Closed Bug 1653354 Opened 4 years ago Closed 4 years ago

Support MozBrowser.print passing nsIPrintSettings.kOutputFormatPDF on macOS

Categories

(Core :: Printing: Setup, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
81 Branch
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.

Whiteboard: [print2020_v81] → [print2020_v82]

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?

Flags: needinfo?(jwatt)

(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.

Flags: needinfo?(jwatt)
Whiteboard: [print2020_v82] → [print2020_v81]

I think we can make this work via the existing macOS printing code fairly easily. Hoping to have a patch up shortly.

Assignee: nobody → jfkthame

(Though it won't provide clickable links in the pdf.)

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
Keywords: dev-doc-needed
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 81 Branch
Regressed by: 1660218
No longer regressed by: 1660218
Regressions: 1660218
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: