使用 GhostScript 获取页面大小 [英] Using GhostScript to get page size

查看:19
本文介绍了使用 GhostScript 获取页面大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 GhostScript 获取页面大小(例如来自 PDF 文档页面)?我见过bbox"设备,但它返回边界框(每页不同),而不是 PDF 页面的 TrimBox(或 CropBox).(有关信息,请参阅 http://www.prepressure.com/pdf/basics/page_boxes关于页面框.)还有其他可能吗?

Is it possible to get the page size (from e.g. a PDF document page) using GhostScript? I have seen the "bbox" device, but it returns the bounding box (it differs per page), not the TrimBox (or CropBox) of the PDF pages. (See http://www.prepressure.com/pdf/basics/page_boxes for info about page boxes.) Any other possibility?

推荐答案

同时我找到了一个不同的方法.这个只使用 Ghostscript(就像你需要的那样).无需额外的第三方实用程序.

Meanwhile I found a different method. This one uses Ghostscript only (just as you required). No need for additional third party utilities.

这个方法使用了一个小助手程序,用 PostScript 编写,随 Ghostscript 的源代码一起提供.在 toolbin 子目录中查找 pdf_info.ps 文件.

This method uses a little helper program, written in PostScript, shipping with the source code of Ghostscript. Look in the toolbin subdir for the pdf_info.ps file.

包含的注释说你应该像这样运行它以列出使用的字体、使用的媒体大小

The included comments say you should run it like this in order to list fonts used, media sizes used

gswin32c -dNODISPLAY ^
   -q ^
   -sFile=____.pdf ^
   [-dDumpMediaSizes] ^
   [-dDumpFontsUsed [-dShowEmbeddedFonts]] ^
   toolbin/pdf_info.ps

我确实在本地示例文件上运行了它,命令行参数只要求媒体大小(而不是使用的字体).结果如下:

I did run it on a local example file, with commandline parameters that ask for the media sizes only (not the fonts used). Here is the result:

C:> gswin32c ^
      -dNODISPLAY ^
      -q ^
      -sFile=c:downloads\_IXUS_850IS_ADVCUG_EN.pdf ^
      -dDumpMediaSizes ^
      C:/gs8.71/lib/pdf_info.ps


  c:downloads\_IXUS_850IS_ADVCUG_EN.pdf has 146 pages.
  Creator: FrameMaker 6.0
  Producer: Acrobat Distiller 5.0.5 (Windows)
  CreationDate: D:20060817164306Z
  ModDate: D:20060822122024+02'00'

  Page 1 MediaBox: [ 595 842 ] CropBox: [ 419.535 297.644 ]
  Page 2 MediaBox: [ 595 842 ] CropBox: [ 297.646 419.524 ]
  Page 3 MediaBox: [ 595 842 ] CropBox: [ 297.646 419.524 ]
  Page 4 MediaBox: [ 595 842 ] CropBox: [ 297.646 419.524 ]
  [....]

这篇关于使用 GhostScript 获取页面大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆