使用 Cairo 和 pyPDF 对齐两个 PDF 进行合并

发布于 2024-08-22 04:52:36 字数 220 浏览 4 评论 0原文

我需要以编程方式将其他图形元素添加到现有的静态 PDF 书籍封面上。现在,我使用 pycairo 在透明 PDFSurface 上绘图,然后使用 pyPdf 将其合并到现有的静态 PDF 中。这样,PDFSurface 就可以作为叠加层使用。

然而,透明PDF与静态PDF的TrimBox大小完全相同,因此比静态PDF小。如何将内容放置在透明 PDF 上,以便合并后它恰好覆盖静态 PDF 的 TrimBox?

I need to programmatically add additional graphical elements onto an existing, static PDF book cover. Right now I use pycairo to draw onto a transparent PDFSurface, then merge it into the existing static PDF using pyPdf. This way, the PDFSurface works as an overlay.

However, the transparent PDF is exactly the same size as the static PDF's TrimBox, thus being smaller than the static PDF. How do I position the content on the transparent PDF so that after merging, it exactly overlays the static PDF's TrimBox?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁月蹉跎了容颜 2024-08-29 04:52:36

正如所料,这是一个简单的数学问题。事实证明,我在对齐 PDF 框时遇到的麻烦是由于我对框坐标的错误解释造成的:
PDF 框坐标是相对坐标还是绝对坐标?

As would be expected, this was a matter of simple math. It turns out the trouble I was having with aligning the PDF boxes was caused by my wrong interpretation of the box coordinates:
Are PDF box coordinates relative or absolute?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文