XSL-FO Tutorials - Herong's Tutorial Examples - v2.25, by Herong Yang
What Is "basic-link" Formatting Object?
This section describes the 'basic-link' formatting object, which is an inline-level formatting object that makes the content as a hyperlink pointing to the specified internal or external location of the referenced resource.
What Is "basic-link" Formatting Object? "basic-link" is an inline-level formatting object that makes the content as a hyperlink pointing to the specified internal or external location of the referenced resource.
Note that hyperlinks are only supported in formatted output on interactive target devices, link a PDF document viewer. If the formatted output is printed on paper, hyperlinks are useless.
"basic-link" formatting objects can take a mixed of text, inline-level and block-level formatting objects as content, which will be formatted as "clickable" to allow the user to access the referenced resource.
"basic-link" formatting objects can be use to create hyperlinks for two types of references:
Here is my tutorial example, basic-link-external-destination.fo, that has a "float" formatting object floating to the "start" edge of the page:
<?xml version="1.0" encoding="utf-8"?> <!-- basic-link-external-destination.fo - Copyright (c) 2006 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" external-destination="https://en.wikiquote.org/wiki/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: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 open the referenced web page in a browser:
Table of Contents
Apache™ FOP (Formatting Objects Processor)
XSL-FO Document Basics and Examples
Block-Level Formatting Objects
Inline-Level Formatting Objects
Including Graphics in XSL-FO document
Floating Blocks - "float" and "footnote"
►Hyperlinks, Table of Contents and Indexes
►What Is "basic-link" Formatting Object?
"basic-link" with "internal-destination" Attribute
Headers and Footers using "static-content"
Font Attributes and Font Families
Apache FOP Font Configurations