Bug 15576 - [GTK] Printing support
Summary: [GTK] Printing support
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 523.x (Safari 3)
Hardware: All All
: P2 Normal
Assignee: Nobody
Keywords: Cairo, Gtk
Depends on:
Reported: 2007-10-20 07:32 PDT by Alp Toker
Modified: 2007-12-12 08:15 PST (History)
2 users (show)

See Also:

Initial printing support, WIP (5.40 KB, patch)
2007-11-19 04:14 PST, Alp Toker
no flags Details | Formatted Diff | Diff
Nearly feature complete (7.99 KB, patch)
2007-11-22 13:05 PST, Alp Toker
no flags Details | Formatted Diff | Diff
Abstracted PrintContext class (8.27 KB, patch)
2007-11-22 15:04 PST, Alp Toker
no flags Details | Formatted Diff | Diff
Print button for GtkLauncher (1.02 KB, patch)
2007-11-22 15:08 PST, Alp Toker
no flags Details | Formatted Diff | Diff
Add printing support (9.80 KB, patch)
2007-12-12 05:48 PST, Alp Toker
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alp Toker 2007-10-20 07:32:11 PDT
We need to implement printing support, Probably using GtkPrint.

We will need to clean up some assumptions about Gdk during the rendering process, say in native widget theming, but Cairo does most of the work for us here when it comes to generating PS and PDF.
Comment 1 Alp Toker 2007-11-19 04:14:49 PST
Created attachment 17396 [details]
Initial printing support, WIP

This is the start of printing support.

It adds one public entry point, webkit_frame_print(), and also adds support for launching print jobs from within pages.

You need a recent version of Cairo to get high-quality PDF output with selectable text and vector graphics -- older versions rasterize the entire document.

Still TODO:

Calculate page rects. Add support for more than just the first page.

Disable font hinting when in print mode. This problem needs to be dealt with for features like text scaling in other places too.

API: Decide whether webkit_frame_print() is correct -- I just made it up. Do we want a function on WebKitPage as well/instead? Do we want this to be overridable in subclasses? Thoughts welcome.
Comment 2 Alp Toker 2007-11-22 13:05:57 PST
Created attachment 17448 [details]
Nearly feature complete

This revision of the patch now paginates correctly.

Questions arising:

What should the public API look like? Should it be on WebKitPage, WebKitFrame or both?

There is an ugly global that needs to go before the patch is ready.

(I won't be looking into header/footer support.)
Comment 3 Alp Toker 2007-11-22 15:04:38 PST
Created attachment 17452 [details]
Abstracted PrintContext class

Still has mix 'n' match coding style because I can't bear the look of "gpointer userData".

Not finished yet.
Comment 4 Alp Toker 2007-11-22 15:08:48 PST
Created attachment 17453 [details]
Print button for GtkLauncher
Comment 5 Christian Dywan 2007-11-23 12:37:33 PST
Please surround printing code with #if GTK_CHECK_VERSION(2, 10, 0).

At some point it would be nice to allow for manual page setup from a client app, but this can go in a separate bug once this one is done.
Comment 6 Alp Toker 2007-12-12 05:48:56 PST
Created attachment 17862 [details]
Add printing support

It's a shame to leave this patch in the bug tracker, it works really well.

Coding style is intentionally not consistent wrt. camelCase vs. under_score since I expect the the print spooler will be split out and maybe even shared with other ports in the near future.

No public API change.
Comment 7 Alp Toker 2007-12-12 08:14:19 PST
Comment on attachment 17862 [details]
Add printing support

Comment 8 Alp Toker 2007-12-12 08:15:36 PST
Landed in r28648 with minor style fixes.