You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by ch...@me.com.INVALID on 2025/06/24 09:03:18 UTC

PDF/A validation fails in the test environment, but works in production

Hello PDFBox Community,

The validation of a PDF/A - 1b file fails in the test but is successful in
production with the same data. What could be the reason for the different
results? The error message indicates that the metadata could not be read
because it is "nested". The metadata is only set in the conversion method
and there should be no differences between test and production. Do you have
any ideas as to why this could be?

 

## Conversion process

1.	JxBrowser creates a file from HTML
2.	PDFBox converts to PDF/A - 1b

 

## Validation Error

Jun 23, 2025 2:09:39 PM org.verapdf.gf.model.impl.pd.GFPDMetadata
getXMPPackage

WARNING: Problems with parsing metadata. Nested content not allowed with
rdf:resource or property attributes

org.verapdf.xmp.XMPException: Nested content not allowed with rdf:resource
or property attributes

              at
org.verapdf.xmp.impl.ParseRDF.rdf_EmptyPropertyElement(ParseRDF.java:841)

              at
org.verapdf.xmp.impl.ParseRDF.rdf_PropertyElement(ParseRDF.java:438)

              at
org.verapdf.xmp.impl.ParseRDF.rdf_PropertyElementList(ParseRDF.java:312)

              at
org.verapdf.xmp.impl.ParseRDF.rdf_NodeElement(ParseRDF.java:192)

              at
org.verapdf.xmp.impl.ParseRDF.rdf_ResourcePropertyElement(ParseRDF.java:584)

              at
org.verapdf.xmp.impl.ParseRDF.rdf_PropertyElement(ParseRDF.java:471)

              at
org.verapdf.xmp.impl.ParseRDF.rdf_PropertyElementList(ParseRDF.java:312)

              at
org.verapdf.xmp.impl.ParseRDF.rdf_NodeElement(ParseRDF.java:192)

 

## Convert implementation

static ByteArrayOutputStream convert(File file, PDFBuilder.PDFFlavour
pdfFlavour) throws Exception {
    try (PDDocument document = PDDocument.load(file)) {
        PDFAFlavour veraPDFFlavour =
PDFAUtils.pdfAFlavourMapper(pdfFlavour);

        XMPMetadata xmpMetaData = XMPMetadata.createXMPMetadata();
        PDDocumentInformation docInfo = document.getDocumentInformation();
        createPDFAIdentificationSchema(xmpMetaData, veraPDFFlavour);
        createDublinCoreSchema(docInfo, xmpMetaData);
        createXMPBasicSchema(docInfo, xmpMetaData);
        createAndAddAdobePDFSchema(docInfo, xmpMetaData);

        PDDocumentCatalog documentCatalog = document.getDocumentCatalog();
        PDMetadata metadata = new PDMetadata(document);

        XmpSerializer serializer = new XmpSerializer();
        ByteArrayOutputStream byteArrayOutputStream = new
ByteArrayOutputStream();
        serializer.serialize(xmpMetaData, byteArrayOutputStream, true);

        metadata.importXMPMetadata(byteArrayOutputStream.toByteArray());
        documentCatalog.setMetadata(metadata);

        PDCIDSetEmbedder.setPDFontDescriptorCIDSet(document);
        InputStream colorProfile =
PDF2PDFAConverter.class.getResourceAsStream("/resources/sRGB2014.icc");
        PDOutputIntent pdOutputIntent = createOutputIntent(document,
colorProfile);
        documentCatalog.addOutputIntent(pdOutputIntent);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        document.save(out);
        document.close();

        return out;
    } catch (IOException | BadFieldValueException | TransformerException |
IllegalArgumentException exception) {
        throw new PDFAConverterException(exception.getCause());
    }
}

 


Re: PDF/A validation fails in the test environment, but works in production

Posted by Tilman Hausherr <TH...@t-online.de>.
How are the two files different? Can you upload both PDF files somewhere?

Maybe test and production use different PDFBox or VeraPDF versions?

Tilman

On 6/24/2025 11:03 AM, christian_kulesza@me.com.INVALID wrote:
> Hello PDFBox Community,
>
> The validation of a PDF/A - 1b file fails in the test but is successful in
> production with the same data. What could be the reason for the different
> results? The error message indicates that the metadata could not be read
> because it is "nested". The metadata is only set in the conversion method
> and there should be no differences between test and production. Do you have
> any ideas as to why this could be?
>
>   
>
> ## Conversion process
>
> 1.	JxBrowser creates a file from HTML
> 2.	PDFBox converts to PDF/A - 1b
>
>   
>
> ## Validation Error
>
> Jun 23, 2025 2:09:39 PM org.verapdf.gf.model.impl.pd.GFPDMetadata
> getXMPPackage
>
> WARNING: Problems with parsing metadata. Nested content not allowed with
> rdf:resource or property attributes
>
> org.verapdf.xmp.XMPException: Nested content not allowed with rdf:resource
> or property attributes
>
>                at
> org.verapdf.xmp.impl.ParseRDF.rdf_EmptyPropertyElement(ParseRDF.java:841)
>
>                at
> org.verapdf.xmp.impl.ParseRDF.rdf_PropertyElement(ParseRDF.java:438)
>
>                at
> org.verapdf.xmp.impl.ParseRDF.rdf_PropertyElementList(ParseRDF.java:312)
>
>                at
> org.verapdf.xmp.impl.ParseRDF.rdf_NodeElement(ParseRDF.java:192)
>
>                at
> org.verapdf.xmp.impl.ParseRDF.rdf_ResourcePropertyElement(ParseRDF.java:584)
>
>                at
> org.verapdf.xmp.impl.ParseRDF.rdf_PropertyElement(ParseRDF.java:471)
>
>                at
> org.verapdf.xmp.impl.ParseRDF.rdf_PropertyElementList(ParseRDF.java:312)
>
>                at
> org.verapdf.xmp.impl.ParseRDF.rdf_NodeElement(ParseRDF.java:192)
>
>   
>
> ## Convert implementation
>
> static ByteArrayOutputStream convert(File file, PDFBuilder.PDFFlavour
> pdfFlavour) throws Exception {
>      try (PDDocument document = PDDocument.load(file)) {
>          PDFAFlavour veraPDFFlavour =
> PDFAUtils.pdfAFlavourMapper(pdfFlavour);
>
>          XMPMetadata xmpMetaData = XMPMetadata.createXMPMetadata();
>          PDDocumentInformation docInfo = document.getDocumentInformation();
>          createPDFAIdentificationSchema(xmpMetaData, veraPDFFlavour);
>          createDublinCoreSchema(docInfo, xmpMetaData);
>          createXMPBasicSchema(docInfo, xmpMetaData);
>          createAndAddAdobePDFSchema(docInfo, xmpMetaData);
>
>          PDDocumentCatalog documentCatalog = document.getDocumentCatalog();
>          PDMetadata metadata = new PDMetadata(document);
>
>          XmpSerializer serializer = new XmpSerializer();
>          ByteArrayOutputStream byteArrayOutputStream = new
> ByteArrayOutputStream();
>          serializer.serialize(xmpMetaData, byteArrayOutputStream, true);
>
>          metadata.importXMPMetadata(byteArrayOutputStream.toByteArray());
>          documentCatalog.setMetadata(metadata);
>
>          PDCIDSetEmbedder.setPDFontDescriptorCIDSet(document);
>          InputStream colorProfile =
> PDF2PDFAConverter.class.getResourceAsStream("/resources/sRGB2014.icc");
>          PDOutputIntent pdOutputIntent = createOutputIntent(document,
> colorProfile);
>          documentCatalog.addOutputIntent(pdOutputIntent);
>
>          ByteArrayOutputStream out = new ByteArrayOutputStream();
>          document.save(out);
>          document.close();
>
>          return out;
>      } catch (IOException | BadFieldValueException | TransformerException |
> IllegalArgumentException exception) {
>          throw new PDFAConverterException(exception.getCause());
>      }
> }
>
>   
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org