Aspose.PDF for Java – Temp File Locking and Cleanup Issue with ImageStamp(InputStream) and PdfContentEditor

Issue 1: ImageStamp(InputStream)

  • When using ImageStamp(InputStream), Aspose internally creates a temporary image file.
  • These temp files are not deleted until the JVM exits, leading to gradual disk space growth.
  • There is no public API available to explicitly release or delete these temp files.

Issue 2: PdfContentEditor

  • A similar issue occurs when using PdfContentEditor.
  • Temp files are created internally and are not cleaned up reliably, even when the editor instance is explicitly closed.
  • This indicates that the root cause is in Aspose’s internal resource management, not in application-level object lifecycle handling.

Environment:

  • Aspose.PDF for Java version: [e.g., 22.12 ]
  • Java version: [JDK 17]
  • Operating System: [Ubuntu 22.04.5]

Request:

  • Please confirm whether this is a known bug.
  • Provide any possible workarounds (e.g., API calls to force temp file cleanup).

@mubeenraoofm

It sounds like you’re encountering a couple of issues with temporary file management in Aspose.PDF for Java.

Cause:

The behavior you’re experiencing with temporary files not being deleted until the JVM exits is a known issue in the library.

Solution:

Currently, there isn’t a public API available to explicitly release or delete these temp files. However, you can implement the following workarounds:

  1. Manual Cleanup: Implement a manual cleanup process in your application. This could involve periodically checking the temp directory where Aspose stores these files and deleting any that are older than a certain threshold.

  2. Use of PdfContentEditor: When using PdfContentEditor, ensure that you are closing the editor instance properly. While this may not always trigger cleanup, combining this with manual cleanup will help manage temporary files more effectively.

Next Steps:

  • Monitor your disk space usage, especially if your application runs for extended periods without restarting.
  • Consider implementing the manual cleanup routine as soon as possible to prevent potential disk space issues.

If you have further questions or need assistance with implementing a cleanup routine, please feel free to ask! Thank you for your understanding, and I hope this helps!

Temporary files are only cleared when the application is restarted, which is not feasible in production due to potential disruptions. This behavior needs to be addressed in the API itself. Please provide a fix or enhancement that ensures these temporary files are automatically managed and do not require an application restart.

@mubeenraoofm

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFJAVA-45321

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.