in reply to Printing a TK Canvas

From the perl/Tk FAQ:
11.7. How do I get a Canvas to output PostScript(c)? Many thanks to Tom Oelke <tpo9617@rit.edu> for providing this questio +n, answer & snippet of code: The following section of code gets the postscript code for the secti +on of canvas that's top-left corner is at $min_x, $min_y, and has a width +and height equivalent to the displayed region. This ps code is then pipe +d out to lpr to be printed. my $ps = $canvas->postscript( '-x' => $min_x, '-y' => $min_y, -width => $canv->Width, -height => $canv->Height); open (PS, "| lpr"); # customize with -Pname e.g. print PS $ps; close (PS); Whereas you would use something like: open (PS, ">file.ps"); # to output to a file print PS $ps; close (PS);
Update: A better explanation: the first bit of code sends the canvas data in postscript form to a (unix) printer lpr. The second bit of code creates a postscript file that you can send to the printer directly via
% lpr file.ps
or you can open it with ghostscript to print it on a non-postscript printer.

-Mark

Replies are listed 'Best First'.
Re: Re: Printing a TK Canvas
by Anonymous Monk on Apr 16, 2004 at 21:07 UTC
    but! that doesnt do anything does it ? just prints it to the screen, or to a file. It doesnt print it (hard copy) whatsoever! Maybe i have misunderstood?