【发布时间】:2013-11-26 02:22:37
【问题描述】:
我想在一个简单的程序或 shell 脚本中获取 PostScript 文档每一页的页面大小。
是否有任何程序或库可以获取页面大小。 (类似于 pdfinfo,但处理 PostScript)
【问题讨论】:
我想在一个简单的程序或 shell 脚本中获取 PostScript 文档每一页的页面大小。
是否有任何程序或库可以获取页面大小。 (类似于 pdfinfo,但处理 PostScript)
【问题讨论】:
毫无疑问,有一些程序可以做到这一点,但你可以尝试使用 Ghostscript:
gs -q -sDEVICE=nullpage -dBATCH -dNOPAUSE \
-c '/showpage{currentpagedevice /PageSize get{=}forall showpage}bind def' \
-f test.ps
但是您可能需要过滤掉任何警告或 DSC cmets。例如。我发现的一个测试文件给了我这个:
%%[ ProductName: GPL Ghostscript ]%%
(Warning: Job contains content that cannot be separated with on-host methods. Th
is content appears on the black plate, and knocks out all other plates.)
595.28
841.89
%%[Page: 1]%%
%%[LastPage]%%
在您重新定义的showpage 过程中添加一些标记可能会有所帮助。
【讨论】:
如果您可以使用 PostScript 级别 2,则可以使用 currentpagedevice:
/pagewidth currentpagedevice /PageSize get 0 get def
/pageheight currentpagedevice /PageSize get 1 get def
【讨论】: