Now, in Class PdfContentEditor we provide a set of new API which can create a web link or a local link into a Pdf document, just follow the following steps:
Method CreateWebLink takes three arguments:
- rect - The specified Rectangle for active click.
- url String - The specified web destination.
- originalPageint - The original page for creating rectangle.
Method CreateLocalLink takes four arguments:
- outputFile - The output file.
- rect - The specified rectangle for active click.
- desPage- The specified local destination page.
- originalPage - The original page in which the url link is created.
Code Snippet
[C#]
// New a object of Class PdfContentEditor.
PdfContentEditor editor = new PdfContentEditor();
//New a object of Class System.Drawing.Rectangle
System.Drawing.Rectangle rect=New System.Drawing.Rectangle(100,100,20,20);
// Bind target pdf document .
editor.BindPdf(inputPath + "example1.pdf");
//Create Web Link.
editor.createWebLink(rect, "http://www.aspose.com", 2);
// Save the result Pdf Document.
editor.Save(outputPath+ "example1_WLink.pdf");
[VB]
'New a object of Class PdfContentEditor.
Dim editor As PdfContentEditor = New PdfContentEditor()
'Bind target pdf document.
editor.BindPdf(inputPath + "example1.pdf")
'New a object of Class System.Drawing.Rectangle.
Dim rect As System.Drawing.Rectangle=New System.Drawing.Rectangle(100,100,20,20)
'Create Web Link.
editor.createWebLink(rect, "http://www.aspose.com", 2)
'Save the result Pdf Document.
editor.Save(outputPath+ "example1_WLink.pdf")
[Java]
// New a object of Class PdfContentEditor.
PdfContentEditor editor = new PdfContentEditor();
//New a object of Class Rectangle
Rectangle rect=new Rectangle(130,130,150,150);
// Set target pdf document .
String outputFile="test.pdf";
//Create Local Link.
editor.createLocalLink(outputFile,rect,1,2);