Example: The following example will place a label on the PDF then create a link at that location that links to a webpage.
import com.cete.dynamicpdf.*;
import com.cete.dynamicpdf.pageelements.*;
public class MyClass{
public static void main(String args[]){
// Create a PDF Document
Document document = new Document();
// Create a Page and add it to the document
Page page = new Page();
document.getPages().add(page);
String text = "This is a link to mydomain.com";
Font font = Font.getHelvetica();
// Create the link's label
Label label = new Label(text, 50, 50, 400, 20, font, 18,
RgbColor.getBlue());
label.setUnderline(true);
// Set the action then create the link
UrlAction action = new UrlAction("http://www.mydomain.com");
Link link = new Link(50, 50, font.getTextWidth(text, 18), 20, action);
// Add the label and the link to the page
page.getElements().add(label);
page.getElements().add(link);
// Save the PDF
document.draw("[Physicalpath]/MyDocument.pdf");
}
}