如何将 PDF 文件中的页面图像向左或向右移动?
我们有一堆扫描页面(大约 600 个),每个 PDF 查看器都显示右边缘零边距的图像,但左边缘大约 2 英寸边距。 (大概是在扫描时使用了错误的设置......)
我们想要打印这些页面,最好是作为小册子。有没有办法永久地将所有页面图像移向中心,并使 PDF 以更令人满意的方式显示这些页面? Ghostscript 能做到吗?可以用其他方法来做到这一点,例如在某些 PDF 处理库的帮助下以编程方式实现吗?
We have a bunch of scanned pages (about 600) for which every PDF viewer displays the image with zero margin on the right edge, but about 2 inch margin on the left. (Presumably while scanning, there was a wrong setting used...)
We want to print these pages, preferably as a booklet. Is there a way to permanently shift all page images towards the center and have the PDF display these pages also in a more pleasing way? Can Ghostscript do that? Can one do this with some other method, such as programatically with the help of some PDF processing library?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您不想编写自己的程序代码(如 Nikolaus 建议的那样),而是使用 Ghostscript 命令行,则需要了解 3 件事:
setpagedevice
运算符,它接受PageOffset
参数;-c ...
传递 PostScript 代码片段,Ghostscript 将处理它们;现在尝试此命令行将所有页面图像向左移动 1 英寸(==72pt):
(我放入的
-dPDFSETTINGS=/prepress
是为了不丢失任何图片质量扫描...)If you don't want to write your own program code (as Nikolaus suggested), but use a Ghostscript commandline instead, you need to know 3 things:
setpagedevice
operator that takes aPageOffset
parameter;-c ...
on the commandline;Now try this commandline to shift all page images by 1 inch (==72pt) to the left:
(The
-dPDFSETTINGS=/prepress
I put in in order to not loose any picture quality of the scans...)您可以使用 iText 移动、缩放或裁剪 pdf 页面,
您需要为源文件定义 PdfReader,为目标文件定义文档
然后,如果读者在文档中创建一个新页面,则迭代页面
并将 sourcePage 作为模板添加到新页面(随心所欲地移动、缩放等)
you can use iText to move, scale or crop pdf-pages
you need to define a PdfReader for your source file, and a Document for your Target file
then you iterate over the pages if the Reader, create a new page in the Document
and add the sourcePage as a Template to the new page (shifting, scaling etc wherever you want)