Image to PDF/A-1a in Java: wrong format/validation failed

Hi, i’m trying to convert a PNG/JPEG/GIF to PDF in PDF/A-1a format. Unfortunately the test to validate the PDF Format failed:

    @Test
    void testImageToPdfA1a() throws IOException {
        try(ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
            Resource inputDocument = new ClassPathResource("sampleInput.png");

            Image image = Image.load(inputDocument.getInputStream());

            PdfOptions pdfOptions = new PdfOptions();
            PdfCoreOptions pdfCoreOptions = new PdfCoreOptions();
            pdfCoreOptions.setPdfCompliance(PdfComplianceVersion.PdfA1a);
            pdfOptions.setPdfCoreOptions(pdfCoreOptions);

            image.save(outputStream, pdfOptions);

            InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());

            assertThat(new Document(inputStream).validate(outputStream, PdfFormat.PDF_A_1A)).isTrue();
        }
    }

Does anyone knows what i’m doing wrong ? For PDF/A-1b the validation is working:

    @Test
    void testImageToPdfA1b() throws IOException {
        try(ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
            Resource inputDocument = new ClassPathResource("sampleInput.png");

            Image image = Image.load(inputDocument.getInputStream());

            PdfOptions pdfOptions = new PdfOptions();
            PdfCoreOptions pdfCoreOptions = new PdfCoreOptions();
            pdfCoreOptions.setPdfCompliance(PdfComplianceVersion.PdfA1b);
            pdfOptions.setPdfCoreOptions(pdfCoreOptions);

            image.save(outputStream, pdfOptions);

            InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());

            assertThat(new Document(inputStream).validate(outputStream, PdfFormat.PDF_A_1B)).isTrue();
        }
    }

I’m using JDK 17 or 21 and
Maven: com.aspose:aspose-imaging:jdk16:23.10 (aspose-imaging-23.10-jdk16.jar)

According the article PDF/A - Wikipedia
it might be that we do not have enough elements in our PDF.
For example the following.

Additional Level A requirements:

  • Tagged text spans and descriptive text for images and symbols

But it is not an issue of Aspose.Imaging in my view.
I am going to find it out exactly in soon days.

@evgeniy.sidenko someone changed the tag. I posted it originally under Apose.PDF Product Family as bespoke…

@KevinK

We moved this post in Aspose.Imaging directory because you are generated PDF/A using Aspose.Imaging API. We could not notice Aspose.PDF related code in your first post. In case you are using Aspose.PDF as well, you can please create an inquiry in respective category with necessary information and we will proceed to assist you accordingly.

@KevinK
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): IMAGINGJAVA-8611

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.

1 Like