Converts external links to internal links wherever possible.

 

   

Syntax
 

XHtmlOptions.LinkPages

 

   

Params
 
Name Type Description
n/a n/a n/a

 

   

Notes
 

This method scans the entire document converting external links to internal links wherever possible.

By default, links in rendered HTML are preserved as is. This means that links in a web page link to external URLs. When you click on them, a browser window will be launched and the original target of the link displayed.

In some situations, you may wish to resolve links within the document so that they take you between pages in the PDF rather than launching an external browser window.

For example, you might add a number of web pages which contain links to each other. Rather than linking to the pages on the original web site, you might like to resolve the links so that they point at at the pages as they now appear in the PDF.

Similarly, if you use named destinations (HTML fragments) with links within the document, you will may wish to use this method to convert them from external links to internal ones.

 

   

Example
 

This example shows how to import an HTML page which uses named destinations.

We first create a Doc object and inset the edges a little so that the HTML will appear in the middle of the page. We assign the appropriate HTML options so that links will be rendered live.

Set theDoc = Server.CreateObject("ABCpdf10.Doc")
theDoc.Rect.Inset 18, 18
theDoc.HtmlOptions.AddLinks = True

We add the pages to the document.

theURL = "http://www.websupergoo.com/support.htm"
theID = theDoc.AddImageUrl(theURL)
Do
  If Not theDoc.Chainable(theID) Then Exit Do
  theDoc.Page = theDoc.AddPage()
  theID = theDoc.AddImageToChain(theID)
Loop

The URL we've referenced makes extensive use of named destinations. We want these named destination links to take us between pages on the PDF rather than taking us to the original URL.

After adding the pages, we can flatten them. We can't do this until after the pages have been added because flattening will invalidate our previous ID and break the chain.

theDoc.HtmlOptions.LinkPages
For i = 1 To theDoc.PageCount
  theDoc.PageNumber = i
  theDoc.Flatten
Next

Finally, we save.

theDoc.Save "c:\mypdfs\linkpages.pdf"

We get the following output. The links work - where possible - within the PDF.


linkpages.pdf [Page 1]

linkpages.pdf [Page 2]