Bug 79226

Summary: [GTK] Implement print preview
Product: WebKit Reporter: Carlos Garcia Campos <cgarcia>
Component: WebKitGTKAssignee: Tomas Popela <tpopela>
Status: NEW    
Severity: Normal CC: aperez, bugs-noreply, bugzilla, mcrha, mike, noein93, tpopela
Priority: P2 Keywords: Gtk
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Linux   
See Also: https://bugzilla.gnome.org/show_bug.cgi?id=779254
Bug Depends on:    
Bug Blocks: 75544    
Attachments:
Description Flags
Patch none

Carlos Garcia Campos
Reported 2012-02-22 05:07:58 PST
It's currently unsupported.
Attachments
Patch (14.26 KB, patch)
2016-12-01 07:44 PST, Tomas Popela
no flags
Martin Robinson
Comment 1 2015-05-07 18:24:58 PDT
What all do we need to do for this?
Carlos Garcia Campos
Comment 2 2015-05-07 22:38:11 PDT
We probably need a way to send the PDF from the web process to the UI process.
Milan Crha
Comment 3 2016-02-16 06:27:54 PST
I do not know the rationale behind this, but with respect of the Gtk's print dialog, you get all of that for free, both Print Preview and Export to PDF (yes, that's also sometimes useful), if you just reuse what the gtk offer. All you need to do is to implement three signals on the GtkPrintOperation, as shown in the simple example [1], which can be run in gtk3-demo, Printing->Printing demo. Reuse of the code is beneficial, I believe, especially when you get things for free. [1] https://git.gnome.org/browse/gtk+/tree/demos/gtk-demo/printing.c#n158
Carlos Garcia Campos
Comment 4 2016-02-16 08:34:45 PST
Unfortunately this is not that easy in WebKit2 model. We run the dialog in the ui process, but the print operation in the web process. So we use the unix print dialog manually, and a custom print operation in the web process. So, the UI process simply collects the options form the print dialog, and the web process does the actual printing to a file that is sent to the printer with GtkPrintJob
Tomas Popela
Comment 5 2016-12-01 07:44:55 PST
Tomas Popela
Comment 6 2016-12-01 07:49:30 PST
I added a wip implementation (but it's working) just to have some opinion from other devs if this is the right way to implement this (we talked about this with Carlos during the hackfest). For the description please see the change logs.
Milan Crha
Comment 7 2017-02-27 04:57:26 PST
Just for a record, recent downstream bug report against Evolution: https://bugzilla.gnome.org/show_bug.cgi?id=779254
Michael Gratton
Comment 8 2018-04-26 23:27:54 PDT
FWIW, Flatpak's xdg-desktop-portal-gtk just did something similar using evince-previewer for its print preview implementation, which has the same challenges as the WK2 model: https://github.com/flatpak/xdg-desktop-portal-gtk/commit/8710c71022e60543881bbe7dbefb76285ab03a34
Carlos Garcia Campos
Comment 9 2022-09-05 01:14:44 PDT
Now that we have PDF support we can probably implement print preview using a web view.
Note You need to log in before you can comment on or make changes to this bug.