Free Support Forum - aspose.com

Check hyperlink in a pdf link to another pdf cannot be made with javascript code?

check hyperlink in a pdf link to another pdf cannot be made with javascript code?

@kranthireddyr,

Aspose.PDF for .NET API has support of linking a PDF in another PDF document. You can use remote linking action of LinkAnnotation instance. Please refer to this help topic: Create PDF Document Link in a PDF File

Furthermore, Aspose.PDF for .NET API has support of adding Javascript. You can use JavascriptAction instance, please refer to this help topic: Adding JavaScript (DOM)

@kranthireddyr

Adding more to above reply, you may use following code snippet to open another PDF document using JavaScript action. In below code we have added a button field around specified text and added JavaScript action to it.

Document doc = new Document(dataDir + "sample.pdf");
TextFragmentAbsorber absorber = new TextFragmentAbsorber("TEST");
doc.Pages[1].Accept(absorber);
Page page = doc.Pages[1];
// Add button
Field field = new ButtonField(page, absorber.TextFragments[1].Rectangle);
doc.Form.Add(field);
// Set ButtonField actions
string fieldName = field.PartialName;
string opendocscript = "app.openDoc(\"/D/TestDocument2.pdf\");";
field.Actions.OnPressMouseBtn = new JavascriptAction(opendocscript);
// Save document
doc.Save(dataDir + "OpenPDFFile.pdf");

In case of any further assistance, please feel free to let us know.