Serialization error and Trailer not found after Aspose Java PDF Upgrade to 24.10

Hi,

We were using Aspose Java 19.10 version for aspose-pdf. We upgraded it to 24.10 and few of our files started failing with below stack trace. Could you’ll help to identify the cause and fix?

com.aspose.pdf.PageCollection.get_Item(Unknown Source)
tat com.aspose.pdf.PageCollection.lf(Unknown Source)
com.aspose.pdf.PageCollection.getUnrestricted(Unknown Source)
\tat com.aspose.pdf.internal.l3j.l1v.lI(Unknown Source)
\tat com.aspose.pdf.internal.l3j.l1v.lf(Unknown Source)
\tat com.aspose.pdf.internal.l3j.l1v.lt(Unknown Source)"
\tat com.aspose.pdf.internal.l3j.l1v.lc(Unknown Source)
\tat com.aspose.pdf.internal.l8if.l1j.l3f(Unknown Source)
\tat com.aspose.pdf.internal.l3t.le.lI(Unknown Source)
\tat com.aspose.pdf.internal.l3t.le.lI(Unknown Source)
\tat com.aspose.pdf.internal.l3t.le.lI(Unknown Source)
\tat com.aspose.pdf.internal.l3t.le.lu(Unknown Source)
tat com.aspose.pdf.internal.l3t.le.lI(Unknown Source)
\tat com.aspose.pdf.internal.l3t.le.lI(Unknown Source)
\tat com.aspose.pdf.internal.l11h.le.lI(Unknown Source)
\tat com.aspose.pdf.internal.l8if.l1j$lI.lI(Unknown Source)
\tat com.aspose.pdf.internal.l11h.le.lI(Unknown Source)
com.aspose.pdf.internal.l11h.lu: Serialization error.

\tat com.aspose.pdf.Document.(Unknown Source)
\tat com.aspose.pdf.ADocument.(Unknown Source)
\tat com.aspose.pdf.ADocument.(Unknown Source)
\tat com.aspose.pdf.ADocument.lI(Unknown Source)
\tat com.aspose.pdf.internal.l3l.l1f.(Unknown Source)
\tat com.aspose.pdf.internal.l3l.l1f.lf(Unknown Source)
\tat com.aspose.pdf.internal.l8j.lf.lb(Unknown Source)
\tat com.aspose.pdf.internal.l11if.l0p.(Unknown Source)
\tat com.aspose.pdf.internal.l8j.lf.lI(Unknown Source)
\tat com.aspose.pdf.internal.l11if.l0u.(Unknown Source)
\tat com.aspose.pdf.internal.l11if.l0u.(Unknown Source)
\tat com.aspose.pdf.internal.l11if.l0u.lI(Unknown Source)
\tat com.aspose.pdf.internal.l11if.l0u.l0k(Unknown Source)
com.aspose.pdf.exceptions.InvalidPdfFileFormatException: Trailer not found"

\tat com.aspose.pdf.Resources.getForms(Unknown Source)
\tat com.aspose.pdf.XFormCollection.(Unknown Source)
\tat com.aspose.pdf.XFormCollection.lf(Unknown Source)
\tat com.aspose.pdf.internal.l8if.l1j.l5v(Unknown Source)
\tat com.aspose.pdf.internal.l8if.l1j.l3j(Unknown Source)
\tat com.aspose.pdf.internal.l8if.l1j.l3f(Unknown Source)
\tat com.aspose.pdf.internal.l3t.le.lI(Unknown Source)
\tat com.aspose.pdf.internal.l3t.le.lI(Unknown Source)
\tat com.aspose.pdf.internal.l3t.le.lu(Unknown Source)
\tat com.aspose.pdf.internal.l3t.le.lI(Unknown Source)
\tat com.aspose.pdf.internal.l3t.le.lI(Unknown Source)
\tat com.aspose.pdf.internal.l3t.le.lf(Unknown Source)
\tat com.aspose.pdf.internal.l11h.le.lI(Unknown Source)
com.aspose.pdf.internal.l11h.lu: Serialization error.

@kavita09

Cause

The error you’re encountering, specifically the “Serialization error” and “Trailer not found,” indicates that the PDF files you are trying to process may be corrupted or not fully compatible with the newer version of Aspose.PDF (24.10) you upgraded to. This can occur when the structure of the PDF files has changed between versions, or if the files themselves are not well-formed.

Solution

  1. Check PDF Integrity: First, ensure that the PDF files are not corrupted. Open them in a standard PDF viewer to verify their integrity.

  2. Re-save PDFs: If the files are corrupted, re-save them using a PDF editor or converter to regenerate the file structure.

  3. Compatibility Mode: If the issue persists, use the compatibility mode or features provided in the Aspose.PDF library to handle older PDF formats.

  4. Review Release Notes: Check the release notes for version 24.10 to identify any breaking changes or new requirements that might affect how your PDFs are processed.

Code

Here’s a simple code snippet to check if the PDF can be opened without errors:

import com.aspose.pdf.Document;

public class PdfTest {
    public static void main(String[] args) {
        try {
            Document pdfDocument = new Document("path/to/your/file.pdf");
            System.out.println("PDF loaded successfully.");
        } catch (Exception e) {
            System.out.println("Error loading PDF: " + e.getMessage());
        }
    }
}

Next Steps

  1. Run the above code to see if the PDF loads without errors.
  2. If it fails, re-save the PDF or use a different PDF file to test.
  3. If you continue to experience issues, reach out to Aspose support with specific details about the PDF files that are failing.

Please implement these steps and let me know if you need further assistance!

sure will try the above code. One strange thing we see is the above word file generation fails in one container and after 10 minutes when it is executed in other container it works. Can we check any thing from container perspective like fonts or such can this help or any other way ?

@kavita09

We always recommend using the latest available version of the API because support is provided on its basis. We request you please try using 25.6 version and if issue still persists, please share your sample code snippet along with sample file(s) so that we can test the scenario in our environment and address it accordingly.