自定义 pe:documentViewer 按钮行为

Customize pe:documentViewer Button Behavior

我的问题是 PrimeFaces Extensions 中的组件 pe:documentViewer 以及您可以在照片中看到的打印元素,我想要的是将打印功能与我的代码绑定,而不是使用默认设置如果有办法定制谢谢告诉我如果没有办法不显示打印图标 谢谢。

有些聪明的 jquery 可能有办法覆盖打印按钮,但这可能相当困难。但是,如果需要,您可以隐藏打印按钮,这是我为此编写的一些代码。

  1. 在您页面的某处加载此 JavaScript 方法。
/**
 * Hides a button on the PDF Viewer toolbar
 */
pdfHideButton : function(button) {
    $('iframe').on('load',
            function() {
                var head = $(this).contents().find('head');
                var css = '<style type="text/css">#' + button   + '{display:none};</style>';
                $(head).append(css);
            });
}
  1. 将此添加到您的 XHTML 页面,该页面将执行此 JavaScript 此与文档就绪功能一起删除按钮。
<script>
$(document).ready(function() {
           pdfHideButton('print');
});
</script>