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

Free Support Forum - aspose.com

How to disable word-wrap for txt files in the Aspose.Words

Hi,

I need to convert txt to image and I use Aspose.Words.
I just open txt and try to save it to PNG like following:

doc = new Document(new BufferedInputStream(new FileInputStream(txtFile)));
imgOptions = new ImageSaveOptions(SaveFormat.PNG);
imgOptions.setUseAntiAliasing(true);
imgOptions.setResolution(AsposeTest.DPI);
imgOptions.setUseHighQualityRendering(true);
imgOptions.setPageCount(1);
imgOptions.setPageIndex(0);
doc.save(new BufferedOutputStream(new FileOutputStream(output)), imgOptions);

Then I get png, but I can see that txt file doesn’t well-formed. You can see what I mean in the attached screenshot.

Could you please advise how to write code properly to get txt as png in “well-formed” manner?

Thank you.

Hi Josh,

Thanks for your inquiry. Could you please attach your input txt file here for testing? I will investigate the issue on my side and provide you more information.

Test txt has been attached (ANSI encoding).

Hi Josh,

Thanks for sharing the document. Aspose.Words supports following Text Encoding while loading text file into Aspose.Words DOM.

  • Latin1.
  • BigEndianUnicode.
  • UTF-16.
  • UTF-7.
  • UTF-8.

Please read following documentation link for more detail.
https://docs.aspose.com/words/net/create-or-load-a-document/

However, I have logged loading of ANSI encoding feature as WORDSNET-8127 in our issue tracking system. You will be notified via this forum thread once this feature is available. We apologize for your inconvenience.

Moreover, please read supported features of plain text (txt) import/export from here:
https://docs.aspose.com/words/net/load-in-the-plain-text-format/
https://docs.aspose.com/words/net/save-in-the-plain-text-format/

The issues you have found earlier (filed as WORDSNET-8127) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.