我想將頁面附加到現有的pdf文件。使用python(和matplotlib?)向現有的pdf文件添加頁面
目前,我正在使用matplotlib pdfpages。但是,一旦文件關閉,保存另一個數字將覆蓋現有文件而不是追加。
from matplotlib.backends.backend_pdf import PdfPages
import matplotlib.pyplot as plt
class plotClass(object):
def __init__(self):
self.PdfFile='c:/test.pdf'
self.foo1()
self.foo2()
def foo1(self):
plt.bar(1,1)
pdf = PdfPages(self.PdfFile)
pdf.savefig()
pdf.close()
def foo2(self):
plt.bar(1,2)
pdf = PdfPages(self.PdfFile)
pdf.savefig()
pdf.close()
test=plotClass()
我知道追加是可能通過多次調用pdf.savefig()調用pdf.close()之前,但我想追加到已經關閉PDF格式。
替代matplotlib將不勝感激。