[cairo] Printing/Creating PDf/Postscript

Adrian Johnson ajohnson at redneon.com
Thu Jun 3 16:18:06 PDT 2010

On 04/06/10 05:24, Jeff Hallock wrote:
> How can write this code, so the print_text function prints the same size
> on the print operation and a cairo surface that I create myself.

The default units for the gtk print context are GTK_UNIT_PIXEL, an
unhelpful unit for printing. Using the gtk_print_operation_set_unit()
function to set the units to GTK_UNIT_POINTS should fix the problem.

The longer explanation is that the units used by the PDF and PS surfaces
are points (1/72 inch). The gtk print context scales the units to be
GTK_UNIT_PIXEL. On Linux GTK_UNIT_PIXEL units are always 1/72 inch.
On Windows GTK_UNIT_PIXEL units are the GDI device units which for
printers is the dpi resolution. So for a 600dpi printer 1 unit
is 1/600".

More information about the cairo mailing list