I have 2 different pdf plots (generated by matplotlib also) and I'd like to combine them as one side-by-side. Originally I wanted to generate with 2 subplots 121 and 122 but then was too tricky to adjust many details. So I generated two independent plots.
Is there any way to import those ready pdfs and just make one out of them? Because at the end in a latex file which I am using, it is much easier to deal with one figure file rather than two!
Thank you!
如果您使用的是Linux或Mac,则pdfjam程序可以执行此操作。
pdfjam --nup 2x1 leftFig.pdf rightFig.pdf --outfile combinedFig.pdf
I would save the plots as PNGs and then create a PDF out the PNGs using ReportLab. For example:
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter
c = canvas.Canvas('report.pdf', pagesize=letter)
c.drawImage('filename1.png', 0,0)
c.drawImage('filename2.png', 0,100)
c.save()
http://www.reportlab.com/apis/reportlab/2.4/pdfgen.html
Or if you're set on merging multiple PDFs than that's already been answered here: Merge PDF files or you can merge image directly using PIL see here: How do you merge images into a canvas using PIL/Pillow? .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.