Ghostscript删除了裁剪框之外的内容? [英] Ghostscript removes content outside the crop box?

查看:95
本文介绍了Ghostscript删除了裁剪框之外的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用ghostscript 9.10时遇到了麻烦,显然是从裁剪框的外部删除了内容(特别是我放在那里的裁剪标记)

I'm having troubles with ghostscript 9.10 apparently removing content outside of the crop box (specifically the crop marks I've put there)

这是使用ghostscript之前的PDF: with_cropbox_before_optimize.pdf

This is the PDF before using ghostscript: with_cropbox_before_optimize.pdf

$ pdfinfo -box with_cropbox_before_optimize.pdf
  MediaBox:           0.00     0.00   651.97   898.58
  CropBox:           28.35    28.35   623.62   870.24

设置查看器以显示整个媒体框将按预期方式在裁切框外部显示裁切标记. (有黑色边框说明了裁剪框的位置)

Setting the viewer to display the entire media box shows the crop marks outside of the crop box as expected. (the black border is there to illustrate where the crop box would be)

然后我打电话:

gs -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dCompatibilityLevel=1.7 \
-dNOPAUSE -dQUIET -dBATCH -dAutoRotatePages=/None -sOutputFile=<out.pdf> <in.pdf>

产生以下文件: with_cropbox_after_optimize.pdf

现在裁剪标记丢失了,或者至少不再显示了-页面尺寸仍然可以,因此它没有被裁剪或其他任何东西...

Now the crop marks are missing or at least they are no longer being displayed - the page dimensions are still fine however, so it hasn't cropped it or something...

$ pdfinfo -box with_cropbox_after_optimize.pdf
  MediaBox:           0.00     0.00   651.97   898.58
  CropBox:           28.35    28.35   623.62   870.24

所以:我做错了还是这是个错误?

So: Am I doing it wrong or is this a bug?

推荐答案

要理解的第一件事(我知道我一直在提这个,但是人们不理解)是Ghostscript和pdfwrite并不会简单地与您的PDF纠缠在一起.忽悠.

The first thing to understand (I know I keep mentioning this, but people don't understand it) is that Ghostscript and pdfwrite are not simply twiddling with your PDF fikle.

解释输入的PDF文件,并将PDF标记操作转换为内部图形基元,然后将其通过Ghostscript设备接口传递.通常,这些原语然后呈现为位图.在使用pdfwrite的情况下,原语将重新转换为PDF标记操作,并从中组合出一个全新的PDF文件.输出与输入无关,除了其视觉外观.

The input PDF file is interpreted and the PDF marking operations are converted into internal graphical primitives which are then passed through the Ghostscript device interface. In general these primitives are then rendered to a bitmap. In the case of pdfwrite, the primitives are reconverted into PDF marking operations, and a brand new PDF file assembled from them. The output bears no relation to the input, other than its visual appearance.

因此,当您使用Ghostscript处理PDF文件时,并不是在优化"它,而是在创建一个全新的PDF文件.

So when you process your PDF file with Ghostscript you are not 'optimising' it, you are creating a brand new PDF file.

在您的情况下,不会解释CropBox外部的对象(因为它们在CropBox外部,因此会对其进行裁剪).显然,它们没有通过设备接口传递,因此不存在于输出PDF文件中.

In your case the objects outside the CropBox are not interpreted (because they are outside the CropBox, they are cropped). As an obvious result they are not passed through the device interface, and therefore not present in the output PDF file.

请注意,尽管Ghostscript裁剪到CropBox,但这不会影响MediaBox,因此媒体仍然相同,但是裁剪的对象被裁剪了.您可以使用-dUseCropBox将媒体更改为与CropBox相同,但这不是您想要的.

Note that while Ghostscript crops to the CropBox, that doesn't affect the MediaBox, so the media is still the same but cropped objects are cropped out. You can use -dUseCropBox to alter the media to be the same as the CropBox, but that's not what you want.

此刻我看不到CropBox转换为剪辑的位置,因此,您最好的解决方案可能是在没有CropBox的情况下创建文件(或将其删除,或将其设置为MediaBox),然后添加它在处理文件时使用pdfmark.

Right at the moment I can't see where the CropBox is converted into a clip, so your best solution is probably to create the file without a CropBox (or remove it, or set it to the MediaBox) and then add it in using a pdfmark when processing the file.

这篇关于Ghostscript删除了裁剪框之外的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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