1
votes

I am generating a PDF document from an XML using XSL template in Apache FOP API. My applications requires the PDF documents to be generated dynamically.

Now, I need to set the language of the document to English (which defaults to x:unknown). How can I add this meta-info using XSL-FO or i-text?

1
Setting the language isn't the only thing you need to do when making a PDF accessible (accessible PDF is PDF/UA). Please read my answer to the question How can I generate a PDF/UA compatible PDF with iText? You'd also benefit from reading the book about ZUGFeRD. It's about making invoices, but it also explains how to create PDF/UA based on invoices created in HTML (which is originally generated from XML).Bruno Lowagie

1 Answers

1
votes

Set xml:lang (https://www.w3.org/TR/xsl11/#xml.lang). E.g.:

<fo:root xml:lang="en" xmlns:fo="http://www.w3.org/1999/XSL/Format">

(You don't need a namespace declaration for the xml prefix because it's known to every XML processor.)