使用ghostscript缩放PDF文件 [英] Scaling PDF file using ghostscript

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

问题描述

我们的系统仅提取8.5 x 11个PDF文件并对它们执行处理.有时,客户将我们的文件交给我们,以使其变形为正确的形状.我们正在努力将非标准尺寸的PDF文件自动缩放到8.5 x 11.

Our system takes 8.5 x 11 PDF files (only) and does things to them. Sometimes customers hand us files to manipulate into the right shape. We're working to automate scaling non-standard sized PDF files into 8.5 x 11.

我们已经能够处理我们用ghostscript测试过的大多数文件,但是我们有一位客户提交的文件无法处理. (很遗憾,我们无法重新创建条件,当然也无法发布客户的数据.)

We've been able to handle most files we've tested with ghostscript, but we have this one customer submitted file that we are unable to handle. (And unfortunately we can't recreate the condition and, of course, can't post the customer's data.)

文件为PDF v1.7,包含七个8.5x11页,其后是四个25.5 x 45.33英寸的页.我不知道它们是如何生成的(每个pdfinfo的Adobe Acrobat 10.1.2).

The file is PDF v1.7 and contains seven 8.5x11 pages followed by four pages that are 25.5 x 45.33 inches. I don't know how they were generated (Adobe Acrobat 10.1.2 per pdfinfo).

我们逐渐在gs命令中添加了一系列参数,直到达到以下要求:

We have gradually added a series of parameters to our gs command until we arrived at this:

gs -sDEVICE=pdfwrite -sOutputFile=$final_file -dBATCH -dNOPAUSE -sPAPERSIZE=letter -q -r720 -g6120x7920 -dPDFFitPage -dFIXEDMEDIA $files_to_convert

这对于其他文件似乎很好用,但对于此一个文件,25.5 x 45.33页未按字母大小缩放.以下是每个pdfinfo对输出文件的第7页和第8页的度量:

This seems to work fine for our other files, but for this ONE file, the 25.5 x 45.33 pages are not scaled to letter size. Here are the measurements for the output file's pages 7 and 8's per pdfinfo:

Page 7 size: 612 x 792 pts (letter) Page 7 rot: 0 Page 8 size: 1836 x 3264 pts Page 8 rot: 0

Page 7 size: 612 x 792 pts (letter) Page 7 rot: 0 Page 8 size: 1836 x 3264 pts Page 8 rot: 0

我已经阅读到PostScript具有策略"和"PageSize"选项,但是我不知道PDF会发生这种情况.而且,如果存在,我不知道如何使用ghostscript进行更改.

I've read that PostScript has Policies, PageSize options, but I'm not aware of such a thing with PDF. And if it exists, I don't know how to alter it using ghostscript.

如何确保所有页面都按字母比例缩放?

How can I make sure all pages are scaled to letter?

推荐答案

好吧,Ghostscript使用PostScript作为其脚本语言,因此您在PostScript中可以执行的任何操作都可以对PDF文件执行.

Well, Ghostscript uses PostScript as its scripting language, so anything you can do in PostScript you can do to a PDF file.

真的不会将-g与pdfwrite一起使用,因为-g指定了 pixels ,并且因为pdfwrite是矢量设备,实际上并不能很好地工作.改用DEVICEHEIGHTPOINTS和DEVICEWIDTHPOINTS.

I really wouldn't use -g with pdfwrite, because -g specifies pixels, and since pdfwrite is a vector device that doesn't really work well. Use DEVICEHEIGHTPOINTS and DEVICEWIDTHPOINTS instead.

也不要设置-sPAPERSIZE,也不能将媒体设置为一个地方是字母,而将其他地方设置为-g开关.

Don't set -sPAPERSIZE either, you can't set the media to be letter in one place and something different (the -g switch) elsewhere.

在没有看到PDF文件的情况下,实际上不可能告诉您它到底发生了什么,并且您还没有真正解释出什么问题.您暗示页面没有缩放,但是您没有说以什么尺寸绘制页面.您也不会说在Acrobat中查看页面时为什么认为页面是合法"大小.

Its not really possible to tell you what's going on exactly with your PDF file without seeing it, and you haven't really explained what's wrong. You imply that the pages are not being scaled, but you don't say what size they are being drawn at. You also don't say why you think the pages are 'legal' size when viewed in Acrobat.

如果您说的是相关网页合法",但媒体要大得多,那么这完全有可能,并建议该网页具有CropBox. Ghostscript将MediaBox用于页面大小,Acrobat使用过多的不同盒子,但通常默认使用CropBox.

If you are saying that the pages in question are 'legal' but the media is much larger, then that is entirely possible and would suggest that the pages have a CropBox. Ghostscript uses the MediaBox for page sizes, Acrobat uses a plethora of different boxes, but usually defaults to the CropBox.

如果您希望Ghostscript使用CropBox,则只需告诉它-dUseCropBox.

If you want Ghostscript to use the CropBox then just tell it -dUseCropBox.

或者将示例张贴在某个地方,我可以看一下.

Alternatively post an example somewhere and I can look at it.

这篇关于使用ghostscript缩放PDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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