ABCpdf 可以从用 Javascript 创建的页面创建 PDF 吗? [英] Can ABCpdf create a PDF from a page created with Javascript?

查看:17
本文介绍了ABCpdf 可以从用 Javascript 创建的页面创建 PDF 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我网站的访问者可以点击打印预览"按钮.Javascript 代码打开一个窗口并使用 document.writelin() 将创建一个显示动态内容的 html 页面(基本上,用户正在查看报告.以下代码片段向您展示了我的意思:

A visitor to my website can click on a "Print Preview" button. Javascript code opens a Window and using document.writelin() will create a html page that displays dynamic content (basically, the user is looking at a report. Here's code snippet to show you what I mean:

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.

I would like to include a "Download PDF" link on this page so visitor can save report to a PDF.

这可以用 ABCpdf 8.1 实现吗?(我正在评估它.)我遇到的问题是弄清楚哪个示例与我需要做的最接近.有什么建议?TIA.

Is this possible with ABCpdf 8.1? (I'm evaluating it.) The problem I'm having is figuring out what example is the closest one to what I need to do. Any suggestions? TIA.

推荐答案

我认为你应该可以.c#中有一些设置会有所帮助.

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

您需要设置

doc.HtmlOptions.UseScript = true; 

这将使 javascript 能够运行.

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;

我一直使用 Gecko 渲染引擎获得更好的结果

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

doc.HtmlOptions.Engine = EngineType.Gecko;

这篇关于ABCpdf 可以从用 Javascript 创建的页面创建 PDF 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆