Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ABCPdf add document javascript

Is it possible to add document JavaScripts to a generated PDF using ABCPdf?

like image 402
andr111 Avatar asked Mar 19 '12 18:03

andr111


2 Answers

If you mean, Javascript that is being executed after the document has been loaded, then have a look at this documentation page.

doc.HtmlOptions.UseScript = true;
doc.HtmlOptions.GeckoSubset.OnLoadScript =
@"(function() {
   window.ABCpdf_go = false;

   // your javascript code here

   window.ABCpdf_go = true;
})();";
like image 56
devio Avatar answered Oct 25 '22 23:10

devio


I think you should be able to. There are some settings in the c# which will help.

You need to set the

doc.HtmlOptions.UseScript = true; 

this will enable javascript to run.

it's probably worth setting the timeout to give it more time to finish loading

doc.HtmlOptions.Timeout = 10000;

and i've always had better results with the gecko rendering engine

doc.HtmlOptions.Engine = EngineType.Gecko;
like image 42
tentonipete Avatar answered Oct 26 '22 00:10

tentonipete