blog.sirkevi.com

floating in the ether

Making pdf links with fop and docbook

Wow, all weekend I tried to get any PDF links using FOP 20.5 XSL Stylesheets 1.69 and olink (I needed olink since I had broken my book into chapter.xml files). Links to within the same .xml orignal file worked but as soon as I tried to cross link to another section... no link.

All I wanted was clickable cross links in my PDF to other sections in a PDF document. It works great when you have one single XML document and link things with xref and link but as soon as you try and get fancy and break out the chapters into their own chapter.xml files and then put them together as a book things get nightmarish.

Once I had broken everything up into their own XML files I saw that my xrefs and links were not working any more, at least when they referred to something in one of the other files. Of course everything worked great with RenderX's XEP but that is expensive and I needed something in a free processor like Apache's FOP.

The best I could get was this error "FO processing failed: internal-destination or external-destination must be specified in basic-link" and that was after discovering I needed olinks and needed to make a text file to describe where the links were kept (olinkdb.xml). Ugh, what a pain.

Of course I had the syntax for that olinkdb.xml file all messed up and couldn't understand the whole olink idea to begin with. Finally I got the olinkdb file right... with some tests using RenderX's XEP Personal edition. Then thanks to Google I came across this newsgroup comment from 2 weeks ago and everything started to fall into place: HERE .

So, following Robert's suggestion to turn off insert.xref.page.number I suddenly found my olinks appearing Happy. No page numbers or named destinations but at least there are links. RenderX works great with this insert.xref.page.number activated but FOP just choked unless it was off.

Here is a summary of what I did. Note any directory paths to be sure files are in the right place.
  1. make a customization xsl file with the following parameters:

    < xsl :param name="fop.extensions" select="1"/>
    < xsl :param name="insert.xref.page.number" select="0"/>
    < xsl :param name="targets.filename" select="'C:/documents/targets.db'">
    < xsl :param name="target.database.document" select="'file:/C:/documents/olinkdb.xml'">
    < xsl :param name="collect.xref.targets" select="'yes'">
    < xsl :param name="current.docid" select="'testbook'">
    < xsl :param name="prefer.internal.olink" select="1">
    < xsl :param name="insert.olink.pdf.frag" select="1">



  2. Make an olinkdb.xml file (the targets.db will be autogenerated) like below
    < ?xml version="1.0"?>
    < !DOCTYPE targetset SYSTEM "file:/C:/docbook-xsl-1.69.0/common/targetdatabase.dtd" [
    < !ENTITY book-targets SYSTEM "file:/C:/documents/targets.db">
    ]>
    < targetset>
    < targetsetinfo> Description of this target database document,
    which is for the examples in olink doc. < /targetsetinfo>

    < document targetdoc="testbook">&book-targets;< /document>
    < /targetset>




  3. Put my olinks in with only the targetptr set to the linkend name of someplace in one of the documents (without any targetdoc). These olinks could either be with preset text or empty (and becoming autofilled later.) NOTE - the auto filling seemed to have some problems if the linkends were placed on a title. All should be fine if linkends stay on sections and chapters.



  4. compile my pdf from the main book.xml.



Sorry if some of the above texts did not come out right. I'll try to clean them up again later. As I said, ugh.
0 Comments