I have a list of Matplotlib figures that are saved as bytes in pdf format and base64 encoded. I wish to save these figures to a PDF file with the following code:
with open('result.pdf', 'wb') as f:
for fig in f_list:
f.write(base64.b64decode(fig))
The file is created successfully but it seems like only the last figure is saved to the file. What am I doing wrong??
popplerinstalled? You could usepdfuniteif you did.wboverwrites the file. You can append withab, but that doesn't fix your problem. That appends bytes. If you want to add pages to a PDF, then you'll need a Python library that knows how to do that.