browser.tabs.saveAsPDF({}) bloats existing PDFs when saving
Categories
(WebExtensions :: Untriaged, defect, P3)
Tracking
(firefox76 wontfix, firefox77 wontfix, firefox78 wontfix)
People
(Reporter: xdhmoore, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0
Steps to reproduce:
Steps to reproduce:
- Install an addon that uses the browser.tabs.saveAsPDF() api. I installed FoxyTab from
https://addons.mozilla.org/en-US/firefox/addon/foxytab/ - Go to a web page pdf such as https://arxiv.org/pdf/1906.04160.pdf
- At the top right click the save pdf button to save the pdf.
- Open your downloads folder and note the size of the file.
- Save the pdf tab using the addon. In FoxyTab right click the tab and select "FoxyTab > Save Tab as PDF".
- Wait for the tab to save and then note the size of the new file in your downloads folder.
Actual results:
The "saved" file is 6,181 KB, while the file created with browser.tabs.saveAsPDF() is about 4 times larger at 24,210 KB.
Expected results:
saveAsPDF() should save the original pdf file at its original size if possible.
I assume that saveAsPDF() is wrapping the existing pdf code with more pdf code. Perhaps the Content-Type could be used to determine if the page needs wrapping or could be saved as-is.
I guess the question is, is it up to addon developers to detect Content-Type and save pdfs differently instead of calling saveAsPDF(), or would it make sense to make saveAsPDF() smart enough to save pdfs as-is.
NOTES:
- On verifying that FoxyTab uses browser.tabs.saveAsPDF({}): The developer doesn't make the source available, but if you download and extract the xpi, in background.js you can see the menu item handler which calls exactly browser.tabs.saveAsPDF({}).
Updated•4 years ago
|
Comment 1•4 years ago
|
||
Hi Daniel,
Thank you for submitting this bug report. After testing on Windows 10 x 64 bit with latest Nightly 78.0a1 (20200528032513), Beta 77.0 (20200527121107) and Release 76.0.1 (20200507114007), I was able to reproduce the issue that you described.
On Mac 10.14 saving the PDF using step 3 will result in a 6,3 MB saved file and trying to save the PDF through the Foxytab add-on described in step 5, the message "Save as PDF is not available on Mac OS x or before Firefox 56" is displayed and the PDF can't be saved.
Updated•4 years ago
|
Comment 2•4 years ago
|
||
The saveAsPDF
generates a new PDF based on the currently rendered content. The resulting size can be larger or smaller, that's normal.
If you want the original PDF file, download that file instead of using saveAsPDF
.
Updated•4 years ago
|
Description
•