Printing



Dear list,

In lack of a complete printing tutorial, I wrote one myself. There are still some open questions though. My objective is to get consistent output of text and graphics on screen, in PDF and printed on paper, cross platform. All drawing code is in one function, which should not need to know the properties of the current device. I do that by scaling the cairo context so user space units are in millimeters.

You will find the code attached, these are the issues:

1) In order to get approximately correctly scaled text I had to specify a resolution of around 27.2 on the pango context. This value was determined by trial and error. I suspect I am doing something fundamentally wrong, and I would like to know how to render text the way the font designer inteded it. I have tried scaling only graphics and not text, but even then text was much too big.

2) The printed font seems a little heavy. This may be due to the scaling issue above.

3) Some letters seem to be placed too close to each other. On my Linux screen with the Sans font this is most notable between the r and o in "brown" and o and x in "fox". On Windows the problems are at other places. I have tried to rule out hinting problems by switching off all hinting.

4) When trying to print under Linux, nothing happens. No print job is spooled. No message on the console. I can produce a preview which looks OK. Not sure whether this is because GTK+ assumes some command line tool to be present, like lpr. CUPS is operational on my system.

5) When printing under Windows to an HP LaserJet (PCL and PS) there is a positive offset of a few millimeters both horizontally and vertically. Printing the PDF is OK.

6) When printing under Windows to an HP LaserJet, the cairo_rectangle is not printed. It is when printing the PDF.

7) When printing under Windows to a Canon inkjet, the bounding rectangle of graphics (not text) is filled black (auch!). The PDF is printed OK. On the laserjet the bounding box is first cleared to white, visible when the example on [1] is printed.

8) When exporting to PDF on Windows, trying to overwrite an existing file, the program crashes (oops!). This works fine on Linux.

9) The issue of margins. I know that the margins dealt with in the API are intended to be used as printer margins, not document margins. However, on Windows it is natural to use them as document margins, because the interface to modifying them appears on a high level, directly in the page setup dialog. These can be modified independently from the paper dimensions, and the graphical representation gives the user the impression of adjusting document margins, with dynamically updated lines printed inside a dashed rectangle. The label does not inform the user either that the margins presented are supposed to be printer margins, and why would a user be interested to adjust these indeed? In most cases the user is only interested in document margins, and these should be limited to the printer margins which should stay outside the user's control. On Linux the interface is quite different, here using these margins as document margins makes no sense. The interface to adjusting these margins is nested on a deeper level, and is coupled to the definition of a custom paper size. So the user cannot define the margins without defining a custom paper size. It is my feeling that there is confusion between "paper setup" and "page setup". Linux implements "paper setup" with printer margins that are dependent on the printer and paper size, and Windows implements "page setup" with a choice of paper size and document margins. I think the Linux implementation is more correct (although the name GtkPageSetup is misleading), and that the exposure of the margins on Windows is a mistake. As it is, I think the page setup dialog is unsuitable not be used in cross platform applications. However, a widget for adjusting document margins like the current Windows presentation would be nice, but then consistent accross platforms.


I hope we can work out all these issues, so the community can have a working tutorial and I can get on with my project :-) Probably I should file a bug for some of these issues, but maybe the list can correct my errors first...

Thanks,
Bastiaan.

[1] http://library.gnome.org/devel/gtk/stable/GtkPrintContext.html


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]