原文:
11.7. How do I get a Canvas to output PostScript(c)?
Many thanks to Tom Oelke mailto: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);
译文:
11.7. 如何把画布中的内容输出成PostScript文件?
非常感谢Tom Oelke提供了这个问题、答案和代码片断:
下面的这段代码将一个画布组件($canvas)的一部分输出成了一段postscript代码,此部分是以$min_x,$min_y坐标点为左上角,宽度和高度都等于画布显示的宽度和高度的区域中的内容。然后,这个PS的代码被直接输送给了lpr来进行打印。
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);
然而,你也许会希望保存成文件:
open (PS, ">file.ps"); # to output to a file
print PS $ps;
close (PS);