Wednesday, July 2, 2008

Fixing Printer Scaling on Ubuntu 8.04 (bug: 217151)

During a recent rollout of "Ubuntu on the Desktop" I ran foul of this bug in Epiphany.

The symptoms, as the bug describes -- are the headers and footers of a document are printed, but no body text -- we tested this on various printers and came out with the same result.

To fix it, we applied a hack at login-time to manually set people's preferences to Scale=100, by editing the ~/.gnome2/epiphany/print-settings.ini file and changing:

--- Scale=1

to

+++ Scale=99

(note: I never use 100, because it makes badly-designed websites like Online Banking websites sometimes print outer-borders on a second page, 99 fixes that with no user-discernable difference to the print quality)

It fixed the problem, but hacks are never elegant, break easily and are not good to apply over a 400-workstation installation, so this morning -- my task was to track it down and fix it.

Turns out, it's an innoculous little bastard in the Epiphany gecko code that caused it.

In the embed/mozilla/GeckoPrintService.cpp file, there's a line (around 737-739) that reads:

" gtk_print_settings_set_scale (aGtkSettings, 1.0); "

But this states:

" scale : the scale in percent "

So, the solution turned out to be changing:



gtk_print_settings_set_scale (aGtkSettings, 1.0);



To:



gtk_print_settings_set_scale (aGtkSettings, 99.0);



The bug has now been noted, with a patch that fixes the issue here