Aspose pdf using C: drive Temp directory to generate temporary files

While trying to generate docx from pdf , it is creating temp files in C: drive :- temp folder(see attached image)
I’m trying to generate docx from pdf using Document | Aspose.PDF for Java API Reference
Following is the code snippet :

import com.aspose.pdf.Document;
import com.aspose.pdf.License;
import com.aspose.pdf.SaveFormat;
			
		File pdfToDocx = this.tempfileManager.getTempFileWithGivenName("PdfToDocx.docx", publishingContext.getProcessId());
		File pdfFile = inputPDFDocInfo.getFile();

		pdf = new Document(pdfFile.getAbsolutePath());

		**pdf.save(pdfToDocx.getAbsolutePath(), SaveFormat.DocX);**

temporary files are genrated when I call pdf.save method
image.jpg (294.2 KB)

Is there any way this can get cleaned up after method execution? Can we change the default temp files storage path?

@qppUser

This is not a bug. We use java.awt when working with system fonts and the following method works in such way (creates temp files and track them):

java.awt.Font.createFont(int fontFormat, InputStream fontStream)
java.awt.Font.createFont(int fontFormat, java.io.File fontFile)

The temp files will be deleted by JVM with using ShutdownHook when the program exits normally.

https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread)

Java tracker blocks 20 of the last used temp files and does not allow to delete them during process.

Also, notice please, that method: MemoryCleaner.clearAllTempFiles(); - deletes only files from temp directory that placed in the sub-folder “aspose_pdf” or have name that starts as “aspose_”. And we strongly recommend that you do not clear temporary files during the process when converting any document, because JVM may crash java process.

The process must be completed and a cleaner must be started before the conversion of a new document begins.

You may configure separate temp folder for Aspose process adding the property before starting main code:

System.setProperty("java.io.tmpdir", "D:/tmp");
setLicense();

If used memory stream to hold font data, java will save them in temp folder anyway with mask: “+~JF *** .tmp” in temp folder. We are using mask “aspose_ *** .tmp” to separate temp files generated by Aspose.PDF.

Thanks for the assist, will definitely try this.

There are some inbuild header files that can help to out from this situation.