GtkPrintOperation and margins



Hi,

I have an app that prints text to a printer, and was using code based on
Microsoft's print_mswin.c code sample (actually originally cribbed from the
Ethereal source code) in its Win32 port, and with no real printing support
in its Linux version. So I just spent a day rewriting that to use
GtkPrintOperation, and it's all working very nicely, except for one small
problem:

I set the top and left margins to one inch, and then start the print output
with:
  cairo_move_to(cr, 0, 0);
  pango_cairo_show_layout(cr, layout);

But the text is printed with top and left margins that are about one and a
quarter inches. The same shows up when I print to a PDF (using PdfFactory
Pro) so it's not the printer that's doing it. The code that sets the margins
to 1" is this, with the topMargin and leftMargin variables each set to 1.0:

  /* Set the margins */
  pageSetup = gtk_page_setup_new();
  gtk_page_setup_set_top_margin(pageSetup, topMargin, GTK_UNIT_INCH);
  gtk_page_setup_set_left_margin(pageSetup, leftMargin, GTK_UNIT_INCH);
  gtk_page_setup_set_bottom_margin(pageSetup, btmMargin, GTK_UNIT_INCH);
  gtk_print_operation_set_default_page_setup(print, pageSetup);

When I do the same with the old print_mswin.c code the one inch margins
print at exactly one inch. But that code includes allowing for the print
device's non-printable area by reducing the margins a little:
  btmMargin -= GetDeviceCaps(hdc, PHYSICALOFFSETY);
  leftMargin -= GetDeviceCaps(hdc, PHYSICALOFFSETX);

So, do I need to do the same here, and is there some equivalent call in GTK
to get the print device's physical offsets to the start of the printable
area?

Note that this is happening in the Win32 port. Whether the same happens
under Linux I don't know (I currently have FC5 which has GTK 2.8, or
thereabouts, so no GtkPrintOperation). I can find out shortly as I'm about
to upgrade it to FC6.

Thanks
Ian






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