Reputation: 149
I have an XSL document that transforms an XML document to a PDF. It had been working fine until I was asked to enhance this so that it is possible to add attachment to the PDF as well. I searched and found that the XSL must be edited in the following manner to achieve that.
1.The fo:root element should include xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf attribute.
< fo:declarations>
< pdf:embedded-file filename=" myfile.text " src=" url(file:///C:/Bill.txt" />
< /fo:declarations>
Now when I run the transformation I get the following error.
Unknown formatting object "{http://xmlgraphics.apache.org/fop/extensions/pdf}embedded-file" encountered (a child of fo:declarations}. (No context info available)
I searched a lot over the internet but could not find a solution to it. Can someone help me here ?
Upvotes: 2
Views: 1996
Reputation: 3778
Apparently, your code fragment seems to respect the documentation for the extension element pdf:embedded-file (note that a namespace URI like http://xmlgraphics.apache.org/fop/extensions/pdf is just an identifier, it doesn't necessarily point to a web resource).
However, I tested this simple example with FOP 1.1 (by the way, you did not say which version of FOP you are using) and it works as expected:
<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
<fo:layout-master-set>
<fo:simple-page-master master-name="one">
<fo:region-body />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:declarations>
<pdf:embedded-file filename="test.png" description="This is just an image" src="https://www.google.it/images/srpr/logo11w.png"/>
</fo:declarations>
<fo:page-sequence master-reference="one">
<fo:flow flow-name="xsl-region-body">
<fo:block><fo:basic-link external-destination="url(embedded-file:test.png)">Attached image</fo:basic-link></fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
I was able to produce the error message you receive (Unknown formatting object ...) using an incorrect namespace URI, for example adding a space at the beginning or at the end; so I suggest you check if your declaration of the pdf namespace is exactly like this:
xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf"
Upvotes: 5