function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ApoorvApoorv 

Rendering javascript widget in pdf using renderAs pdf

I want to display a widget which is initialized by calling a javascript function in a pdf using renderAs pdf attribute, when I remove the renderAs pdf, it works perfectly. It is compulsory to use that widget and cant be replaced, hence javascript is also compulsory. I looked for a number of options but nothing helped. Please help me out, thanks in advance.
bob_buzzardbob_buzzard

You can't invoke javascript from PDF, as PDF doesn't have a javascript engine that will execute the code and allow the content to be updated.  PDF has its own markup language and you can only use that.

 

The way that I've handled this in the past is to render the page as HTML and use google chrome's print to PDF functionality.

ApoorvApoorv
Hi bob_buzzard, thanks for the rply. Can you please tell about the google chrome's functionality you have used, and also i would like to know that will it work on other browsers as well? Thanks again
bob_buzzardbob_buzzard

Its the way that chrome handles printing - if you press CTRL+P, the print dialog opens and you can change the destination to 'Save as PDF'.  It won't work in other browsers as its part of google chrome.  Other browsers may have this functionality.