Disable PDF printing in Firefox by web developer - pdf

I am developing a web page to show PDF (in .NET platform). The PDF is inside a iframe. One of the requirement is NOT allow client to print the PDF. I have already made the PDF to be password protected (with pdfsharp). I further hide the toolbar by setting toolbar=0. In Chrome & IE, this works fine. But for Firefox, the story is totally different.
In Firefox, the toolbar will be shown even append #toolbar=0 in the src link. Further, the password protected pdf can be printed by simply clicking the icon in the toolbar.
Can anyone suggest some ways to disable pdf printing in firefox.
Note: I need to show the PDF in the webpage. So, download the PDF is not a option.

You will not be able to control the toolbar or the ability to print (not all PDF viewers respect the permissions set by the password) if you rely on the native browser or OS level PDF viewer by using an iFrame. Different browsers will interpret those settings differently. Even different applications within the same browser will yield different results (Chrome vs Dropbox in Chrome)
You'll need to display the PDF using something like PDF.js or another such library if you want any kind of consistency in appearance and behavior.

Related

How to edit and save a PDF in Firefox 107 with JavaScript?

With the latest version of Firefox (107) it is now possible to edit and sign PDF documents within the browser preview window.
But how can I upload an updated version of such a PDF file back into my Web Application?
Is there any kind of JavaScript API I can use?
There is much overlap between PDF web editing browsers and Browser editing PDFs
the data is pulled down locally and the binary application edits the data however for a PDF, that then requires a local save as a new combined PDF. here we can see a visual reminder.
In Firefox or Chrome there are slight differences but the core need is to resave the PDF as a clients local file.
Chrome has inking
And Firefox uses a slightly different overlay but again the conjoined local data must be first saved as a new PDF.
either by print
or the top right Save (again) AS
Thus to achieve your goal you need to ask the annotator user to upload their masterpiece. However you cannot easily do that in the sandboxed page (with work frame) it needs to be after a user signal such as press button here to upload where-ever IF you were able or bothered to save as a new pdf.

Access DOM embedded PDF in Chrome

Is it possible to access the DOM of a embedded PDF file opened in Chrome?
If you simply open the DevTools in Chrome, only the EMBED tag is visible:
But there is a mouse over PDF file opened in Chrome and right-click => code view, then a completely different page code opens:
Can I get access to it?
Thank you in advance!
Yeah so it looks like you've got multiple documents on a page. Its similar to iFrames in web design. I'm not sure 100% because I cant look through the link.
But I'd highly recommend downloading the PDF as a file, then using ADOBE Pro's library to scrape or w/e with the PDF functions. You eliminate the whole aspect of timing, page loads, and page changes, when you get a direct link to a pdf, and then manipulate the data on the user or cloud PC.

Edit texts in a PDF on Chrome using Chrome inspect

Is there any way to modify texts in PDF on Chrome using the Chrome inspect tool? I was stuck because in the Chrome inspect element, differently than any other websites and even PowerPoint presentations opened in Chrome, I'm able to modify texts, while with PDFs I cannot. Does anyone know how to do it?
Edit: Yes I know that the changes made through Chrome DevTools are temporary, but usually I'm able to make those changes, even if they're temporary. But with PDFs I can't.
There are differences in the way some browsers handle PDF data.
Chromium based browsers are more traditional in that the PDF plug-in is based on a Foxit/Skia collaboration, So you need to understand in that case, the downloaded PDF you are viewing is in the binary application/pdf (file already outside of the html wrapper).
Just as you cannot edit the PDF text in Acrobat Reader, the most you can do is incrementally add comments/annotation or field data to the end of the file, before save as a secondary download. The server cannot see your changes unless you submit as an upload.
With Firefox and Google docs there is often a different approach where the PDF is "Repr"oduced as an "Ex"ample (A ReprEx of the PDF) so it is built of a hybrid image and text overlay to emulate that part of the real PDF source. When you previously or later save the underlying downloaded PDF (for viewing) it would not necessarily include any browser based HTML editing, in the saving.
There are other techniques for other cases, but to answer the basic OP question most simply, the answer is NO you cannot change a PDF body, only add notes, etc via extensions. Microsoft variant of Chrome I.E. Edge has some inbuilt annotation ability thus does not need a second extension.
Found this question because I was googling a similar situation--I was wanting to manipulate type sizes and margins on a PDF in inspector via Chrome. I found that FireFox DevTools will allow you to view those styles and even alter the content in the PDF while in browser. I am late to the game but hope this provides answers for someone else in the future.

Safari do not print Check Form properly where as Chrome does

When I print any Check Form, it opens as a PDF in the browser. It prints OK from Chrome but when I print it using Safari on MAC, it prints the same Check Form into two pages.
However, when I select the PDF or click on Check Form PDF and then print the Check Form using Safari, then it prints on single page, same like it prints from Chrome.
Any idea if there is any settings needs to be done in Safari for printing. Please suggest.
For printing always use PDF format if precise format matching is required:
On the workstation where it prints correctly, open the PDF and go into the print page setup then take note of all page settings, paper size, margins etc.. ask your technician to access page setup if you can't:
Be wary of any settings in page setup that attempts to resize the PDF before sending it to the printer:
Configure page setup (sometimes called print option) on Safari browser and macOS to match those that print successfully.
Links below are good starting points but actual configuration is dependent on OS and browser version. It's also out of scope of StackOverflow because it isn't a programming question. If you need help on configuring printers in Safari/MacOS and don't have a technician to do it, it would be better you ask on another stackexchange site, perhaps SuperUser would be the most appropriate:
https://support.apple.com/kb/ph25622?locale=en_US
https://support.apple.com/kb/PH21472?locale=en_US

Safari PDF controls missing PDF is rendered in iFrame

Anyone know why the PDF controls normally available when displaying a PDF in Safari would be missing when displayed in an iframe? Neither the "hover" controls or the extnded contextual menu is available. Safari reognized it as a PDF because the contextual menu includes the word PDF in the Open commands, ie. "Open PDF in new Window"
Opening a PDF into an empty browser works fine. The built in controls in Chrome and Firefox are there as well and work fine.
I am serving the PDFs using a very simple web page with an iframe inside a div.
I could be wrong but thought that they were there when I first started this project but I just noticed today that they are missing. Without them, PDF drawings cannot be zoomed in and out rendering them useless as PDFs.