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

Free Support Forum - aspose.com

Line breaks from toText()


I have been trying to export text from a document to place in an email (essentially having an email template stored in a word doc).

I have tested both getText() and toText() methods. I decided to go with toText. The problem is this:

a) When I test from my Java editor, the line breaks are viewable in the output console window.

b) When I retrieve the text through a java bean, using the exact same code, the output loses line breaks and the text is continuous (spaces between words are still viewable).

I tried looking at the following article to try and capture line/paragraph breaks to incorporate back into the string returned from the java bean:


but I cannot see any special set of chars to determine a line break should/has occured so that I can manually handle them in my other application.

Does anyone know how to interperate line breaks once the toText has been passed to a string?

many thanks


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

Thanks for your request. Maybe the following code could help you:

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

String docStr = doc.toTxt();

docStr = docStr.replace(ControlChar.LINE_BREAK_CHAR, '\n');


Best regards.

thanks Alexey, I’ll give that a try.