Open2
pythonで各ページのサイズが異なるPDFファイルを作る

from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A3, A4, A5, B4, B5, LETTER
from reportlab.lib.units import inch
# 新しいPDFファイルを作成
pdf_file = "multi_size_pages.pdf"
c = canvas.Canvas(pdf_file)
# 1ページ目 (A3サイズ)
c.setPageSize(A3)
c.drawString(100, 700, "This is page 1 (A3)")
c.showPage()
# 2ページ目 (A4サイズ)
c.setPageSize(A4)
c.drawString(100, 800, "This is page 2 (A4)")
c.showPage()
# 3ページ目 (A5サイズ)
c.setPageSize(A5)
c.drawString(100, 600, "This is page 3 (A5)")
c.showPage()
# 4ページ目 (B4サイズ)
c.setPageSize(B4)
c.drawString(100, 700, "This is page 4 (B4)")
c.showPage()
# 5ページ目 (B5サイズ)
c.setPageSize(B5)
c.drawString(100, 600, "This is page 5 (B5)")
c.showPage()
# 6ページ目 (LETTERサイズ)
c.setPageSize(LETTER)
c.drawString(1 * inch, 10 * inch, "This is page 3 (LETTER)")
c.showPage()
# PDFファイルを保存して閉じる
c.save()
print(f"PDFファイル '{pdf_file}' が作成されました。")

pythonは便利