2012-05-05 35 views
1

我的網站的訪問者可以點擊「打印預覽」按鈕。 Javascript代碼打開一個窗口,使用document.writelin()將創建一個顯示動態內容的HTML頁面(基本上,用戶在看一個報告,這裏的代碼片斷向你展示我的意思:Can ABCpdf可以從使用Javascript創建的頁面創建PDF嗎?

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。

回答

4

我認爲你應該可以。有一些在C#中的設置將有所幫助。

您需要設置

doc.HtmlOptions.UseScript = true; 

這將啓用JavaScript運行。

它可能是值得設置超時時間,給它更多的時間來完成加載

doc.HtmlOptions.Timeout = 10000; 

和我一直與Gecko渲染引擎

doc.HtmlOptions.Engine = EngineType.Gecko; 
更好的效果