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?
精彩评论