GTK apps should send PDF to CUPS when printing

Bug #258421 reported by Till Kamppeter
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Evince
Expired
Wishlist
GTK+
Fix Released
Wishlist
evince (Ubuntu)
Fix Released
Wishlist
Ubuntu Desktop Bugs
gtk+2.0 (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

To implement the Blueprint "PDF as standard print job format"

https://blueprints.edge.launchpad.net/ubuntu/+spec/pdf-as-standard-print-job-format

applications need to output PDF instead of PostScript when printing.

GTK applications still output PostScript. This can be changed by applying a simple patch which is attached.

This makes for example GEdit and GIMP (built-in standard dialog) sending PDF to CUPS.

Other programs, like evince and Firefox still send PostScript. Here there are probably similar patches needed in the applications themselves.

Related branches

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :
Changed in gtk+2.0:
importance: Undecided → Medium
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gtk+2.0 - 2.14.3-0ubuntu2

---------------
gtk+2.0 (2.14.3-0ubuntu2) intrepid; urgency=low

  * debian/patches/061_use_pdf_as_default_printing_standard.patch:
    - launchpad patch to use pdf as default printing standard (lp: #258421)

 -- Sebastien Bacher <email address hidden> Thu, 25 Sep 2008 00:47:22 +0200

Changed in gtk+2.0:
status: New → Fix Released
Changed in gtk:
status: Unknown → New
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

evince and several other applications are not affected by the GTK patch applied here. They need additional patches to output PDF instead of PostScript when printing, perhaps also in the individual applications.

Revision history for this message
none (ubuntu-bugs-nullinfinity-deactivatedaccount) wrote :

I tried forcing evince to output pdf. It sort of works, but the pdftopdf filter consumes very large amounts of memory on large-ish documents. For a 5 meg pdf file, the resident size of pdftopdf grew to 1.6 gigabytes and the machine was swapping like crazy before I killed the process.

I'm attaching the patch to evince that I used.

Revision history for this message
none (ubuntu-bugs-nullinfinity-deactivatedaccount) wrote :

It's possible the out-of-memory problems would be alleviated by the patch in http://bugzilla.gnome.org/show_bug.cgi?id=557112 .

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Johan, can you try the patch to see whether evince printing works better then? Thanks.

Revision history for this message
none (ubuntu-bugs-nullinfinity-deactivatedaccount) wrote :

Unfortunately, the patch from the gnome bug didn't help. Evince still produces very large pdf output files for some documents.

Revision history for this message
none (ubuntu-bugs-nullinfinity-deactivatedaccount) wrote :

Wow. The poppler pdf output seems to be... less than optimal. Running pdfimages on a 3-page pdf that came from the evince "Print preview" functionality gave me 10 000 ppm images. Poppler seems to embed bitmaps into the pdf, one for each character of text.

No wonder the file is huge. Possibly related thread: http://lists.freedesktop.org/archives/cairo/2007-January/009096.html

Revision history for this message
none (ubuntu-bugs-nullinfinity-deactivatedaccount) wrote :

The reason for the huge files is a bug in Cairo that was fixed very recently. See http://bugs.freedesktop.org/show_bug.cgi?id=12769

Would there be any chance of the Cairo fix going into Jaunty? If not, it's probably better to leave Evince as it is.

Revision history for this message
none (ubuntu-bugs-nullinfinity-deactivatedaccount) wrote :

Sorry, make that "bug in poppler".

Revision history for this message
Sebastien Bacher (seb128) wrote :

the poppler changes are far to be trivial and probably for next cycle rather

Changed in evince:
assignee: nobody → desktop-bugs
importance: Undecided → Wishlist
Revision history for this message
none (ubuntu-bugs-nullinfinity-deactivatedaccount) wrote :

With Karmic and poppler 0.11, the above patch to make evince output PDF works much better.

The PDF file that evince gives to cups is now just slightly bigger than the original, instead of being a factor of 100 larger, like it was before.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

seb128, Poppler is fixed now in Karmic. Could you apply the Evince patch for Karmic's evince? Thanks.

Revision history for this message
Sebastien Bacher (seb128) wrote :

not sure that's something we want to change in a stable serie or a sru candidate

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

I thought about Karmic.

Revision history for this message
Sebastien Bacher (seb128) wrote :

sorry I read the previous comment too quickly, I will upload after the alpha freeze, could you open an upstream bug about that too?

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :
Changed in evince:
status: Unknown → New
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

seb128, not that the evince patch is not working correctly. It makes jobs sent to a real printer being sent in PDF, but it also emits PDF if the user prints to a file and chooses PostScript as output format. Probably some additional check is needed.

Revision history for this message
none (ubuntu-bugs-nullinfinity-deactivatedaccount) wrote :

The patch just papers over the fact that the original check is buggy: file_format is always set to the null string, when it should be "pdf" or "ps".

I'll try to figure out why this happens.

Revision history for this message
none (ubuntu-bugs-nullinfinity-deactivatedaccount) wrote :

I believe the bug is in this line in ev-print-operation.c:

file_format = gtk_print_settings_get (print_settings, GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT);

... but the key GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT is only defined for the "output to file" pseudo-printer, according to http://library.gnome.org/devel/gtk/unstable/GtkPrintSettings.html

I'm attaching a new patch. If file_format is NULL (which it is for any real printer) or "pdf" (which it is when you select "print to file" and choose pdf as the format), the patch will make evince output pdf.

If file_format is "ps" (which it will only be if you select "print to file" and choose ps as the format), the patch will make evince output postscript.

Revision history for this message
none (ubuntu-bugs-nullinfinity-deactivatedaccount) wrote :

Here's a slightly updated patch that uses gtk_printer_accepts_pdf().

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Did you test this patch whether it actually works? Does gtk_printer_accepts_pdf(printer) results in True if printer is a CUPS queue?

Revision history for this message
none (ubuntu-bugs-nullinfinity-deactivatedaccount) wrote :

Yes, I tested that and it does work. But the patch with gtk_printer_accepts_pdf had a bug - apparently that function always returns true for the print to file "printer", even if the user selects postscript. Updated patch attached.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Thank you for the patches.

There is one possibility to make it even better: It should be checked what the input file format is and if it is the same as the print output format selected by your patch (PDF or PostScript), the input file should be sent directly to CUPS instead of evince re-rendering it.

Revision history for this message
Bartek (tschew) wrote :

Hi Till, I'm only familiar with the pagination parts of ev-print-operation (the re-rendering bit) and not with the initialisation steps so I might be off: As far as I understand gtk-print-operation is used for real printer targets in evince > 2.24 so evince does not do any re-rendering. (for instance, multiple pages per sheet works correctly for a real printer but has a number of bugs when exporting to file)

Except maybe in the case of printing multiple pages per sheet and printer drivers that don't natively support it. (not sure about this though, a quick glance does not reveal any relevant conditionals)

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Another suggestion is the following (I do not know whether this is perhaps already implemented):

CUPS has sophisticated page management methods: N-up, selected pages, scale to fit, even/odd pages, ... These work very well if the page management is completely left to CUPS and not a part already done by evince or GTK Print and another part by CUPS. This is important because the page management actions have to be done in the correct order. For example if both 4-up and odd pages are selected, the first sheet should come out with page 1, 2, 3, 4 and the second with page 9, 10, 11, 12. So the N-up has to be done before filtering out every second sheet. For selected page ranges it is different. If the user selects 2-up and wants to print only page 1, 5-10, 16, and 17, he should get the following sheets: 1/5, 6/7, 8/9, 10/16, 17/blank.

So the best would be that in case of printing to a CUPS queue to always send the full document in PDF (the input file if it was already PDF) and the page management options as IPP attributes, as well as the PPD options. Then CUPS will do everything to get the document correctly printed.

Revision history for this message
Bartek (tschew) wrote :

I think the argument against doing what you suggest is that some printer drivers mess up the page management (is this even true? I don't know how cups operates and which part does the pagination.) and the evince guys wanted to produce a write once run everywhere solution.

Using gtk-print-operation the ranges and sheets that you mention should come out correctly (ie printing to a real printer with a recent version of evince), at least they do for me.

As for printing to file (which is known broken for the cases you mention) I have a patch in bug http://bugzilla.gnome.org/show_bug.cgi?id=583429 which operates the way you explain it. The only thing remaining to be fixed is reverse printing of multiple pages per sheet.

I wrote a test-script (http://bugzilla.gnome.org/show_bug.cgi?id=583976) for automatically testing different print setting combinations and it should be possible to adapt it to test printers other than "print to file". (it uses the accessiblity extensions to interact with the UI)

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

CUPS page management is completely independent of the printer driver. It happens in the pdftopdf filter (in Ubuntu and Debian unstable) or in the pstops filter (all other Linux distros).

Having the page management completely be donme by evince is also no problem, but it must be really completely done by evince, and it must have all functionality of the CUPS page management.

Revision history for this message
none (ubuntu-bugs-nullinfinity-deactivatedaccount) wrote :

Adding a final, functionally equivalent but slightly cleaned-up version of the patch.

As for punting the page management to CUPS, code just landed in evince that does the page management with gtkprint: http://bugzilla.gnome.org/show_bug.cgi?id=557112

So presumably gtk is now the proper place for changing that.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Johan, thank you very much for your patch. It works perfectly. "Print to file" gives the selected file format and printing to a CUPS queue sends PDF. The output fioles are also small and do not have text converted to bitmaps. All is perfect now.

With this patch applied there should be no complaints any more that printing from evince gives bad quality, is too slow, or even does not work at all.

Changed in evince (Ubuntu):
status: New → In Progress
status: In Progress → Triaged
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you for your work there, could you add your updated patch to the upstream bug for review?

Changed in evince:
status: New → Fix Released
Revision history for this message
Sebastien Bacher (seb128) wrote :

the issue is fixed in karmic

Changed in evince (Ubuntu):
status: Triaged → Fix Released
Changed in evince:
importance: Unknown → Wishlist
status: Fix Released → New
Changed in gtk:
importance: Unknown → Wishlist
Changed in gtk:
status: New → Fix Released
Changed in evince:
status: New → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.