RTF file 600% size increase after saving with words, java

Hello,

The attached rtf file gets over 600% size increase after opening it and saving with aspose words for java 15.2.0

			LoadOptions loadOptions = new LoadOptions();
		loadOptions.setLoadFormat(LoadFormat.RTF);
		Document doc = new Document("/tmp/RTF-Spec-1.7.rtf", loadOptions);
		doc.save("/tmp/RTF-Spec-1.7_saved.rtf", SaveFormat.RTF);

edit:
original file size: 2.1M
after saving: 13M

Regards,
ArikRTF-Spec-1.7.zip (205.3 KB)

@arik-1,

Thanks for your inquiry. Please use the following code example to fix the shared issue. Hope this helps you.

Document srcDoc = new Document(MyDir + "RTF-Spec-1.7.rtf");
RtfSaveOptions options = new RtfSaveOptions();
options.setExportCompactSize(true);
options.setExportImagesForOldReaders(false);
srcDoc.save(MyDir + "18.1.rtf", options);

Thanks, that helped.
The resulting file is 4.7M which is only twice as big and not six times.

@arik-1,

Thanks for your feedback. It is nice to hear from you that your problem has been solved. Please note that Aspose.Words mimics the behavior of MS Word. If you re-save your RTF document using MS Word, you will get the same output.

1 Like

Hi @tahir.manzoor,

I was going to ask about this and saw this thread. It seems this mostly happens when there are pictures. I confirm though that setting ExportImagesForOldReaders=false (I’m using .Net) alleviates the issue.

Saving via Aspose or Word does produce files that looks the same, but the size is much bigger if setExportImagesForOldReaders=true.

Is there any drawbacks with setting this to false? I read in the reference that “document may not display properly on older readers”, what does “older readers” mean? And is this something that will be updated in future releases?

sampleFiles.zip (356.3 KB)

Thanks.

@dcdeveloper,

Thanks for your inquiry. The “Old readers” are pre-Microsoft Word 97 applications and also WordPad. When this option is true Aspose.Words writes additional RTF keywords. These keywords allow the document to be displayed correctly when opened in an “old reader” application, but can significantly increase the size of the document.

If you set this option to false, then only images in WMF, EMF and BMP formats will be displayed in “old readers”.