Problem inserting multiline text to a Word document using Aspose.Words 9.4.0.0

Hi, I’m inserting a multine line text
“Zeile1
Zeile2
Zeile3”
into a Word document using Aspose.Words 9.4.0.0. The result contains some special characters as you can see in the attached sample.doc. Exporting to HTML works fine. An export to PDF also contains these special characters.
Thanks and regards.

Hi

Thanks for your inquiry. These special characters are LineFeed characters. Could you please show me code that you use to insert text into the document? I will check it and provide you more information.
Best regards.

Words::Document ^doc = gcnew Words::Document;
doc->RemoveAllChildren();
Words::Section ^section = gcnew Words::Section(doc);
doc->AppendChild(section);
section->PageSetup->SectionStart = Words::SectionStart::NewPage;
section->PageSetup->PaperSize = Words::PaperSize::A4;
Words::Body ^body = gcnew Words::Body(doc); 
section->AppendChild(body);
Words::Paragraph ^para = gcnew Words::Paragraph(doc);
body->AppendChild(para);
para->ParagraphFormat->Alignment = Words::ParagraphAlignment::Center;
Words::Run ^run = gcnew Words::Run(doc);
run->Text = "Zeile1\r\nZeile2\r\nZeile3";
para->AppendChild(run);
doc->Save("d:\\temp\\sample.doc");

Hi

Thank you for additional information. Why do not use DocumentBuilder to insert text:
https://reference.aspose.com/words/net/aspose.words/documentbuilder/write/
It is much easier to generate document using DocumentBuilder than using DOM.
In your case the problem occurs because you insert text with LineFeed characters (Paragraph breaks) into a Run. If you insert the same text using DocumentBuilder, there will not be any problem because your text will be translated into three paragraphs.
If you still would like to use DOM approach to built your document, then replace LineFeed characters’\n’ in your string with LineBreak character ‘\v’:
https://reference.aspose.com/words/net/aspose.words/controlchar/
Best regards,

That works. Thanks and regards.