CropBox的GhostScript问题 [英] GhostScript issues with a CropBox

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

问题描述

我正在尝试使用ghostscript将CropBox添加到pdf中.我使用以下代码:

I am trying to add a CropBox to a pdf with ghostscript. I use the following code:

gs -sDEVICE=pdfwrite -o output.pdf -c "[/CropBox [100.00 100.00 200.00 200.00] /PAGES pdfmark" -f input.pdf

问题在于,使用某些pdf它将创建适当的CropBox,但是对于其他pdf则无法执行任何操作.

The problem is that with some pdf's it will create a proper CropBox, but with others it fails to do anything.

失败的pdf文件已经具有一个现有的TrimBox,并且在我的代码行之后已删除了TrimBox.但这不能创建正确的CropBox.

The pdf's that fail already have a existing TrimBox, and after my line of code the TrimBox has been removed. But it doesn't create a correct CropBox.

我没有收到来自GhostScript的错误,但这是行不通的.

I get no errors from GhostScript, it just doesn't work.

有人知道我在做什么错吗?

Does anybody have an idea what I'm doing wrong?

推荐答案

在没有看到示例PDF文件的情况下,很难分辨....

Without seeing an example PDF file, its rather hard to tell....

请注意(重复演讲....)您正在做的是不是添加CropBox".当您通过Ghostscript处理输入(无论输入是PDF,PS,PCL,XPS ...)时,它将被完全解释为图形基元.这些原语将传递到Ghostscript设备,该设备决定如何处理它们.对于渲染设备,它们使用图形库将图形渲染为位图.对于高级设备(例如pdfwrite),原语将转换为所需格式的适当操作,并以文件格式适当包装后发出.

Please note (repetitive lecture....) what you are doing is not 'adding a CropBox'. When you process input through Ghostscript (whatever the input is, PDF, PS, PCL, XPS...) it is completely interpreted into graphics primitives. These primitives are passed to the Ghostscript device, which decides what to do with them. In the case of rendering devices they use the graphics library to render the graphics to a bitmap. In the case of the high level devices, such as pdfwrite, the primitives are converted into suitable operations for the desired format and emitted suitably wrapped up in a a file format.

所以......输出的PDF文件与输入没有任何共同之处,只是它在外观上应该是相同的. PDF解释程序将某些PDF元数据(即非标记内容)转换为pdfmark操作,并以这种方式发送到设备,而某些高级设备会将部分内容嵌入其输出中,因此最可能的情况是在解释PDF文件之前,您提供的pdfmark操作会被PDF解释器根据PDF文件的内容生成的更高版本的pdfmark覆盖.

So.... The output PDF file has nothing in common with the input, except that it should appear visually the same. Some PDF metadata (ie non-marking content) is converted into pdfmark operations by the PDF interpreter, and sent to the device that way, and some high level devices will embed some part of that in their output, so the most likely situation is that the pdfmark operation you are supplying before the PDF file is interpreted is overridden by later pdfmarks generated by the PDF interpreter in response to the content of the PDF file.

主要要点是您没有将CropBox添加到现有PDF中.您正在使用CropBox创建一个全新的PDF,并且该PDF文件的内容与原始文件没有任何共同之处.

The main point is that you aren't adding a CropBox to an existing PDF< you are creating a brand new PDF with a CropBox, and the content of that PDF file has nothing in common with the original file.

如果您发布一个示例PDF文件,您会遇到麻烦,但如果没有该文件,我将无法确定真正的原因.

If you post an example PDF file you are having trouble with I can look at it, but without that I can't tell what the actual reason is.

这篇关于CropBox的GhostScript问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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