且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用python(和matplotlib?)将页面附加到现有的pdf文件中

更新时间:2022-04-21 00:48:05

您可能要使用 pyPdf 一个>为此.

# Merge two PDFs
from PyPDF2 import PdfFileReader, PdfFileWriter

output = PdfFileWriter()
pdfOne = PdfFileReader(open("path/to/pdf1.pdf", "rb"))
pdfTwo = PdfFileReader(open("path/to/pdf2.pdf", "rb"))

output.addPage(pdfOne.getPage(0))
output.addPage(pdfTwo.getPage(0))

outputStream = open(r"output.pdf", "wb")
output.write(outputStream)
outputStream.close()

从此处获取的示例

因此,您可以将绘图从pdf合并中分离出来.

Thereby you detach the plotting from the pdf-merging.