在 Python 中缩小和合并 PDF
我正在尝试将两个 A4 PDF 页面缩小并合并为一个 A4 页面,这样如果我有的话;
_____ _____
| | | |
| p1 | | p2 |
| | | |
|_____| |_____|
我会得到;
_____
| p1 |
|.....|
| p2 |
|_____|
作为新的 PDF,其中一页上有两个 A5 大小的页面。类似于在纸上每页打印两页的方式。
我研究过 pypdf 和 ReportLab 但我似乎找不到如何像这样缩小和合并。
有什么提示吗?
谢谢!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
pdfnup 有此功能(http://pypi.python.org/pypi/pdfnup)#
例如
pdfnup has this functionality (http://pypi.python.org/pypi/pdfnup)#
e.g.
我的方法(不一定是最好的方法,但使用我可用的工具)是使用 Ghostcript 的
pdf2ps
转换为 PostScript,然后附加一个 N-up PostScript 序言(PS 是完整的编程语言,您可以重新定义“showpage”等内置函数,以将 N-up 或海报化直接添加到文档中),然后我会使用ps2pdf
转换回来。我暂时没有找到 PostScript N-up 实用程序的发布版本,但是您可以在 google 上搜索几个用其他语言编写的操作 PostScript 文档本身的实用程序,例如http://www.tardis.ed.ac.uk/~ajcd/psutils/
The way I would do it (not necessarily the best way, but using tools I have available) would be to use Ghostcript's
pdf2ps
to convert to PostScript, then append an N-up PostScript preamble (PS is a full programming language and you can redefine builtins like "showpage" to add N-up or posterization directly to a document) and then I'd convert back withps2pdf
.Offhand I'm not finding a published version of a PostScript N-up utility, but you can google several ones written in other languages that manipulate the PostScript document itself, such as those at http://www.tardis.ed.ac.uk/~ajcd/psutils/