【问题标题】:Getting the page sizes of a PostScript document获取 PostScript 文档的页面大小
【发布时间】:2013-11-26 02:22:37
【问题描述】:

我想在一个简单的程序或 shell 脚本中获取 PostScript 文档每一页的页面大小。

是否有任何程序或库可以获取页面大小。 (类似于 pdfinfo,但处理 PostScript)

【问题讨论】:

    标签: ghostscript postscript


    【解决方案1】:

    毫无疑问,有一些程序可以做到这一点,但你可以尝试使用 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 过程中添加一些标记可能会有所帮助。

    【讨论】:

      【解决方案2】:

      如果您可以使用 PostScript 级别 2,则可以使用 currentpagedevice

      /pagewidth  currentpagedevice /PageSize get 0 get def
      /pageheight currentpagedevice /PageSize get 1 get def
      

      【讨论】:

      • 答案与接受的答案重复。而且它与我所问的“...在一个简单的程序或 shell 脚本中”不匹配。
      • 很公平。我想我实际上是为了回答一个不同的 SO 问题,或多或少地问同样的事情,减去脚本部分。在答案上,他们混淆了 0 和 1。不幸的是,我混淆了问题:(
      猜你喜欢
      • 2020-03-24
      • 1970-01-01
      • 2020-06-27
      • 1970-01-01
      • 2012-09-16
      • 1970-01-01
      • 2012-09-23
      • 2015-05-13
      • 1970-01-01
      相关资源
      最近更新 更多