We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Newline using \n

Hello,

I’m currently in the progress of migrating our process of generating Word Documents over to Aspose. My question is how i can generate a LineBreak using String format properties. For example I would expect a \n to create a new line in Word. But when I insert a string containing \n there’s more than one new line inserted (see attatched picture which shows my problem in the table at third row, first column)

Best Regards
Jan Thewes

Hello

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. I think in your case, you can try using DocumentBuilder as described here:

http://www.aspose.com/documentation/java-components/aspose.words-for-java/using-documentbuilder-to-modify-a-document-easily-1.html

Please see the following code:

Document doc = new Document("in.doc");

DocumentBuilder builder = new DocumentBuilder(doc);

builder.insertBreak(BreakType.LINE_BREAK);

Best regards,

ok that worked fine, thank you.

another thing. when you look into the first row second columen. there’s a paragraph break behind the text. the text is inserted using “DocumentBuilder.insertHtml()” how can i prevent the paragraph break behind inserted html?

Best Regards
Jan

Hello

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. I suppose your HTML contains

tags, during html import these tags are converted to paragraphs.

Please try using the following code:

Document doc = new Document("C:\\Temp\\in.doc");

DocumentBuilder builder = new DocumentBuilder(doc);

builder.moveToCell(0, 0, 0, 0);

builder.insertHtml("Test");

doc.save("C:\\Temp\\out.doc");

Best regards,