10.6. How do I get a Canvas to output PostScript(c)?

Many thanks to Tom Oelke <tpo9617@rit.edu> for providing this question, answer & snippet of code:

The following section of code gets the postscript code for the section 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 piped 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);

Previous | Return to table of contents | Next