GMail printing twice from Firefox

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
Timur Born
User
Posts: 874
Joined: Tue Jun 26, 2012 1:50 pm

GMail printing twice from Firefox

Post by Timur Born »

Hello,

this is not an Editor specific problem, but maybe Editor can offer a solution?

When I click on a PDF attachment in GMail using Firefox I first get a preview and then can choose to either download or print the file. If I choose to print then the file is downloaded using a temporary filename and then opened in Editor for printing. Next Editor's print dialog is automatically opened *twice* instead of just once. This also happens when Acrobat is used as default PDF viewer, so it's not an Editor specific problem, but likely rather a problem of how GMail sends the print command.

Is there anything I can do about it other than just download the file and then start a print manually?
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: GMail printing twice from Firefox

Post by Tracker Supp-Stefan »

Hello Timur,

Does this happen with any PDF file or with some specific one?
As I suspect that maybe one of the two 'prints' is a JS inside the file that tries to print it, and the second is the browser trying to do the same.

Regards,
Stefan
Timur Born
User
Posts: 874
Joined: Tue Jun 26, 2012 1:50 pm

Re: GMail printing twice from Firefox

Post by Timur Born »

I don't think it happens with specific PDF files, at least it happened with any PDF I tried to directly print out of GMail instead of just saving it (which also automatically opens it in Editor, but without the printing dialog). I don't think I opened any PDF files with JS at all yet. Could even be a Firefox specific thing, need to test using other browsers.
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8440
Joined: Wed Jan 03, 2018 6:52 pm

Re: GMail printing twice from Firefox

Post by TrackerSupp-Daniel »

Hi Timur,

I haven't been able to reproduce this on my end yet either.
With Firefox, Chrome and Edge clicking the print button downloads the file, opens in editor and only presents 1 print dialog.
When you say the print dialog opens twice, are both of them the Editor print dialog, or is one of them a system print dialog? If they are both Editor dialogs, do they open at the same time, or does one open after the other is closed?
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Timur Born
User
Posts: 874
Joined: Tue Jun 26, 2012 1:50 pm

Re: GMail printing twice from Firefox

Post by Timur Born »

It's Editor's print dialog and it comes up a second time after I closed the first (either printing or cancelling).

I just tried it using a simple PDF consisting of a single scanned page. Turns out that the actual printing is done via JS anyway, seems that GMail recreates the PDF including a JS print command. That print command is interpreted twice by Editor, Acrobat, Foxit and Internet Explorer, but only once by Firefox' internal PDF view and even Chrome's PDF view when Chrome is started by Firefox as external viewer.

Foxit even displays the JS warning twice if the file is not trusted.
Timur Born
User
Posts: 874
Joined: Tue Jun 26, 2012 1:50 pm

Re: GMail printing twice from Firefox

Post by Timur Born »

I started Firefox without any addons, but the same thing happens, so it's not an addon thing.
Timur Born
User
Posts: 874
Joined: Tue Jun 26, 2012 1:50 pm

Re: GMail printing twice from Firefox

Post by Timur Born »

When I use Chrome and set it up to to save PDF files instead of viewing them internally then the print button only saves the temporary file, which resulting in the print dialog only opening once when opened in Editor.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: GMail printing twice from Firefox

Post by Tracker Supp-Stefan »

Hello Timur,

Thanks for the further details in you investigating this!
So if FFox or Chrome does initiate printing with JS, and there is separate JS inside the PDF file itself that also tries to print it - this might explain why this whole thing happened!
Is the solution you've found so far an acceptable one for you or do we need to look at this further?

Regards,
Stefan
Timur Born
User
Posts: 874
Joined: Tue Jun 26, 2012 1:50 pm

Re: GMail printing twice from Firefox

Post by Timur Born »

If I want to keep Editor as default application for handling PDF links in Firefox then the only workarounds are to either save the file and then hit print manually or to cancel the second print dialog popup. The latter is more convenient and what I did all the time anyway. I just asked to see if anyone can think of a solution. Curious that Firefox' internal PDF view only prints once, though, while both Editor and Acrobat try to print twice

According to Editor's document info the following JS is included in the file:

Do Print
this.print({bUI:true,bSilent:false,bShrinkToFit:true});

When I remove this, save the file and open it again then the print dialog is only opened once. Albeit I wonder where does Editor (or Acrobat) get the print command from anyway if I just removed the JS command via the document info dialog?
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8440
Joined: Wed Jan 03, 2018 6:52 pm

Re: GMail printing twice from Firefox

Post by TrackerSupp-Daniel »

HI Timur,

I am unsure how Firefox handles it, but it seems to be sending a print command to the application as it sends the document, along with embedding that JS into the file. Which would cause the print dialog to open twice on any processor that reads JS. It is purely a theory, as I cannot be sure.
But if it happens not only to our software, but others as well, I might suggest contacting Mozilla to have them look at it from their end. It seems very likely that their handling for this is the cause.

It is also possible that its the combination of print operations, Perhaps Firefox tells the application to print, and Gmail tells the document to do it, turning this entire situation into a "who-dun-it" scenario.

I don't like to provide idle speculation, but in this case I cannot come up with any alternatives.

Best Regards.
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Timur Born
User
Posts: 874
Joined: Tue Jun 26, 2012 1:50 pm

Re: GMail printing twice from Firefox

Post by Timur Born »

I don't think that any print command is sent by Firefox. That is because I saved the file locally after removing the JS command and it still opens a (single) print dialog when I then open it locally. So it has to be somewhere within the file, on top of the already removed JS command (removed from Document Properties).
Timur Born
User
Posts: 874
Joined: Tue Jun 26, 2012 1:50 pm

Re: GMail printing twice from Firefox

Post by Timur Born »

I prepared two files for demonstration:

- Print_JS is how GMail sends the file via Firefox. It includes the "DoPrint" JS command line I posted earlier and thus makes Editor open two print dialogs in a row.

- Print_no_JS is has the "DoPrint" JS command removed via Document Properties and thus makes Editor only open the print dialog once.
Attachments
Print_no_JS.pdf
(105.66 KiB) Downloaded 71 times
Print_JS.pdf
(105.7 KiB) Downloaded 74 times
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3549
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: GMail printing twice from Firefox

Post by Ivan - Tracker Software »

As you mentioned Print_JS.pdf has document-level JS script

Code: Select all

this.print({bUI:true,bSilent:false,bShrinkToFit:true});
which is executed when document is opened, and will show print dialog.

Another place which causes the print dialog to show is the document's Open Action which has the same JS action (see picture below)

99% of documents which have Open Action use Goto action to jump to some initial page, that's why most PDF applications (including the Editor) does not allow editing JS open actions (but we are going to add this feature soon).
print_js_structure.png
To 'fix' the document, open document's preferences (in the Editor or Acrobat), go to "Initial View" page, change eighter initial page or zoom level, press apply and then change it back to original value, press Ok and save the document.

HTH
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
Timur Born
User
Posts: 874
Joined: Tue Jun 26, 2012 1:50 pm

Re: GMail printing twice from Firefox

Post by Timur Born »

Thanks Ivan,

applying manual changes would be even less convenient than simply closing the second print dialog. I mostly wondered if there was an automated way to handle this problem, but obviously this is more of a GMail/Firefox issue anyway. At least we know now that there are two JS print commands attached to the documents, so this is what makes Editor open the print dialog twice.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: GMail printing twice from Firefox

Post by Tracker Supp-Stefan »

:D
Post Reply