Table of Contents show
Hyperlinks in PDF documents allow you to specify websites or external resources that users can visit for more information. (Though they can also be a source of phishing!)
Our Java PDF toolkit JPedal contains a powerful PDF manipulation API which you can use to add links to PDF files
final PdfManipulator pdf = new PdfManipulator();
pdf.loadDocument(new File("inputFile.pdf"));
final Annotation[] annotations = new Annotation[2];
// Hyperlink annotation with blue color.
annotations[0] = new Link(new float[] {200, 600, 300, 700}, new float[] {0.0f, 0.0f, 1.0f}, "https://idrsolutions.com/");
// Hyperlink annotation with red color.
annotations[1] = new Link(new float[] {200, 300, 300, 400}, new float[] {1.0f, 0.0f, 0.0f}, "https://support.idrsolutions.com/");
pdf.addAnnotation(1, annotations);
pdf.apply();
pdf.writeDocument(new File("outputFile.pdf"));
pdf.closeDocument();
Download JPedal
You can get a JPedal trial jar to test adding links to PDF files.
Resources
Learn more about the PDF Manipulator API.
We can help you better understand the PDF format as developers who have been working with the format for more than 2 decades!