1. 概述
1.1 版本
報表伺服器版本 |
---|
11.0 |
1.2 問題描述
使用者在遇到 FineReport 報表嵌入 iframe 中的場景時,如果需要列印報表內容,可以自訂列印按鈕並將其放置在報表外部。
1.3 實現思路
如果報表嵌入在 ID 為 reportFrame 的 iframe 中,直接透過 JS 程式碼呼叫 FineReport 內建工具欄中的方法即可。
JS 程式碼格式如下:
document.getElementById('reportFrame').contentWindow.contentPane.pdfPrint();
2. 範例
2.1 範本準備
本文範例將範本%FR_HOME%\webapps\webroot\WEB-INF\reportlets\GettingStarted.cpt嵌入 iframe 中。
2.2 建立 HTML 檔案
1)建立print.html,內容如下:
點選下載並解壓獲得 HTML 檔案:print.zip
2)將print.html放置到 %FR_HOME%\webapps\webroot\help\page_demo 路徑下,如下圖所示:
2.3 效果預覽
啟動設計器,在瀏覽器端輸入http://localhost:8075/webroot/help/page_demo/print.html,效果如下圖所示: