GNOME Bugzilla – Bug 679883
When printing Custom paper sizes GTK Print Dialog does not send correct page size attribute
Last modified: 2012-12-16 18:20:22 UTC
Original bug report to Ubuntu: https://bugs.launchpad.net/ubuntu/+source/gimp/+bug/998156 To print a job on a custom paper size one has to send it with the attribute PageSize=Custom.WIDTHxHEIGHT[UNIT] for example PageSize=Custom.8x10in with the unit being optional. The unit can be in, pt, cm, or mm. The GTK print dialog sends PageSize=Custom.Custom.WIDTHxHEIGHT[UNIT] instead (2 times "Custom."). This breaks printing with CUPS. Many drivers do not recognize a valid page size at all and try to print with width = 0 and height = 0. In any case no printout with the given custom size comes out. Some applications, like Firefox, make the GTK print dialog send this wrong attribute even with regular page sizes. To reproduce: Run the command cupsctl LogLevel=debug In an application choose File/Print in the menu, in the print dialog select a printer on the "General" tab, switch to "Page Setup" tab, click on paper size drop down and choose "Manage Custom Sizes ...". Create a custom paper size. Now choose the newly created custom size and print. In /var/log/cups/error_log You will find a line like D [13/Jul/2012:19:24:49 +0200] [Job 626] argv[5]="InputSlot=Default PageSize=Custom.Custom.595.28x841.89 Duplex=None PrintoutMode=Normal PrinterResolution=FromPrintoutMode number-up=1 job-uuid=urn:uuid:bd2f3351-a345-3abb-63d9-ea13d11a8f39 job-originating-host-name=localhost time-at-creation=1342200218 time-at-processing=1342200289" Note the "PageSize=Custom.Custom.595.28x841.89" in the line. I have tested it with Thunderbird but users report it for nearly every other application with GTK print dialog.
Comments #74 and #75 in the Ubuntu bug report https://bugs.launchpad.net/ubuntu/+source/cups/+bug/973270 show a similar problem: When printing from Inkscape or evince the jobs get sent with an "PageSize=Custom.BrA3_S" attribute. Perhaps it is caused by the same bug but with a regular page size chosen.
Created attachment 224615 [details] [review] Check whether "Custom." prefix is already present in the name of selected paper size. This patch fixes the first problem by checking whether the prefix is already there.
For the second problem: The problem with Inkscape is that it doesn't let you select paper size so it always (my guess) print to a custom paper size whose dimensions are taken from "Document properties". This triggers the reported problem and should be solved by the patch. Evince remembers last used paper size and tries to use it again when printing. It can happen that you print the document on A3 paper on a printer but after that you want to print it on another printer which does not support A3 (e.g. the HP CP1515n). In that case the A3 paper size is custom for the second printer. It is a little different problem then the originally reported. You can see similar behaviour if you change PPD of the printer from a one which supports printing on A3 to a PPD which doesn't support it. Regards Marek
Review of attachment 224615 [details] [review]: This looks safe and sane to me.
Hi, I've committed the patch to the master and to the gtk-3-4 branch. I'm closing this. Regards Marek
Could the fix be backported to GTK+ 2.24? Current Inkscape still use GTK2, as does GIMP 2.8.
Also Firefox and Thunderbird are still using GTK 2.x.
Done: commit d9f9925878773fb37d1a385a929ddcbb4ef8fb80 Author: Marek Kasik <mkasik@redhat.com> Date: Tue Sep 18 14:18:15 2012 +0200 printing: Add "Custom." prefix only once to paper size Check whether "Custom." prefix is already present in the name of selected paper size. (#679883) (cherry picked from commit be7752183eb07274b67036362f895b31aa28eb25) modules/printbackends/cups/gtkprintbackendcups.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)