gtk_print confusion



Hello,

I recently added printing support to a program I've written and I'm using gtkPrint for it. My hardcopy output is fairly simple. It is a single page with a header across the top, a footer across the bottom and some simple figures (drawn with cairo) and text (via pango) on the page.

The problem I'm having is when I print under NetBSD my header is cut off. It looks like maybe an inch or more is missing.

When I build my program under win32, I get the correct height but the right hand side of my page is cut off.

This all leads me to think that I am somehow confused about units, margins, and perhaps others.

My basic sequence is

operation = gtk_print_operation_new();
gtk_print_operation_set_use_full_page (operation, FALSE);

/* is a point here a postscript point, i.e. 72 per inch? */
gtk_print_operation_set_unit (operation, GTK_UNIT_POINTS);

later in my callback I have

cr = gtk_print_context_get_cairo_context (context);
width = gtk_print_context_get_width (context);
height = gtk_print_context_get_height (context);

at this point is it true that cairo_move_to (cr, 0, 0) should position me at the top left corner of my imagable area? Is it also true that cairo_move_to (cr, width, height) will position me at the bottom right corner of my imagable area? How does it know what paper size I've picked? Maybe this is the ultimate source of my problems?


When I do things like

layout = gtk_print_context_create_pango_layout (context);

and set the markup and then do

pango_layout_get_pixel_size (layout, &text_width, &text_height);

will I get back a width and height in the same units as what my cairo calls are taking?


The only other question I have is really more of a comment. The way I'm taking data from my program and laying it out for printing is in a way where I don't know how many pages I might have until I actually render the pages. This makes it tough to set the number of pages before printing each individual page. Luckily I've dodged the issue because currently I only have enough output to use a single page but if someone used much smaller paper, that might not be true. Is there a "standard" way of doing pagination? Its almost like I need a way to run my 'draw_page()' call back in a "paginate" mode where it doesn't actually produce output, but I can put up text and graphics, get there sizes and keep track of when I have filled a page.

Thanks much for any suggestions.
-Dan






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