GNOME Bugzilla – Bug 599401
GtkPrint should not rotate context for PDF when printing landscape
Last modified: 2012-09-12 13:44:20 UTC
1. Open gedit and paste in some text 2. Print to PDF in landscape orientation 3. View the PDF in evince Result: Page is in portrait orientation with text rotated 90 degrees. PostScript is the only output format that requires the context to be rotated 90 degrees for landscape printing. Other output formats should swap the width and height values instead of rotating 90 degrees when in landscape orientation. ie if (landscape) cairo_pdf_surface_create (file, height, width) else cairo_pdf_surface_create (file, width, height) The context can be rotated 180 degrees for the reverse portrait and reverse landscape orientations.
Created attachment 146259 [details] [review] Don't rotate pdf landscape Patch to fix this problem. I found gtk_page_setup_get_paper_width/height to be a better solution than swapping width and height when in landscape orientation.
Created attachment 146418 [details] [review] Don't rotate pdf landscape The previous patch broke PDF output with reverse portrait/reverse landscape orientation. Fixed in this patch.
Hi Adrian, the first page is not rendered correctly when printing landscape to PDF with your last patch (with gtk-demo). The page is cropped. Marek
The cropped page is a cairo bug: https://bugs.freedesktop.org/show_bug.cgi?id=24691 This occurs because the PDF surface is created in portrait orientation then before the page is rendered the page size is changed to landscape. It is on our list of blockers to be fixed before cairo 1.10 is released. https://bugs.freedesktop.org/show_bug.cgi?id=24384
*** Bug 622783 has been marked as a duplicate of this bug. ***
Created attachment 176279 [details] [review] adapted patch to gtk-2-24 branch Applying the adapted patch to gtk-2-24 resolves two bugs reported against Dia (see blocks). Any objections to commit it?
Created attachment 177121 [details] [review] don't rotate pdf landscape - rebased to git master I've rebased the patch to git master and successfully tested with cairo 1.10.2 cairo git master. The problem referred to in comment 3 has been fixed in cairo.
Are there any issues with this patch that need addressing? The patch still applies.
Created attachment 209478 [details] [review] don't rotate pdf landscape - rebased to git master Another 12 months has passed. Rebasing to master.
Created attachment 224089 [details] [review] don't rotate pdf landscape Hi Adrian, thank you for the patch and I'm sorry for the long delay. I tested the patch and it breaks printing to CUPS printers. It prints landscape-sized page to portrait-sized page when printing to a CUPS printer. The result is that the print is cropped. The problem is easy to fix by checking "manual_orientation" also inside of unix_start_page in the "type == CAIRO_SURFACE_TYPE_PDF" part (current CUPS backend accepts PDFs). Other than that the patch is ok with me. But since there is hard freeze quite soon I would like to have approval from a core Gtk+ developer. Matthias do you agree with committing this to master now or should we wait after the freeze? Regards Marek
I'm fine with getting it in this week - your comment indicates that you've done enough testing that we can be confident it works...
(In reply to comment #11) > I'm fine with getting it in this week - your comment indicates that you've done > enough testing that we can be confident it works... Yes, you are right, I spent quite a lot of time on testing of various printing scenarios this week. I've committed the patch to the master. Thanks Marek