[Tkinter-discuss] Multipage Postscript printing from canvas

Vasilis Vlachoudis Vasilis.Vlachoudis at cern.ch
Tue Feb 20 12:04:17 CET 2007


Hi all,

 

In my application I am creating an editor using a scrollable canvas as
the main widget. I want to provide a print option for the canvas,
creating a multi-page A4/letter format postscript. I made the following
method to split the content of the canvas into many postscript files,
which will be later send to the printer or joined together to a single
file, but I have many problems.

1.	How do I create an A4 or letter format page?
2.	What is the conversion between pixels in the Canvas and points
in the postscript?
3.	What is the best way to split the pages?
4.	How do I merge everything into a multi-page postscript?

 

class InputCanvas(Canvas):

            ...

            def printer(self,filename):

                        bbox =
map(int,self.canvas.cget("scrollregion").split())

                        if bbox is None: return

                        (x,y,w,h) = bbox

                        height = 1000                # For the moment
arbitrarily chosen!

                        for y in range(0,h,height):

                                    self.canvas.postscript(

                                                file=filename+str(y),

                                                colormode="color",

                                                y=y)

                                                #pageheight=12*96)

 

 

Vasilis

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20070220/c1a87454/attachment.htm 


More information about the Tkinter-discuss mailing list