在primefaces documentViewer中禁用下载/打印按钮

在primefaces documentViewer中禁用下载/打印按钮,primefaces,pdf.js,primefaces-extensions,Primefaces,Pdf.js,Primefaces Extensions,我想禁用documentViewer工具栏中的下载和打印按钮 我试着用JavaScript和CSS来实现它,如下所示,但都不起作用 有什么建议吗 我试着这样做: $(function() { $('#download').hide(); }); 在CSS中,如下所示: .download { display:none !important; } .print { display:none !important; } 我的XHTML实现 <h:form

我想禁用documentViewer工具栏中的下载和打印按钮 我试着用JavaScript和CSS来实现它,如下所示,但都不起作用

有什么建议吗

我试着这样做:

$(function() {
    $('#download').hide();
});
在CSS中,如下所示:

.download {
    display:none !important;    
}

.print {
    display:none !important;
}
我的XHTML实现

<h:form id="ReportViewerForm">  
        <f:event listener="#{ReportController.printReportSchedule}" type="preRenderView" />
             <p:panel id="ReportViewerPanel" header="" style="margin-bottom:10px;">
                    <pe:documentViewer height="500" value="#{ReportController.content}"/> 
            </p:panel>   
</h:form>

在PrimeFaces 6.0中适用于我,请注意,而不是。没有这个!重要信息:顺便说一句,DocumentViewer不能通过添加和强制使用css或javascript进行修改。 DocumentViewer在不允许插入css和javascript的JFrame中运行。 最理想的解决方案和最适合我的解决方案如下:

使用zip解压缩primefaces-primefaces-extensions-6.0.0.jar的jar文件 编辑文件\META-INF\resources\primefaces extensions\documentviewer\viewer.html并添加style=display:none

打印

下载

使用扩展jar primefaces-extensions-6.0.0.jar保存并重新压缩它

替换jar文件并部署
您可以使用autoRun=true的remoteCommand强制CSS配置。从oncomplete调用javascript。这很有效。

pdfview位于iFrame中。因此,您必须直接将css更改应用于它

<pe:documentViewer url="#{pdfcontroller.pdfPath}" id="pdfVw" />
然后我使用javasript在ready上运行

<script>
$(document).ready(function() {
    $('#pdfVw').contents().find('#download').css('display', 'none');
    $('#pdfVw').contents().find('#print').css('display', 'none');
});
</script>

我在primefaces论坛上找到了一个基于Javascript的答案,它对我很有用 这是链接

将此方法添加到应用程序javascript文件中

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);
        });}
在使用PDF Viewer的页面上,可以隐藏OpenFile和书签按钮


您是否尝试过在组件本身中使用渲染属性?据我所知,它没有渲染属性。能否显示您正在使用的组件的实际代码?好,我在代码中的questionSeeking中添加了我的xhtml实现:有一个可以用来隐藏它的对象:查看设置对象的第20502行,然后查看第20584行。你可以利用这些物品。试试看。
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);
        });}
<script type="text/javascript">
      $(document).ready(function() {
              pdfHideButton('download');
                pdfHideButton('viewBookmark');
          });
      </script>