Free Support Forum - aspose.com

How to include a new line in a text field

Hello everybody!!!!

I have a problem in a cell from a table where I have to write a few addresses from diferent people. The problem is that I have to write all of them in the same Text field(Text is the kind of the node I use). I have tried to include "\n" between each address but it didn´t work. I would like to fix it whitout change the structure of my code but i don´t know if it is possible. Finally my code execute a "getMailMerge().execute" to replace the mergefield, but it delete the "\n" characters. Somebody know if there are any character to include that make it to work ok or other quick solution???

Thanks a lot.

Hi

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

Thanks for your inquiry. “\n” works as expected in the latest version of Aspose.Words for java. I used the following code for testing:

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

doc.getMailMerge().execute(new String[] { "test" }, new Object[] { "test\ntest" });

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

Also, you can try using line break. See the following code:

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

doc.getMailMerge().execute(new String[] { "test" }, new Object[] { "test" + ControlChar.LINE_BREAK + "test" });

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

You can download the latest version of Aspose.Words for Java from here:

http://www.aspose.com/community/files/72/java-components/aspose.words-for-java/category1378.aspx

Best regards.