Closed Bug 1640044 Opened 4 years ago Closed 4 years ago

browser.tabs.saveAsPDF({}) bloats existing PDFs when saving

Categories

(WebExtensions :: Untriaged, defect, P3)

77 Branch
defect

Tracking

(firefox76 wontfix, firefox77 wontfix, firefox78 wontfix)

RESOLVED WONTFIX
Tracking Status
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:

  1. Install an addon that uses the browser.tabs.saveAsPDF() api. I installed FoxyTab from
    https://addons.mozilla.org/en-US/firefox/addon/foxytab/
  2. Go to a web page pdf such as https://arxiv.org/pdf/1906.04160.pdf
  3. At the top right click the save pdf button to save the pdf.
  4. Open your downloads folder and note the size of the file.
  5. Save the pdf tab using the addon. In FoxyTab right click the tab and select "FoxyTab > Save Tab as PDF".
  6. 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({}).
Product: Firefox → WebExtensions

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.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Severity: -- → S3
Priority: -- → P3

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.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.