0

我在 Servlet 中使用动态报告生成 PDF 并使用代码将其输出到 jsp 页面

report.toPdf(response.getOutputStream());

在 Jquery 中,我将 pdf 作为弹出窗口加载到新窗口中

var newWindow = window.open(url, 'name', 'height=800,width=1000');
            if (window.focus) {
                newWindow.focus();
                setTimeout(function() {
                    newWindow.print();
                }, 2000);
            }

但这会返回一个错误

错误:访问属性“打印”的权限被拒绝

火狐版本是 43.0 。我尝试在 about:config 中将 'pdfjs.disabled' 更改为 'true',但这没有帮助:当设置并尝试打印时,窗口会立即自动关闭并且 pdf 会自动保存并且控制台显示错误:

“NS_ERROR_NOT_AVAILABLE:”

.

更新的问题

我刚刚意识到问题不只是打印,我尝试从页面中检索 HTML 内容。

setTimeout(function() {
                $(newwindow.document).ready(function() {
                    $(newwindow.document).find("body").on("load", alert($(newwindow.document).find("body").html()));
                });
            }, 2000);

返回一个错误,

错误:访问属性“文档”的权限被拒绝

现在,如果我在上述两个代码中删除 setTimeout() 函数,第一个将打印空白页,第二个警报为空白。即,我猜到那时内容还没有加载。

4

0 回答 0