-
Notifications
You must be signed in to change notification settings - Fork 54
Prevent download, printing and text selection when download is hidden #179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent download, printing and text selection when download is hidden #179
Conversation
|
/backport to stable19 |
|
/backport to stable18 |
|
/backport to stable17 |
|
Sorry, there is still a missing case (printing through Ctrl+P), please do not review yet :-) |
Even if the Download buttons are hidden in the toolbars it was still possible to trigger the download by using Ctrl|Meta+S. This directly calls the "PDFViewerApplication.download" function, so when downloads are hidden that function is now replaced with an empty function. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Even if the Print button was hidden in the toolbar it was still possible to trigger the printing by using Ctrl|Meta+P. This uses the print service from PDFViewer, so when the download is hidden the print service is now disabled. When printing is flagged as not supported in the PDFViewerApplication initialization the Print buttons are disabled, so it is no longer needed to disable them explicity. Moreover, this also fixes the Print button being disabled only in the toolbar, but not in the secondary toolbar (which is shown in smaller screens). Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
The Download button is hidden in both the toolbar and the secondary toolbar later, so it is not needed to hide it only for the toolbar first. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Even if printing was not possible using the PDFViewer printing services it was still possible to print the PDF document by printing the web page from the browser. As that can not be really prevented the best that can be done is hide all the content in the printed media using CSS. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
When the PDF is rendered PDFViewer creates canvases with the contents of the pages and, in front of them, it creates too a layer with HTML text elements that makes possible to select it. That text layer is used too by the search function to highlight the results, so it can not be removed. Instead of that the selection of the text is prevented using CSS. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
999d885 to
041a36c
Compare
|
Ready for review! :-) |
|
Can confirm that these changes work like expected with Nextcloud 18.0.4. |
Downloading with Thanks for the information :-) |
|
Sorry, I have not seen your changes to workersrc.js when I accessed this PR first time. Everything is fine now! |
Thanks for the confirmation :-) |
Please refer to the commit messages for details.
How to test
Results with this pull request
It is not possible to download or print the file, and it is not possible to select the text (of course it is possible to do all that if you know how, but not with the "normal" ways).
Results with this pull request
It is possible to download the file using
Ctrl+S, it is possible to print the file usingCtrl+Por making the window smaller so the Print button appears in the>>menu, it is possible to print the file by printing the full page or the frame from the browser, and it is possible to select the text of the PDF.