Support MozBrowser.print passing nsIPrintSettings.kOutputFormatPDF on macOS
Categories
(Core :: Printing: Setup, enhancement, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox81 | --- | fixed |
People
(Reporter: jwatt, Assigned: jfkthame)
References
(Blocks 1 open bug)
Details
(Keywords: dev-doc-complete, Whiteboard: [print2020_v81])
Attachments
(1 file)
While checking whether we have save-to-PDF functionality on macOS I discovered that the WebExtensions api tabs.saveAsPDF does not work on macOS (an exception is thrown by that API as of bug 1386805). I don't think it should be too hard to get this working.
The obvious approach would be to handle nsIPrintSettings.kOutputFormatPDF in nsDeviceContextSpecX::MakePrintTarget as we do for the Linux code and Windows code. Hopefully it's as trivial as calling PrintTargetPDF::CreatePrintTarget as the other platforms do.
If we discover that the cairo PDF backend (what PrintTargetPDF uses) doesn't work well on mac (hopefully it's all cross-platform code and works the same as the other platforms) we could try getting the Cocoa code to output to PDF. That may provide better output than the cairo backend anyway, although it will take a bit more work to wire up.
Updated•4 years ago
|
I implemented the tabs.saveAsPDF() API primarily to support the 'Save As PDF' feature in my Print Edit WE extension. It was never clear to me why printing to PDF was not supported for macOS.
I get quite a few emails from users of Print Edit WE asking why saving to PDF is not supported on macOS. So adding support for this on macOS would be good.
However, I get far more emails from users of Print Edit WE asking why the saved PDF does not include 'clickable' links. Would switching to the Cocoa code support 'clickable' links in the saved PDF?
Reporter | ||
Comment 2•4 years ago
|
||
(In reply to dw-dev from comment #1)
I implemented the tabs.saveAsPDF() API primarily to support the 'Save As PDF' feature in my Print Edit WE extension. It was never clear to me why printing to PDF was not supported for macOS.
I believe because the Mozilla printing code had print-to-PDF functionality added on Windows and Mac because historically those platforms didn't have print-to-PDF functionality built into the operating system. Mac has had that OS support for a long time and the conversion happens below the APIs that the Mozilla printing code calls, so there was no reason to hook in the cairo support on Mac since it would never have been used. Since you hooked into Mozilla's normal printing codepath, tabs.saveAsPDF() inherits that behavior.
However, I get far more emails from users of Print Edit WE asking why the saved PDF does not include 'clickable' links. Would switching to the Cocoa code support 'clickable' links in the saved PDF?
Unfortunately not. That would be bug 454059.
Reporter | ||
Updated•4 years ago
|
Assignee | ||
Comment 3•4 years ago
|
||
I think we can make this work via the existing macOS printing code fairly easily. Hoping to have a patch up shortly.
Assignee | ||
Comment 4•4 years ago
|
||
(Though it won't provide clickable links in the pdf.)
Assignee | ||
Comment 5•4 years ago
|
||
Assignee | ||
Comment 6•4 years ago
|
||
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/8a3a8aa97de8 Make the WebExtensions API tabs.saveAsPDF work via the Cocoa printing code on macOS. r=jwatt,extension-reviewers,zombie
Updated•4 years ago
|
Comment 8•4 years ago
|
||
bugherder |
Assignee | ||
Updated•4 years ago
|
Comment 9•4 years ago
|
||
https://github.com/mdn/browser-compat-data/pull/6639
https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/81$revision/1642935
Description
•