Background Color:
 
Background Pattern:
Reset
Search
Home Recent Changes Show All Pages

Link

Not Rated Yet

The link component supports navigation within the current document, to other documents and resources, and also to specific sections within documents.

Article Contents

A Quick Link

Whenever you want to navigate to other content either in the current document, or to content external to the document, then you use a link.

<pdf:Link file="http://www.scryber.co.uk" action="Uri" >
    A link to scryber. <pdf:Image src="../../images/scryberlogo.jpg" style:height="16pt" style:position-mode="Inline" />
</pdf:Link>

 

 

The text is blue because we have explicitly declared a style within our document for a fill colour of blue for all links. Without this the text colour would be inherited from the outer style.

<style:Style applied-type="pdf:Link" >
    <style:Fill color="blue" />
</style:Style>

The link itself is an invisible container component. It does not alter the flow or layout of any text or content. It is up to the inner components how they are laid out, and the link will pick these up and mark the rendered position a link area within the document.

This is some text that should flow over to the next line and the active region should follow
that <pdf:Link file="http://www.scryber.co.uk" >links onto the next line, and will then continue for the full length of a line and overflow
onto the next lines of text (more than one), <pdf:Span style:font-italic="true" style:fill-color="gray" >including new components with new styles and also images
<pdf:Image src="../images/scryberlogo.jpg" style:height="16pt" style:position-mode="Inline" />, so everything within the link being an 
active, clickable part of that parent link </pdf:Span>using the same action annotation</pdf:Link>. So this is following on.

Linking between pages

PDF readers support the concept of relative page linking, and it is easy include these links in a Scryber PDF document. Pages can be linked as going to the First, Previous, Next and Last pages. These links are relative to the page the user is currently viewing (not the page the link is on) which can be confusing.

E.g. If the end user is viewing as continuous pages #4, and the links for next and previous pages are just visible on the next page below (#5) in the window, then clicking on the Next page link will take the user to page #5 and previous will take the user to #3. This is an idiosyncrasy of the reader, rather than an issue with the PDF itself.

<pdf:Link action="FirstPage" >
        <pdf:Label text="Go to First Page" />
</pdf:Link>  | <pdf:Link action="PrevPage" >
        <pdf:Label text="Go to Previous Page" />
</pdf:Link> | <pdf:Link action="NextPage" >
        <pdf:Label text="Go to Next Page" />
</pdf:Link> | <pdf:Link action="LastPage" >
        <pdf:Label text="Go to Last Page" />
</pdf:Link>

 

Linking to other components

A more refined and finer grained method of linking to other content in the document is to do it by name or ID.

When creating a link that will go to a specific component we have fit options that allow the changing of the display scaling / page fit once the link has been clicked.

<pdf:Section id="NavigationLinks" visible="true" >
      <Content>
        First page<pdf:Br/>
        <pdf:Div name="MyBox" style:margins="10pt" style:width="200pt" 
                        style:height="200pt" style:bg-color="gray" style:v-align="Middle" style:h-align="Center" >
          <pdf:Label >This is the box with ID = MyBox</pdf:Label>
        </pdf:Div>
        <pdf:PageBreak/>
        .
        .
         <!-- any amount of content , new pages or page breaks -->
        . 
        .
        .

        <pdf:Link destination="MyBox" destination-fit="FullPage" >Go to component with Name =  MyBox - Full Page</pdf:Link>
        <pdf:Br/>
        <pdf:Link destination="MyBox" destination-fit="PageWidth" >Go to component with Name =  MyBox - Page Width</pdf:Link>
        <pdf:Br/>
        <pdf:Link destination="MyBox" destination-fit="PageHeight" >Go to component with Name = MyBox - Page Height</pdf:Link>
        <pdf:Br/>
        <pdf:Link destination="MyBox" destination-fit="BoundingBox" >Go to component with Name = MyBox - Bounding Box</pdf:Link>

 

 

When the user clicks on any of the links, then they will be taken to the best view of the MyBox component as specified by the destination-fit. The window size will not be altered, but the zoom of the display will change to accommodate

 

 

If a component overflows onto more than one page or column, then only the first bounding rectangle will be used. It is an error in the document to have more than one component with the same name

Linking by ID

Rather than using the name option for specifying a link, it is possible to to use the ID of the component by preceding the string with a hash '#'.

<pdf:Section id="NavigationLinks" visible="true" >
      <Content>
        First page<pdf:Br/>
        <pdf:Div id="MyBox" style:margins="10pt" style:width="200pt" 
                        style:height="200pt" style:bg-color="gray" style:v-align="Middle" style:h-align="Center" >
          <pdf:Label >This is the box with ID = MyBox</pdf:Label>
        </pdf:Div>
        <pdf:PageBreak/>
        .
        .
         <!-- any amount of content , new pages or page breaks -->
        . 
        .
        .

        <pdf:Link destination="#MyBox" destination-fit="FullPage" >Go to component with Name =  MyBox - Full Page</pdf:Link>
        <pdf:Br/>

Unlike names ID do not have to be unique within a document, so the first returned component with an ID matching the required name will be used as the reference component. If the item cannot be found then the contents of the link will still be rendered, but there will be no action specified on their content

As of version 0.8.8.5, it is not necessary to specify the action attribute of a link, as it will be derived from the specified file and destination, but best practice would dictate that the action should be added if there is any cause for doubt

 

Linking to other documents

As we can see from the very first example in this article, it is possible to simply specify a file to open from a link. These can either be web locations of pdf documents.

<pdf:Link file="http://www.scryber.co.uk" action="Uri" >A link to scryber.</pdf:Link>

By specifying the action of URI, then a browser window will be opened an navigate to the requested page or location, although this can be to another pdf (or pdfx file)

By their very nature, pdfs are files and therefore can be copied, moved and shared. So at the moment all URI actions must be absolute URI's not relative - including the full path
<pdf:Link file="http://www.scryber.co.uk/pdfs/document2.pdfx" action="Uri" >A link to document2.pdfx in the scryber site.</pdf:Link>

When you want to link to another local PDF file - e.g. when the PDFs are all stored or generated on the local file system - then you can specify the action of ExternalDestination

<pdf:Link file="document2.pdf" action="ExternalDestination" destination="secondpage" new-window="true" >A link to the page with name 'second page' in Document2.pdf.</pdf:Link>

The optional destination attribute will be honoured and the reader should navigate the component with that name. It is not possible to specify an ID (prefix #) because these are not known by the reader

 

Link Styles

Links are invisible components. They do not affect the flow, or alter the block level styles of inner components. To have links with backgrounds and borders, they can contain (or be contained) by panel components.

      A link with full styles
        <pdf:Div style:margins="10pt" style:padding="5pt" style:bg-color="#DDDDDD" style:border-color="#BBBBBB">
          <pdf:Link action="FirstPage" >
            <pdf:Div style:bg-color="#333333" style:full-width="false" style:padding="4pt" >
              <pdf:Label style:fill-color="#DDDDDD" text="First Page" style:font-bold="true" />
            </pdf:Div>
          </pdf:Link>
       </pdf:Div>

 

See Also



  Rating
Rate This Page: Poor Great   |  Rate Content |
Average rating:  No Ratings Yet   
Number of Ratings : 0
  Comments
Add Comment
No Comments Yet