Search code examples
javascriptajaxpdfwebpdf.js

Customizing pdf.js


i would like to use pdf.js in my webApplication and customize it's view, so i can embedd it into the rest of my application (i was thinking about using an iframe).

At first i would like to get rid of most of the default toolbar-buttons like "print" or "download file" but keep the zoom and page navigation. Instead, i want these features (print/download) to appear inside my application's toolbar. How to do that? How can i hide the print/download buttons from the pdf.js toolbar and call this features with my custom buttons which are rendered inside my webapplication already?

Or should i use another library other than pdf.js?

Any information are very helpful!!


Solution

  • Ok, i found how to do it. To hide a button simply add the CSS class "hidden" to it like "toolbarButton download hiddenMediumView hidden". To download the file, just call "PDFViewerApplication.download();". To print it, use window.print().

    All the handlers are listet in the view.js file. Just search for "// Event handling functions.". In my version it's on line 1840.

    I guess that's the simplest way. Of cours buttons could be removed completely from the DOM but that would mean to also alter the view.js file.