5

要将外部 EPS 文件插入 PostScript 文档,指示使用文本编辑器打开 EPS 文件并在 PostScript 文件中复制/粘贴基于文本的数据。

我想知道是否有一种标准方法可以将外部 EPS 文件包含在 PostScript 文档中?我的意思是链接到 EPS 文件,因为 PS 可以在运行 PostScript 文档时捕获并读取其内容。我读过一些关于run命令的东西,但不知道如何使用它在主 PostScript 文档中包含外部 EPS 文件。

更新:将 EPS 图像插入为

%!PS-Adobe-3.0

/Times-Roman findfont
14 scalefont setfont

72 700 moveto
(Thi is a text) show

72 300 translate
(1.eps)run

72 100 moveto
(Another text bellow image) show
showpage

它发送到下一页。在此示例中,第二个文本转到第 2 页,而不是显示在位置 )72 100。

4

3 回答 3

5

由于您扩展了原始问题,因此我最好添加另一个答案...

首先,不要%!PS-Adobe-3.0在第一行使用(它表示您的文件符合某个标准,但它不这样做)。仅使用%!PS(甚至仅使用%!)。

其次,您必须确保您的1.eps文件确实是有效的EPS。由于你不包括你的1.eps,我无法检查这个。

第三,不,这不是translate导致创建新页面的语句——这个翻译本身在语法上是可以的(取决于你想要达到的效果)。

第四,您的EPS不应该使用showpage运算符,否则我在其他答案中给出的简单行将无法单独工作。如果 EPS 本身弹出,您需要在运行 EPS之前将运算符showpage重新定义为无操作,并在运行后恢复原始语义:showpageshowpage

save
/showpage {} bind def
(my.eps) run
restore

第五,第二个文字不一定出现在EPS下方。根据 EPS 的实际尺寸,它很可能会打印在 EPS 的空间中。

第六,第一个文本可能被 EPS 的笔触和填充覆盖(取决于 EPS 的实际绘图大小),因此可能根本不存在。

第七,真正的 PostScript 大师(我不是其中之一),可能会找到 第 0、第8条、第 9 条、第 10条甚至更多关于这个主题的项目来指出...... ;-)

于 2012-09-04T00:34:55.007 回答
3

假设您的 EPS 文件与您的主 PostScript 文件位于同一目录中,并且名为my.eps. 然后您可以将此行放入 PostScript 文件的代码中:

(my.eps) run

你必须弄清楚这条线应该在哪个确切位置产生想要的效果。可能就在showpage操作员之前是一个不错的起点。

于 2012-09-03T21:10:39.753 回答
3

为了帮助您更深入地了解 EPS,请运行以下命令(根据您自己的情况调整路径):

sudo gs                                                  \
  -o /opt/local/share/ghostscript/9.05/examples/tigr.eps \
  -sDEVICE=epswrite                                      \
   /opt/local/share/ghostscript/9.05/examples/tiger.eps

然后考虑这个示例 PostScript 文件,名为so#12253041.ps

%!

/Times-Roman findfont 14 scalefont setfont

% Page 1
72 680 moveto (This is a text on page 1) show

72 200 translate
save
.5 .5 scale
  /showpage {} bind def
  (/opt/local/share/ghostscript/9.05/examples/tigr.eps) run
2 2 scale
restore

72 100 moveto (Another text \(across image\)) show
showpage


% Page 2
72 680 moveto (This is a text on page 3...) show

.5 .5 scale
72 200 translate
save
  /showpage {} bind def
  (/opt/local/share/ghostscript/9.05/examples/tigr.eps) run
restore
2 2 scale

72 100 moveto
(Another text \(across image\)) show
showpage


% Page 3
72 680 moveto (This is more text on page 3. But it is not visible... Why?) show

.25 .25 scale
72 200 translate
save
  /showpage {} bind def
  (/opt/local/share/ghostscript/9.05/examples/tiger.eps) run
restore
4 4 scale

72 100 moveto
(Another text \(across image\)) show
showpage


% Page 4 (empty)
showpage

并运行:

gs -o so#12253041.pdf -sDEVICE=pdfwrite so#12253041.ps

Last,

  1. ...try to understand what happens in each line of the PS;
  2. ...take into account the differences in the code for each page (also the order of operators);
  3. ...also look at the differences between the two EPS files.
于 2012-09-04T07:41:21.380 回答