将图片放置在PDF上
问题描述:
如何将图像放在特定位置的现有PDF文件上. pdf代表一页的图纸.图像将被缩放.我正在检查ReportLab,但找不到答案.谢谢.
How can I place an image over an existing PDF file at an specific coordinate location. The pdf represents a drawing sheet with one page. The image will be scaled. I'm checking ReportLab but can't find the answer. Thanks.
答
from pyPdf import PdfFileWriter, PdfFileReader
output = PdfFileWriter()
input1 = PdfFileReader(file("document1.pdf", "rb"))
watermark = PdfFileReader(file("watermark.pdf", "rb"))
input1.mergePage(watermark.getPage(0))
# finally, write "output" to document-output.pdf
outputStream = file("document-output.pdf", "wb")
output.write(input1)
outputStream.close()
我认为它类似于watermark
,有关详细信息,请参见手册
I think it's like watermark
, see the manual for better idea