Problem converting pdf to pdf/a

Hi,

Aspose fails to convert a pdf to pdf/a despite the fact that the log states that the file can be converted.

Please advise.

Regs,
Stefan

code involved:

pdfDocument = new Document(newFileName);
pdfDocument.removeMetadata();
boolean result = pdfDocument.convert(logFileName, PdfFormat.PDF_A_2B, ConvertErrorAction.Delete);

pdfDocument.save(targetName);

contents of log:

1.0Copyright (c) 2001-2025 Aspose Pty Ltd. All Rights Reserved.5/20/2025 1:05:56 PMDevice specific color space is used, but no corresponding OutputIntent is present
P239-Uteservering_A-2.pdf (297.7 KB)

@Tefan58

It seems that you are encountering issues when trying to convert a PDF to PDF/A format using Aspose. The log indicates several problems that may be preventing the conversion from succeeding, even though it states that the file is convertible.

Here are some common issues based on the log you provided:

  1. Compressed Objects: The log shows multiple instances of “Object is compressed.” PDF/A requires that all objects be uncompressed. You will need to uncompress these objects before attempting the conversion.

  2. Xref Stream Prohibition: The log mentions “The xref stream is prohibited.” This indicates that the cross-reference stream in your PDF is not compliant with PDF/A standards. You may need to modify the PDF structure to comply with PDF/A requirements.

  3. Non-Embedded Fonts: There are errors indicating that certain fonts (e.g., ‘TimesNewRomanPSMT’ and ‘ArialMT’) are not embedded. PDF/A requires that all fonts used in the document be embedded. You will need to ensure that all fonts are embedded in the PDF.

  4. Inconsistent Glyph Width Information: The log also points out issues with glyph width information for certain embedded fonts. This inconsistency can lead to compliance issues with PDF/A standards.

To address these issues, you can follow these steps:

  • Uncompress Objects: Before conversion, ensure that all objects in the PDF are uncompressed. You may need to manipulate the PDF structure programmatically to achieve this.

  • Embed Fonts: Make sure that all fonts used in the document are embedded. You can do this by setting the appropriate properties in your PDF generation code.

  • Validate Before Conversion: Use the validation method provided by Aspose to check for compliance with PDF/A standards before attempting the conversion. This can help identify issues early on.

Here is a sample code snippet that demonstrates how to validate and convert a PDF to PDF/A:

Document pdfDocument = new Document("input.pdf");

// Validate the document for PDF/A compliance
pdfDocument.validate("validation-log.xml", PdfFormat.PDF_A_2B);

// Convert to PDF/A format
pdfDocument.convert("conversion-log.xml", PdfFormat.PDF_A_2B, ConvertErrorAction.Delete);

// Save the output document
pdfDocument.save("output.pdf");

Make sure to replace "input.pdf" with the path to your PDF file and adjust the output paths as necessary.

If you continue to face issues, consider reviewing the Aspose documentation or community forums for additional guidance on handling specific errors related to PDF/A conversion.

Feel free to reach out if you have further questions or need additional assistance!