Page 1 of 1

Include local Graphic in Docbook -> Pdf

Posted: Wed Dec 20, 2017 3:36 pm
by Chris89
Hello everyone,

im currently trying to customize a docbook footer and for that i need to include an image in that footer.
Sadly the including of an image is not yet working. I have the PNG file test.png that is located at N:\test.png for simplicity.

I tryed to include it like this

Code: Select all

<fo:external-graphic content-height="1.2cm">
          <xsl:attribute name="src">
            <xsl:call-template name="fo-external-image">
              <xsl:with-param name="filname" select="N:/test.png'"/>

However the line

Code: Select all

<xsl:with-param name="filname" select="'N:\test.png'"/>

seems not to work.

My questin is: How do i have to specify the local path (absolut) so that my image gets included in the final pdf output.

Re: Include local Graphic in Docbook -> Pdf

Posted: Wed Dec 20, 2017 3:44 pm
by Radu

Ideally as this question is Docbook related you could consider registering on the Docbook-Apps mailing list and asking it there:

We do not work much with Docbook internally and the Docbook users list contains lots of experienced Docbook users.
I'm not sure in what context your XSLT code gets called, maybe you can add a variable definition around the call-template and then use an xsl:message to list the variable's value and see if the source for the image is properly computed.
I would also suggest sending the image reference as an URL like file:/N:/test.png instead of N:/test.png.
If you have defined the "Docbook PDF" transformation scenario in Oxygen you can also press the "Debug Transformation Scenario" toolbar button to switch to the XSLT Debugger perspective, run the transformation there and see what the generated XSL-FO file looks like.


Re: Include local Graphic in Docbook -> Pdf

Posted: Thu Dec 21, 2017 9:44 am
by Radu
Linking to the discussion Christian started on the Docbook Users List for future reference:

So the correct solution was that absolute references to images in the XSL-FO were to have three slashes, like "file:///c:/test.png" in order for the processor to properly interpret them.
Sorry for not testing my previous solution with using a single slash for the URL, Oxygen knows both these formats but the FO processor seems to be limited at interpreting only one kind of file URL.
Two more things:

- In the Oxygen Preferences->"XML / XSLT-FO-XQuery / FO Processors" you can choose to enable the output of the built-in FO processor. This will show you possible warnings when such problems are encountered.
- Ideally you should avoid absolute references completely as they make the XSLT processing not portable, somebody else would need to copy the image in precisely the same place as you do in order to make this work. So ideally you would have a reference in the XSL-FO file relative to where it is placed on disk.