Free Support Forum -

Convert PDF to PDF/A using Java and Aspose.PDF - NullPointerException

I convert a pdf to PDF/A using this code:

Document document = new Document(new ByteArrayInputStream(this.sourceContent));
document.convert(new PdfFormatConversionOptions(PdfFormat.PDF_A_1B, ConvertErrorAction.Delete));

The conversion of this file leads to a java.lang.NullPointerException:

at Source)
at Source)
at Source)
at Source)
at Source)
at Source)
at Source)
at com.aspose.pdf.internal.l8k.l0if.l0l(Unknown Source)
at Source)
at com.aspose.pdf.ADocument.lI(Unknown Source)
at com.aspose.pdf.ADocument.convert(Unknown Source)
at com.aspose.pdf.Document.convert(Unknown Source)

Attached is the input pdf: example.pdf (6.1 KB)

Kind regards!


We used Aspose.PDF for Java 20.10 with following code snippet and were unable to notice any issue. Would you please check attached output PDF and below code snippet and make sure that you are using latest version of the API. Please let us know in case you still face any issue.

Document doc = new Document(dataDir + "example.pdf");
long totalStart = System.currentTimeMillis();
doc.convert(dataDir + "log.xml", PdfFormat.PDF_A_1B, ConvertErrorAction.None); + "Converted.pdf");

Converted.pdf (47.0 KB)