3

I want to create a valid PDF/A2-b File. After that in wanna put in a ZUGFeRD invoice with the PDFLib libary.

Every time I check the PDF with a Online Validator I get the following error:

rechnung.pdf does not conform to PDF/A.

Validating file "rechnung.pdf" for conformance level pdfa-2b
dc:language :: Wrong value type. Expected type 'bag'.
The document does not conform to the requested standard.
The document's meta data is either missing or inconsistent or corrupt.

Done.

Here´s the part with my meta informations for FOP.

<fo:declarations>
    <x:xmpmeta xmlns:x="adobe:ns:meta/">
        <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
            <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/">
                <dc:title>
                    <rdf:Alt>
                        <rdf:li xml:lang="x-default">Titel</rdf:li>
                    </rdf:Alt>
                </dc:title>
                <dc:creator>
                    <rdf:Seq>
                        <rdf:li>Creator</rdf:li>
                    </rdf:Seq>
                </dc:creator>
                <dc:description>
                    <rdf:Alt>
                        <rdf:li xml:lang="x-default">PDF/A Rechnung</rdf:li>
                    </rdf:Alt>
                </dc:description>
                <dc:date>
                    <rdf:Seq>
                        <rdf:li>2016-10-20</rdf:li>
                    </rdf:Seq>
                </dc:date>
            </rdf:Description>
            <rdf:Description rdf:about=""
                xmlns:xmp="http://ns.adobe.com/xap/1.0/">
                <!-- XMP properties go here -->
                <xmp:CreatorTool>Creator Tool</xmp:CreatorTool>
            </rdf:Description>
        </rdf:RDF>
    </x:xmpmeta>
</fo:declarations>

FOP gets the language part for the meta data from the fo:root element.

<fo:root xml:lang="de"
     xmlns:fo="http://www.w3.org/1999/XSL/Format"
     font-family="PT-Sans" font-weight="normal" font-style="normal"
     xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">

But when I´m opening the PDF File with my notepad++, the dc:language has no type specification. And that´s the problem I think.

How can I get these specification in the file?

Bevor that I have tried to add it like the other declarations like that:

<dc:language>
    <rdf:Bag>
        <rdf:li>de-DE</rdf:li>
    </rdf:Bag>
</dc:language>

But then I get the same failure message from the Validator. Why? Because then the language in the PDF file has the following content:

<dc:language>x-unknown</dc:language>

The value "x-unknown" is comming directly from FOP I think.

In a forum I have read that there is a method in the constructor from the java/org/apache/fop/pdf/PDFRoot.java file that is called "setLanguage("x-unknown");" since FOP 1.1.

Than I have looked in the actually FOP und she is still inside.

java/org/apache/fop/pdf/PDFRoot.java[80:9]

public PDFRoot(PDFDocument document, PDFPages pages) {
    this.document = document;
    setObjectNumber(document);
    put("Type", new PDFName("Catalog"));
    setRootPages(pages);
    setLanguage("x-unknown");
}
Dennis
  • 85
  • 6
  • Servus Dennis. According to [this](https://stackoverflow.com/questions/39017700/how-to-set-the-default-language-in-apache-fop/39025726#39025726) usually xml:lang on fo:root does set the pdf language correctly. Are you on FOP 2.1? – Stefan Hegny Oct 24 '16 at 20:25
  • Servus, Stefan. Yes I´m using FOP 2.1 as you can see in the Headline ;-) I also found the question you linked, and I was also trying these steps, but I got the same error again and again :( The problem for me is not, that I can´t see the language in the Adobe Reader, I don´t care about that. But I also can see a language reference in the PDF file if I´m open it with my notepad++. And the PDF Validator how´s linked above always says it´s not valide. Currently I´m looking for generating PDF´s directly with PDFLib. – Dennis Oct 25 '16 at 14:25
  • 1
    notepad++ may not be the best tool for it, you could try the PDFDebugger from the pdfbox. Before my attempts I had used exiftool to set the language which also worked fine but involved an extra step. Maybe you try with [exiftool](http://www.sno.phy.queensu.ca/~phil/exiftool/), check if that makes it validate and then compare with the fop output. – Stefan Hegny Oct 25 '16 at 14:49
  • Ok thanks, i´ll try it at work tomorrow. – Dennis Oct 25 '16 at 16:38
  • I got it now. After I was deleting all XMP Metas from the xsl-fo i got a valid PDF/A File. Now I can add the Metas with PDFlib and everything is good. Thanks for the support! – Dennis Nov 04 '16 at 07:52

1 Answers1

0

I had the same problem with Apache FOP 2.2 and 2.4 and I think that it is a bug with Apache FOP itself. Apache FOP should create an array/bag under < dc:language > and put the values in it, but instead it puts the value directly under < dc:language >.

For me the solution was that I added the XMP Metadata in a second step with Apache PDFBox.

Olcay Ertaş
  • 5,987
  • 8
  • 76
  • 112
Stephan Berg
  • 124
  • 1
  • 3