Skip to content

How to hide the URL for a link in the PDF output

Dan Allen edited this page Jun 19, 2013 · 1 revision

Assume you have the following AsciiDoc markup:

http://example.org[Example]

When you generate a PDF from this document using a2x with the Apache FOP generator, the link is appears as:

Example [http://example.org]

This almost looks the same as the original AsciiDoc source. The PDF generator (specifically the DocBook XSL for Apache FOP) is not rendering the link the way you would expect it to appear. It puts the URL in square brackets after the linked text.

Hiding the URL

There is a way to customize how a link appears in the PDF document. One way is to disable the URL from showing using the ulink.show parameter:

a2x -f pdf --fop --xsltproc-opts="-param ulink.show 0" sample.adoc

Now you should see that the word "Example" is a link, but the URL only displays on hover in a tooltip.

If you want the text to be another color (such as blue), you can add the following XML markup to docbook-xsl/fo.xsl (one of the files in the AsciiDoc distribution):

<xsl:attribute-set name="xref.properties">
 <xsl:attribute name="color">#0000FF</xsl:attribute>
</xsl:attribute-set>

I know this is really a pain to customize. I can’t understand how else to learn how to customize the DocBook toolchain other than fishing through the XSL. On a link box, it’s usually under /usr/share/sgml/docbook/xsl-stylesheets.