FOP XSL-FO Anchor in an external destination

12,556

For FOP we have two of link: Internal and External.

For External you may use:

   <fo:basic-link 
    external-destination="url('http://www.paulmccartney.com')" 
    color="blue" text-decoration="underline">
     Paul McCartney
   </fo:basic-link>

and Internal links are links from one location in a document to another location in the same document. There are two steps to creating internal links:

First, Give a unique ID to the location being linked to. IDs are specified with the id attribute. The value can be hard coded or generated. In the example below, we use the generate-id() XSLT function to generate IDs:

<fo:block font-weight="bold" font-size="larger" 
 id="{generate-id(.)}" break-before="page">
  <xsl:value-of select="."/>
 </fo:block>

Second, Create the link to that location. As with external links, internal links are created with the tag. The internal-destination attribute should be set to the value of an ID elsewhere in the document.

<fo:basic-link internal-destination="{generate-id(.)}">
 <xsl:value-of select="."/>
</fo:basic-link>

I think you missed to include 'url' keyword in 'external-destination' attribute

Share:
12,556
Johann
Author by

Johann

Updated on July 19, 2022

Comments

  • Johann
    Johann almost 2 years

    With XSL-FO (Fop), I succeeded in creating a link to an external PDF :

    <fo:basic-link show-destination="new">
    <xsl:attribute name="external-destination">foo.pdf</xsl:attribute>
    </fo:basic-link>
    

    But now, I would like to reach an anchor in this external PDF. So I tried to build something like that :

    <fo:basic-link show-destination="new">
    <xsl:attribute name="external-destination">foo.pdf#anchorId</xsl:attribute>
    </fo:basic-link>
    

    Unfortunately, when I click on the generated link, I get an error. It tries to open the document foo.pdf%23anchorId.

    In my .fo file, the link is correct with a # but this # is misinterpreted during the transformation in PDF.

    Do you have an idea to solve this issue ?

    Thanks,

    Johann

  • Johann
    Johann about 11 years
    Thanks for your response Navin. It seems I can't create an hybrid link (both external and internal). Besides, I think I don't need to include 'url' in my attribute because I want to create a link towards a PDF file located in the same folder.