Saving as Text

Hi,

I am in the process of evaluating the product for one of our projects. So far it looks great. However I would like to know if there is any fix available for one of problems I noticed. Or am I missing to set any property?

When we save the doc file as .TXT file by using the option SaveFormat.FormatText, the document is saved properly as text file. When open the text file, the line break is perfect as in the word document. But if I open the text file in browser, there is no line break/word wrap. The paragraph is displayed as single line.

Should I set any other property to overcome this problem? Per our requirement, some people would like to view the document as ‘.TXT’ also. Please let me know.

Thanks,
Parva

Hi Parva,

Thank you for your interest in Aspose.Word.

This behaviour is caused by a combination of factors:

1. In Word, a document normally has only paragraph breaks and lines are wrapped automatically to fill the page. Aspose.Word does not insert extra breaks when saving txt file and just saves it as is.
2. The browser does not seem to try to wrap txt files and just displays them as is.

I found an option in Word where you can indicate to insert line breaks when saving document as txt so the lines are broken in the txt file in exactly the same way as they are in the Word document. I think we can add a similar option to Aspose.Word, maybe an option that just specifies maximum width of the line in characters.

But note that although the paragraphs will appear broken into lines in the browser, it still will not wrap the text when you resize the browser window as it normally does with HTML.

You might consider adding some simple html tags , around the text after it was saved as txt to “convert” it to html and displaying in the browser then. This could make extra line breaks unnecessary.