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

Free Support Forum - aspose.com

Re: SaveOptions.setTempFolder() doesn't seem to be working

So for what does

pdfSaveOptions.setTempFolder("/tmp/XXXX");

???

You are in right saying SaveOptions.TempFolder specifies the folder for temporary files used when saving to a DOC or DOCX file. So it isn’t the location for the created PDF file! BUT it is the location for necessary TMP files!


But I thing the TempFolder doesn’t works at all!

I am using AsposeWords for Java 11.11.0 and I do this

PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setSaveFormat(SaveFormat.PDF);
pdfSaveOptions.setCompliance(PdfCompliance.PDF_A_1_B);
pdfSaveOptions.setImageCompression(PdfImageCompression.AUTO);
pdfSaveOptions.setJpegQuality(jpegQuality);
pdfSaveOptions.setTempFolder("/tmp/XXXX");

I use LINUX, but my temporary image files will still saved on /tmp AND NOT on /tmp/XXXX as requested!!!

So there should be really a BUG.

Michael

Hi Michael,


Thanks for your inquiry.

Aspose.Words for Java uses a temporary directory on your machine that is specified via java.io.tmpdir
system property. Aspose.Words writes temporary files and removes them
as soon as rendering is completed. “java.io.tmpdir” is a standard Java
system property which is also used by the disk-based storage policies.
It determines where the JVM writes temporary files. You can change the
value of this property for example by
using System.setProperty(“java.io.tmpdir”, "/mytempdir) method. I hope,
this helps.

Hi Michael,


Further to my last post, I have logged a new feature request as WORDSNET-10154 to specify folder for temporary files when saving document to PDF file format. You will be notified via this forum thread once this feature is available.

Please let us know if you have any more queries.

Hi Michael,


Thanks for your inquiry. PdfSaveOptions.TempFolder is inherited from SaveOptions. This property specifies 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.

When Aspose.Words saves a document, it needs to create temporary internal structures. By default, these internal structures are created in memory and the memory usage spikes for a short period while the document is being saved. When saving is complete, the memory is freed and reclaimed by the garbage collector.

If you are saving a very large document (thousands of pages) and/or processing many documents at the same time, then the memory spike during saving can be significant enough to cause the system to throw OutOfMemoryException. Specifying a temporary folder using TempFolder will cause Aspose.Words to keep the internal structures in temporary files instead of memory. It reduces the memory usage during saving, but will decrease the save performance.

The folder must exist and be writable, otherwise an exception will be thrown. Aspose.Words automatically deletes all temporary files when saving is complete.

Hi Michael,


Thanks for your patience. Regarding WORDSNET-10154, could you please share your input document and source code that produces OutOfMemoryException exception?