Foxit PDF SDK for Android

How can I add a link annotation to a PDF file?

To add a link annotation to a PDF file, you should first call the PDFPage.addAnnot to add an annotation to a specified page, then call Action.Create to create an action, and set the action to the added link annotation. Following is the sample code for adding a URI link annotation to the first page of a PDF file:

private Link linkAnnot = null;
String path = "mnt/sdcard/input_files/sample.pdf";
try {
// Initialize a PDFDoc object with the path to the PDF file.
PDFDoc document = new PDFDoc(path);

// Load the unencrypted document content.

// Get the first page of the PDF file.
PDFPage page = document.getPage(0);

// Add a link annotation to the first page.
linkAnnot = (Link) page.addAnnot(Annot.e_Link, new RectF(250, 750, 500, 650));

// Create a URI action and set the URI.
URIAction uriAction = (URIAction) Action.create(document, Action.e_TypeURI);

// Set the action to link annotation.

// Reset appearance stream.

// Save the document that has added the link annotation.
document.saveAs("mnt/sdcard/input_files/sample_annot.pdf", PDFDoc.e_SaveFlagNormal);

} catch (Exception e) {


Updated on August 28, 2018

Was this article helpful?
Thanks for your feedback. If you have a comment on how to improve the article, you can write it here: