Pdf Compliace PDF/A and PDF/UA

I’m setting the PDF compliance to PDF_A_4_UA_2 but the generated document doesn’t appear to be compliant with any PDF/A standard.

@samuele.lucarini

Would you please share your sample source and output PDF for our reference along with the sample code snippet so that we can test the scenario in our environment and address it accordingly.

example :

doc.save(wrongTemplate.toPath().toString(), SaveFormat.ODT);

String pdf = wrongTemplate.toPath().toString().replace(".odt", ".pdf");
try (ByteArrayOutputStream pdfStream = new ByteArrayOutputStream()) {
    PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
    pdfSaveOptions.setUseCoreFonts(false);
    pdfSaveOptions.setExportDocumentStructure(true);
    pdfSaveOptions.setCompliance(
    PdfCompliance.PDF_A_4_UA_2);
    doc.save(pdfStream, pdfSaveOptions);

    try (ByteArrayInputStream inputStream = new ByteArrayInputStream(
    pdfStream.toByteArray())) {
    com.aspose.pdf.Document docPdf = new com.aspose.pdf.Document(inputStream);

    OptimizationOptions options = new OptimizationOptions();
    options.setRemoveUnusedObjects(true);
    options.setRemoveUnusedStreams(true);
    options.setLinkDuplicateStreams(true);
    docPdf.optimizeResources(options);
    docPdf.getInfo().setTitle(name);
    docPdf.setDisplayDocTitle(true);
    docPdf.save(pdf);
    }
}

verbale_base.pdf (80.5 KB)

@samuele.lucarini

Looks like you are first generating PDF from a Word document via Aspose.Words and then optimizing output PDF using Aspose.PDF.

Have you checked saving the file to physical path instead of stream in first phase to see if compliant PDF/A is created by Aspose.Words? Can you please share your source Word file with us as well so that we can test the scenario in our environment and address it accordingly.

I tried to save the document before optimizing but it is not compliant.
beforeOptimize.pdf (80.4 KB)

verbale_base.zip (80.1 KB)

@samuele.lucarini

Looks like that Aspose.Words is not able to generate a compliant document. We are moving the inquiry to respective forum category where you will be assisted from Aspose.Words perspective.

@samuele.lucarini As I can see PAC reports that figures in your document do not have description. Aspose.Words uses alternative text of shapes as description in PDF. but there are no alternative texts set for shapes in your document. Please try using the following code:

Document doc = new Document("C:\\Temp\\in.odt");

// Set shape descriptions.
for (Shape s : (Iterable<Shape>)doc.getChildNodes(NodeType.SHAPE, true))
    s.setAlternativeText("This is dummy shape description");

PdfSaveOptions opt = new PdfSaveOptions();
opt.setCompliance(PdfCompliance.PDF_A_4_UA_2);
doc.save("C:\\Temp\\out.pdf", opt);