简体   繁体   中英

How to customize Primefaces documentViewer toolbar?

I am using primefaces documentViewer which is based on mozilla PDF.js: 2.11.338

https://www.primefaces.org/showcase-ext/views/documentViewer.jsf

and I want to customize the viewer to control which buttons to appear in the toolbar like rotate & print & download only.

I couldn't find any guides about that in primefaces website.

There is no JS Widget for Document Viewer however this can be accomplished easily with a JS function like this.

Note: Some buttons like presentationMode are special and need to be hidden a little differently.

pdfHideButtons : function() {
    var pdfViewer = $("#YourDivId");
    if (pdfViewer) {
        $(pdfViewer.contents().find("#openFile")).hide();
        $(pdfViewer.contents().find("#viewBookmark")).hide();
    }
}

Then on your page add this code to basically hide the buttons after the page loads.

<script>
        $(document).ready(function() {
            setTimeout(function(){ pdfHideButtons(); }, 1000);
        });
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM