1. Home
  2. Foxit Quick PDF Library
  3. Add links to a PDF programmatically

Add links to a PDF programmatically

Adding links to PDF files is very straight forward. A link in a PDF is actually an annotation and is placed on top of the content that you wish to link. These hotspot links can be added using the following functions:

Read more about annotations and hotspot links.

An example of how to use the AddLinkTo* functions is shown below.

/* Add a link to a specific page in an external PDF */
 
// Set the origin for the co-ordinates to be the
// top left corner of the page.
 
DPL.SetOrigin(1);
 
// Adding a link to a page in an external PDF
// is easy using the AddLinkToFile function.
 
DPL.AddLinkToFile(200, 100, 60, 20, "Moby_Dick_NT.pdf", 22, 200, 1, 1);
 
// Hyperlinks and text are two separate
// elements in a PDF, so we'll draw some
// text now so that you know where the
// hyperlink is located on the page.
 
DPL.DrawText(205, 114, "Click me!");
 
// When the Foxit Quick PDF Library object is initiated a blank document
// is created and selected in memory by default. So
// all we need to do now is save the document to
// the local hard disk to see the changes that we've made.
 
DPL.SaveToFile("link_to_another_doc.pdf");
Updated on April 9, 2017

Was this article helpful?

Related Articles

Ready to try Foxit PDF SDK?
Click the link below to download your trial
Free Trial