electron-pdf-window icon indicating copy to clipboard operation
electron-pdf-window copied to clipboard

Dynamically disable/enable PDF printing/saving

Open ajmakoni opened this issue 8 years ago • 1 comments

Hello, I have tested your module and it works perfectly! However, is there away in which I could dynamically enable/disable print/saving option on the window?

ajmakoni avatar Sep 11 '17 12:09 ajmakoni

Hello, I took sometime in the evening and have figure a solution. Any one interested in this features, the easiest solution is to insert CSS in your DOM:

win.webContents.on('dom-ready', () => { 
win.webContents.insertCSS('.toolbarButton#print,.toolbarButton#viewBookmark,
.toolbarButton#download,.toolbarButton#openFile,
.toolbarButton#viewAttachments{display: none;}');
});

You can then dynamically show each component by inserting another CSS in the DOM but this time it must say {display: block}

(can be block, initial, inline e.t.c)

The CSS class is as follows: .toolbarButton#openFile = Open File Button, .toolbarButton#viewAttachments = View Attachements button e.t.c To see more classes, check out the view.html page here: PDFJS-viewer Hope this helps someone

ajmakoni avatar Sep 12 '17 06:09 ajmakoni