@@ -35,8 +35,7 @@ export default {
3535
3636 computed: {
3737 iframeSrc () {
38- return generateUrl (' /apps/files_pdfviewer/?file={file}&hideDownload={hideDownload}' , {
39- hideDownload: hideDownload () ? 1 : 0 ,
38+ return generateUrl (' /apps/files_pdfviewer/?file={file}' , {
4039 file: this .source ?? this .davPath ,
4140 })
4241 },
@@ -184,6 +183,46 @@ export default {
184183 this .getDownloadElement ().removeAttribute (' disabled' )
185184 }
186185 })
186+
187+ if (hideDownload ()) {
188+ const pdfViewer = this .getIframeDocument ().querySelector (' .pdfViewer' )
189+
190+ if (pdfViewer) {
191+ pdfViewer .classList .add (' disabledTextSelection' )
192+ }
193+
194+ // Disable download function when downloads are hidden, as even
195+ // if the buttons in the UI are hidden the download could still
196+ // be triggered with Ctrl|Meta+S.
197+ this .PDFViewerApplication .download = () => {
198+ }
199+
200+ // Disable printing service when downloads are hidden, as even
201+ // if the buttons in the UI are hidden the printing could still
202+ // be triggered with Ctrl|Meta+P.
203+ // Abuse the "supportsPrinting" parameter, which signals that
204+ // the browser does not fully support printing, to make
205+ // PDFViewer disable the printing service.
206+ // "supportsPrinting" is a getter function, so it needs to be
207+ // deleted before replacing it with a simple value.
208+ delete this .PDFViewerApplication .supportsPrinting
209+ this .PDFViewerApplication .supportsPrinting = false
210+
211+ // When printing is not supported a warning is shown by the
212+ // default "beforePrint" function when trying to print. That
213+ // function needs to be replaced with an empty one to prevent
214+ // that warning to be shown.
215+ this .PDFViewerApplication .beforePrint = () => {
216+ }
217+
218+ logger .info (' Download, print and user interaction disabled' )
219+ } else {
220+ logger .info (' Download and print available' )
221+ }
222+
223+ const PDFViewerApplicationOptions = this .$refs .iframe .contentWindow .PDFViewerApplicationOptions
224+
225+ logger .debug (' Initialized files_pdfviewer' , PDFViewerApplicationOptions .getAll ())
187226 },
188227
189228 handleWebviewerloaded () {
0 commit comments