Free Support Forum - aspose.com

Different Save Options (MemoryOptimization and TempFolder)

Dear Team,

Looking at the document of the Aspose Word API, I see that in the different save options (eg PdfSaveOptions, ImageSaveOptions etc) there are methods setMemoryOptimization and setTempFolder.

Looking at the text in the documentation it seems like these are only relevant/used when saving a document to docx/doc format, or in general when saving the document.

I would like to know if these settings also have effect in the following cases

  • Save the complete document to PDF

  • Save an individual Shape from the document to some format (in my case TIFF)

Many thanks for clarifying.

Kind regards

Patrick

@PatrickVB,

No. The setTempFolder option is used to specify the folder for temporary files used when saving to a DOC or DOCX file. By default this property is null and no temporary files are used.

However, the setMemoryOptimization option is not bound to output file format. You can set value determining if memory optimization should be performed before saving the document to any format. Default value for this property is false.
Setting this option to true can significantly decrease memory consumption while saving large documents at the cost of slower saving time.

Also, please note that both of these options are inherited from the SaveOptions class.

Hi Awais,

Thanks a lot for the clarifications.

Regards

Patrick

Dear Awais,

Sorry for insisting, but there is still a part of my question unanswered.
For the memoryOptimization, also your explanation is indicating for the saving of the document.
What about memoryoptimizations for saving of an individual shape inside the document.

Will the setting take effect or not?

Kind regards

Patrick

@PatrickVB,

We are checking this scenario and will get back to you soon.

Dear Awais,

Any update on this issue?

Regards

Patrick

@PatrickVB,

Thanks for being patient. The work on your query is still in progress. We will update you soon.

Dear Team,

Any news on this topic.

Regards

Patrick

@PatrickVB,

For saving image from Shape – a most optimal method is the most low level one. I think Shape.getImageData().getImageBytes() can do the trick. The method just returns the image bytes If the image is embedded. Or downloads the bytes of non-embedded image. Shape.getImageData().getImageType() returns a type of the image (ImageType static constant on Java). After getting the bytes and the type, you can save the bytes whatever you want.

About optimization at all – it heavily depends on local environment. For instance, even simple setting like setTempFolder() can produce completely different results on differently configured systems. It is also many image options like SaveOptions.UseHighQualityRendering, ImageSaveOptions.GraphicsQualityOptions, ImageSaveOptions.JpegQuality, ImageSaveOptions.TiffCompression, PdfSaveOptions.ImageCompression, etc. You can trade speed for quality or vice versa, or tweak your specific image types. But all these options are provided to you and you should check them by yourself on your environment and on your documents.

Hi Awais,

Thanks you very much. However doing it low level does not really look like the most attractive option as I then have to deal with things like cropping myself.

I would expect that the development team has some “practices” about how to minimize the usage of memory.
I have the impression that Aspose, expecially when working with shapes is quite memory hungry.

Regards

Patrick

@PatrickVB,

Please ZIP and attach the sample Word document (your are seeing unusual memory usage with) and source code to reproduce the same problem on our end. We will investigate the issue with latest version of Aspose.Words for Java i.e. 18.5 on our end and provide you more information.