可以ABCpdf创建的JavaScript创建了一个页面一个PDF?(Can ABCpdf crea

2019-10-16 16:40发布

访问者到我的网站可以点击“打印预览”按钮。 Javascript代码打开一个窗口,使用document.writelin()将创建一个显示动态内容的HTML页面(基本上,用户在看一个报告,这里的代码片断向你展示我的意思:

printerWindow = window.open("");  
printerWindow.document.writeln("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0   Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>");  
printerWindow.document.writeln("<html>");  
printerWindow.document.writeln("<head>");  
printerWindow.document.writeln("<title>Report Title</title>");  
printerWindow.document.writeln("<link href='./css/schedule_print_preview.css'  type='text/css' rel='stylesheet'>");  
printerWindow.document.writeln("<link href='./css/schedule_printer.css' rel='stylesheet' type='text/css' media='print'>");  
printerWindow.document.writeln("<script type='text/javascript'>");  
printerWindow.document.writeln("function printcalc() {");  
printerWindow.document.writeln("window.print();");  
printerWindow.document.writeln("};");  
printerWindow.document.writeln("<\/script>");  
printerWindow.document.writeln("</head>");  
printerWindow.document.writeln("<body>");  
printerWindow.document.writeln("<div class='btns'>");  

{...}

我想包括此页面上的“下载PDF”链接,以便访问者可以保存为PDF格式的报告。

这可能与ABCpdf 8.1吗? (我评价它。)我遇到的问题是搞清楚什么例子是最接近的一个什么,我需要做的。 有什么建议么? TIA。

Answer 1:

我想你应该可以。 有在C#中,这将有助于一些设置。

您需要设置

doc.HtmlOptions.UseScript = true; 

这将启用JavaScript运行。

它可能是值得设置超时时间,给它更多的时间来完成加载

doc.HtmlOptions.Timeout = 10000;

我一直有与Gecko渲染引擎更好的结果

doc.HtmlOptions.Engine = EngineType.Gecko;


文章来源: Can ABCpdf create a PDF from a page created with Javascript?