GNOME Bugzilla – Bug 346245
Need GTK_UNIT_PIXEL in gtkprintutils.c
Last modified: 2018-02-10 03:29:32 UTC
Please forgive me if this is a dumb question - I am not a printing expert - but do you ever plan to implement GTK_UNIT_PIXEL in gtkprintutils.c? I understand that pixels are not dots. But how is an application supposed to draw on either a printer or a display using the same code? It seems to me that it is not nice to make the application do the translation from pixels to dots in order to print. Then, they have to know that they are drawing on a printer. It would seem nicer for gtkprintutils.c to support GTK_UNIT_PIXEL? For example, GDI+ (on Windows) accepts pixels for drawing units on printers.
What would the meaning of that be ? The current units are a way to know how big the drawing will end up on the paper. Is the idea that we take the screen dpi to go from pixels to inches ?
Yes, please. Otherwise I would have to multiply any units I get from my user by 72/600 (for example) before any drawing takes place. What I am currently doing is returning 72 x 72 when the user asks for the DPI, when I really ought to be returning 600 x 600... (kind of faking out the user so that I don't have to do any slow math... <g>). That way, my users don't have to rewrite any lines of code to do scaling when they go from drawing on the display to drawing on the printer. How do people use the same code to draw on both devices if you don't provide pixel units? I may be missing something here...
I'm working on a Eclipse RCP Application that have to print some documents. On linux I have to rewrite all formattings to scale my gc for the printer. It would be great if you support GTK_UNIT_PIXEL in gtkprintutils.c.
This is still a problem for us, particularly now that bug 346245 is fixed: java.lang.Error at org.eclipse.swt.graphics.Device.logProc(Device.java:729) at org.eclipse.swt.internal.gtk.OS._gtk_page_setup_get_paper_width(Native Method) at org.eclipse.swt.internal.gtk.OS.gtk_page_setup_get_paper_width(OS.java:8683) at org.eclipse.swt.printing.Printer.internal_new_GC(Printer.java:391) at org.eclipse.swt.graphics.GC.<init>(GC.java:159) at org.eclipse.swt.graphics.GC.<init>(GC.java:125) at printing.tests.HelloWorld.main(HelloWorld.java:46) (SWT:10662): Gtk-WARNING **: Unsupported unit java.lang.Error at org.eclipse.swt.graphics.Device.logProc(Device.java:729) at org.eclipse.swt.internal.gtk.OS._gtk_page_setup_get_paper_height(Native Method) at org.eclipse.swt.internal.gtk.OS.gtk_page_setup_get_paper_height(OS.java:8693) at org.eclipse.swt.printing.Printer.internal_new_GC(Printer.java:392) at org.eclipse.swt.graphics.GC.<init>(GC.java:159) at org.eclipse.swt.graphics.GC.<init>(GC.java:125) at printing.tests.HelloWorld.main(HelloWorld.java:46) (SWT:10662): Gtk-WARNING **: Unsupported unit java.lang.Error at org.eclipse.swt.graphics.Device.logProc(Device.java:729) at org.eclipse.swt.internal.gtk.OS._gtk_page_setup_get_paper_width(Native Method) at org.eclipse.swt.internal.gtk.OS.gtk_page_setup_get_paper_width(OS.java:8683) at org.eclipse.swt.printing.Printer.startPage(Printer.java:549) at printing.tests.HelloWorld.main(HelloWorld.java:54) (SWT:10662): Gtk-WARNING **: Unsupported unit java.lang.Error at org.eclipse.swt.graphics.Device.logProc(Device.java:729) at org.eclipse.swt.internal.gtk.OS._gtk_page_setup_get_paper_height(Native Method) at org.eclipse.swt.internal.gtk.OS.gtk_page_setup_get_paper_height(OS.java:8693) at org.eclipse.swt.printing.Printer.startPage(Printer.java:550) at printing.tests.HelloWorld.main(HelloWorld.java:54) (SWT:10662): Gtk-WARNING **: Unsupported unit java.lang.Error at org.eclipse.swt.graphics.Device.logProc(Device.java:729) at org.eclipse.swt.internal.gtk.OS._gtk_page_setup_get_page_width(Native Method) at org.eclipse.swt.internal.gtk.OS.gtk_page_setup_get_page_width(OS.java:8703) at org.eclipse.swt.printing.Printer.getClientArea(Printer.java:641) at printing.tests.HelloWorld.main(HelloWorld.java:56) (SWT:10662): Gtk-WARNING **: Unsupported unit java.lang.Error at org.eclipse.swt.graphics.Device.logProc(Device.java:729) at org.eclipse.swt.internal.gtk.OS._gtk_page_setup_get_page_height(Native Method) at org.eclipse.swt.internal.gtk.OS.gtk_page_setup_get_page_height(OS.java:8713) at org.eclipse.swt.printing.Printer.getClientArea(Printer.java:642) at printing.tests.HelloWorld.main(HelloWorld.java:56) (SWT:10662): Gtk-WARNING **: Unsupported unit
Sorry about comment 4 - I added it in a hurry. I meant to say "now that bug 346252 is fixed and I can reliably get the printer's resolution"... I have a 'good enough' work-around around now for this problem (GTK_UNIT_PIXEL not supported). I do the math on my side, i.e. now that I know the printer's DPI, I can set the scaling in Cairo before printing. ( x * 72 / printerDPI ) Note that this is still a bug, because your doc says it should work, for example: http://library.gnome.org/devel/gtk/unstable/GtkPageSetup.html#gtk-page-setup-get-paper-width Also, because that's the way all printing works on Windows (pixel units), so supporting it in GTK would make life easier for cross-platform apps.
We're moving to gitlab! As part of this move, we are closing bugs that haven't seen activity in more than 5 years. If this issue is still imporant to you and still relevant with GTK+ 3.22 or master, please consider creating a gitlab issue for it.