I would like to append pages to an existing pdf file.
Currently, I am using matplotlib pdfpages. however, once the file is closed, saving another figure into it overwrites the existing file rather than appending.
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()
I know appending is possible via multiple calls to pdf.savefig() before calling pdf.close() but I would like to append to pdf that has already been closed.
Alternatives to matplotlib would be appreciated also.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…