"basic-link" with "internal-destination" Attribute

This section provides a tutorial example on how to use 'basic-link' formatting objects with the 'internal-destination' attribute to create a hyperlink to refer to a location inside the XSL-FO formatted output itself.

If you want to use "basic-link" to create a hyperlink to refer to a location inside the XSL-FO formatted output itself, you need to use the internal-destination="..." attribute to specify an identification string associated with a formatting object in the XSL-FO document.

Here is how to associate an identification string to a formatting object and create a hyperlink to refer to the location of that formatting object as illustrated below:

<fo:basic-link internal-destination="id_1" ...>
...hyperlink...
</fo:basic-link>
...
<fo:block id="id_1" ...>
...referenced block...
</fo:block>

To help understanding how to use "internal-destination" attribute, I wrote this XSL-FO example, basic-link-internal-destination.fo:

<?xml version="1.0" encoding="utf-8"?>
<!-- basic-link-internal-destination.fo
 - Copyright (c) 2016, HerongYang.com, All Rights Reserved.
-->
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
 <fo:layout-master-set>
  <fo:simple-page-master master-name="page" 
   margin="0.08in" page-height="3.3in" page-width="2.55in">
   <fo:region-body region-name="body" background-color="#eeeeee"/>
  </fo:simple-page-master>
 </fo:layout-master-set>
 <fo:page-sequence master-reference="page">
  <fo:flow flow-name="body">
   <fo:block margin="0.08in" font-size="10pt" font-weight="bold">
Winnie the Pooh
   </fo:block>
   <fo:block margin="0.08in" font-size="6pt">
By <fo:basic-link color="#0000ff" internal-destination="A_A_Milne">
A. A. Milne</fo:basic-link>
   </fo:block>
   <fo:block margin="0.08in" font-size="6pt" font-weight="bold"
    text-align="center">
Chapter One
   </fo:block>
   <fo:block margin="0.08in" font-size="6pt" text-align="justify">
Here is Edward Bear, coming downstairs now, bump,
bump, bump, on the back of his head, behind
Christopher Robin.  It is, as far as he knows, the only
way of coming downstairs, but sometimes he feels that
there really is another way, if only he could stop bumping
for a moment and think of it.  And then he feels that
perhaps there isn’t.  Anyhow, here he is at the bottom,
and ready to be introduced to you.  Winnie-the-Pooh.
   </fo:block>
   <fo:block margin="0.08in" font-size="6pt" text-align="justify">
When I first heard his name, I said, just as you are
going to say, ‘But I thought he was a boy?’
   </fo:block>
   <fo:block margin="0.08in" font-size="6pt" text-align="justify">
‘So did I,’ said Christopher Robin.
   </fo:block>
   <fo:block margin="0.08in" font-size="6pt" text-align="justify">
‘Then you can’t call him Winnie?’
   </fo:block>
   <fo:block margin="0.08in" font-size="6pt" text-align="justify">
‘I don’t.’
   </fo:block>
   <fo:block margin="0.08in" font-size="6pt" text-align="justify">
‘But you said –’
   </fo:block>
   <fo:block margin="0.08in" font-size="6pt" text-align="justify">
‘He’s Winnie-ther-Pooh. Don’t you know what “ther” means?’
   </fo:block>
   <fo:block margin="0.08in" font-size="6pt" text-align="justify">
‘Ah, yes, now I do,’ I said quickly; and I hope you do
too, because it is all the explanation you are going to get.
   </fo:block>
   <fo:block margin="0.08in" font-size="6pt" font-weight="bold"
    break-before="page" text-align="center">
References
   </fo:block>
   <fo:block id="A_A_Milne" margin="0.08in" font-size="6pt" 
    text-align="justify">
A. A. Milne - Alan Alexander "A. A." Milne (January 18, 1882 – 
January 31, 1956) was an English author, 
best known for his books about the teddy bear Winnie-the-Pooh and 
for various poems.
   </fo:block>
   </fo:flow>
 </fo:page-sequence>
</fo:root>

If you process this example XSL-FO document with Apache FOP to a PDF file and open it with Adobe Acrobat Reader, you will see that "A. A. Milne" is formatted as hyperlink. You can click on it to jump to the referenced location of the PDF file:

"basic-link" with "internal-destination"

Last update: 2016.

Table of Contents

 About This XSL-FO Tutorial Book

 Introduction of XSL-FO

 Apache™ FOP (Formatting Objects Processor)

 RenderX XEP as an XSL-FO Tool

 Introduction of Area Model

 XSL-FO Document Basics and Examples

 Page Layout Masters

 Block-Level Formatting Objects

 Inline-Level Formatting Objects

 Including Graphics in XSL-FO document

 Table of Rows and Columns

 List, Item, Label, and Body

 Floating Blocks - "float" and "footnote"

Hyperlinks, Table of Contents and Indexes

 What Is "basic-link" Formatting Object?

"basic-link" with "internal-destination" Attribute

 Clickable Table of Content

 Building Back-of-Book Indexes

 Headers and Footers using "static-content"

 Font Attributes and Font Families

 Apache FOP Font Configurations

 RenderX XEP Font Configurations

 References

 PDF Printing Version