Include and invoke javascript functions

Hi,

How can we invoke user defined javascript functions in the code. Can you provide a sample javascript file which reads all the hyperlinks in the PDF document.

Thanks

Mamatha

Hi Mamatha,


Sorry for replying you late.

Do you need the code to read all hyperlinks in a PDF file or you need to call existing JavaScript method in a PDF file using Aspose.Pdf for .NET ? Please share the details so we may reply accordingly.

I am on Java environment. Actually I tried to add javascript to pdf in the following way.

String str = "var numLinks=0;var myBorderWidth=1;var myBorderColor=color.black;";
str+= "for ( var p = 0; p < this.numPages; p++) "+
"{"+
"var b = this.getPageBox(\"Crop\", p); "+
"var l = this.getLinks(p, b); "+
"for (var i=0; i < l.length; i++) "+
"{"+
" l[i].borderColor = color.blue;"+
"}"+
"}";

pdf.getJavaScripts().add(str);

Is there any other way of invoking javascripts.

Thanks

Mamatha

Hi Mamatha,

Please follow the instructions specified over following link for Adding Javascript actions to a PDF file