开发者

Aligning two PDFs for a merge using Cairo and pyPDF

开发者 https://www.devze.com 2022-12-21 00:28 出处:网络
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 sta

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 PDFSu开发者_StackOverflow社区rface 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?


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消