ceTe Dynamic PDF DocumentJavaScript

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Generator for .NET (v4)  /  ceTe Dynamic PDF DocumentJavaScript

DynamicPDF Generator for .NET (v4) Forum

 May 26 2017 5:59 AM
I am creating a PDF within a .NET c# application.
Right now, I have found examples of alerting out text on opening the PDF (after i saver it locally) by using:
 
document.JavaScripts.Add(new DocumentJavaScript("Say Hi", "app.alert(\"Hello!!\")"));


Is there a way, to use the java script to load a URL when the PDF opens?

Thanks,
Posted by a ceTe Software moderator
Hello,

Yes, you can load a URL when a PDF document loads in the PDF viewer/Reader. You will need to add the document level JavaScript to the Document using DynamicPDF API. Below is the code sample.

            Document document = new Document();
            Page page = new Page(PageSize.Letter);
            document.Pages.Add(page);
            document.JavaScripts.Add(new DocumentJavaScript("URL", "app.launchURL(\"http://www.google.com\", true);"));
            document.Draw(@"E:\Temp\test.pdf");

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 7:06 AM.