Re: printing content of goocanvasmm



Hi Klaus,

You will need to set the number of pages to 4 first:

        operation->set_n_pages(4);

Then the signal_draw_page handler will be called 4 times, with the second argument being the page number 
(zero based).
Based on the page number, you should be able to determine the Bounds that should be used for the current page.

Best,

Tom

On 29 Dec 2017, at 15:00, Klaus <lts-rudolph gmx de> wrote:

Hi Tom,


The Canvas documentation mentions a method render 
(https://developer.gnome.org/goocanvasmm/stable/classGoocanvas_1_1Canvas.html#a54aa434b9bfa110dc74e1435b9a6f81d),
 which can be used to draw the canvas onto a cairo context of your choosing.

here I have still a problem: If I want to split up my canvas to multiple print pages, how can I shift the 
rendering to the page position 0,0? The render method offers a "Bounds" parameter which works like a 
clipping rect over the drawing area. But now I need that this area is shifted to a other position in the 
cairo context.

eg. have a canvas with 200x200 in size. Printing is in 100x100 pages.
So I need for page 2 that area 100,0 is printed in the printer context on 0x0. Any idea how that can be 
performed?

I think you can use this method from a Gtk::PrintOperation’s signal_draw_page handler, where the cairo 
context can be fetched from the printcontext using get_cairo_context.

Yes, I found that and has already forwarded the call to on_draw. That works also but can not handle areas 
to print. Great finding! Thanks!


I explained a similar workflow in 
https://tschoonj.github.io/blog/2015/07/05/embedding-plplot-in-gtk-drawingareas/ where you can send the 
contents of a Gtk::DrawingArea to either a file or a printer.


I will take a look into!

Thanks
Klaus



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