Forum Bugs

Link to named anchor (A NAME) does not become a PDF bookmark

Andi0661
Hi,
we use Prince-XML on HTML that is generated by an XSLT and that contains many links. Most links become bookmarks in the generated PDF just fine, but there is a certain set of links that never becomes a bookmark. In those cases, the link text is generated correctly in the PDF, but it seems to be normal text, not a bookmark. I also tried the area around the link text, in case the area of the bookmark is generated differs a bit from the area where the link text is shown, but no success.

In the HTML file, using any of a number of browsers (FF, IE, Opera, Safari) these links work just fine.

This problem is entirely repeatable and I verified that it happens with all Prince-XML versions I tried: 8.0, 8.1r5, and 9.0r4.

It turns out that in all cases that don't work, the link targets a named anchor, i.e. an "A" element that has a "NAME" attribute. In those cases that work, the link targets an element (e.g. "H4") with an "ID" attribute.

Because the links can be fairly long (e.g. "#HG-A-EnabledLogicalElement-O-AssociatorNames-A-ElementCapabilities"), I have added support to the (quite extensive) Javascript that is embedded in the HTML to change the links to a shorter hashed value (e.g. "#HASH-0123456789-0"), but that did not solve the problem.

The reason I am using named anchors for some links is that the same target (a heading) needs to be targetable using multiple different names, to keep the complexity of the XSLT manageable.

For now, my questions are:
-> Is linking to named anchors supposed to be supported by Prince-XML?
-> Is there a length limitation for link names in Prince-XML?

I have attached a linkproblem.zip file containing the HTML and PDF that does not work. The files in that archive are:
runprince.bat - command line for invoking Prince
DSP1080_2.0.0a.html - input to Prince, self-contained (with embedded Javascript, CSS, images)
DSP1080_2.0.0a.pdf - output from Prince 9.0r4
DSP1080_2.0.0a.jsdone.html - input, with Javascript expanded by Firefox (using its "Save As...")

Kind regards,
Andy
  1. linkproblem.zip893.3 kB
mikeday
This may be caused by an issue in Prince where some empty inline elements cannot be targeted. Is it possible to link the block element, or a nearby block element, or a span that contains text?
Andi0661
Hello Mike,
Thanks for answering so quickly!

Your hint with the empty inline elements was a good one. I was able to get the links working by adding dummy text into the "a" element of the named anchor, e.g.:
<div style="visibility: hidden; line-height: 0; font-size: 0;">
<a name="HG-A-EnabledLogicalElement-O-ModifyInstance">dummy</a></div>

Either because named anchors are not supposed to contain text, or because of the hidden visibility of the parent "div" element, the dummy text does not show up in the HTML or in the PDF. So this is good enough as a quick solution for me.

An alternative solution of targeting the "id" attribute of a "div" element for those additional targets would also be possible, but more work.

So I'm fine for now.

Nevertheless, I'd appreciate if you could keep this issue on your list of issues and resolve it at some point.

Just for information, here are three cases of HTML targets (all linked with: <a href="#...") that worked fine as PDF bookmarks:
<p>
<a name="Ref_DMTF_DSP1103"></a>DMTF DSP1103, <i>Job Control Profile 1.0</i>,<br>
<a class="UrlRef" href="http://www.dmtf.org/standards/published_documents/DSP1103_1.0.pdf" title="Link to the referenced document, using the displayed URL">http://www.dmtf.org/standards/published_documents/DSP1103_1.0.pdf</a>
</p>

<td class="Table-BodyCell">
<a name="T-F-Capabilities"></a>Capabilities</td>

<div class="Figure" id="F-CD">
<img src="data:image/gif;base64,R0l....ADs=" width="100%">
<p class="Figure-Caption">Adaptation diagram</p>
</div>

and here is the case that did not work:
<div style="visibility: hidden; line-height: 0; font-size: 0;">
<a name="HG-A-EnabledLogicalElement-O-ModifyInstance"></a></div>

and here the modification that makes it works again:
<div style="visibility: hidden; line-height: 0; font-size: 0;">
<a name="HG-A-EnabledLogicalElement-O-ModifyInstance">dummy</a></div>

Again, thanks for your help!

Andy