first of, I don't know much about XSL.
I am using a app called DITA to generate pdfs. One of the things it requires is an overwrite of an xsl file; to add custom styling.
I am trying to add an external graphic using a relative path. It doesn't work, unless I supply the full path.
Does not work:
<fo:block text-align="center" width="100%">
<fo:external-graphic src="../../images/logo.png"/>
</fo:block>
Does work:
<fo:block text-align="center" width="100%">
<fo:external-graphic src="/absolute/path/to/images/logo.png"/>
</fo:block>
I looked on the web, it said to use "file:image.png" and other website said to use "url(image.png)", but neither worked.
What am I doing wrong?
This is an old question but something that is often misunderstood when working with DITA-OT.
The important thing to know is that the external-graphic path is relative to the DITA-OT artwork.dir.
I can think of two ways to do add the logo.
Copy logo.png into the arwork diretory
DITA-OT/demo/fo/cfg/common/artwork/logo.png
Change your xsl graphic path to
<fo:block text-align="center" width="100%">
<fo:external-graphic src="Configuration/OpenTopic/cfg/common/artwork/logo.png"/>
</fo:block>
It is possible to change the artwork directory from which DITA takes it's pictures as well as the output directory which will be used by FOP to render the PDF.
open the build.xml file
DITA-OT/demo/fo/build.xml
Define the root directory where DITA should copy the artwork to The default is
<property name="artwork.dir" value="${dita.map.output.dir}"/>
Which will set the root to where your final PDF will be saved.
Define the path where the files should be stored relative to the artwork root directory
<copy todir="${coreArtworkDestinationDir}/Configuration/OpenTopic"
By default it will create the folders /Configuration/OpenTopic
and then copy everything in there including sub directories.
Make sure to change the destination twice. The two places you have to edit are only a few lines apart.
Define where the original artwork is saved so that DITA-OT can copy the files to the destination.
The first line points to the default artwork that come with DITA-OT and should not be changed.
<fileset dir="${basedir}" includes="cfg/common/artwork/**/*.*"/>
The second one is intended for customizing thus being the one that should be used for customization.
<fileset dir="${customization.dir}" includes="common/artwork/**/*.*"/>
The path is relative to DITA-OT/demo/fo/Customization.