The PaperSize Class
- class pypdf.PaperSize[source]
Bases:
object
(width, height) of the paper in portrait mode in pixels at 72 ppi.
- A0 = Dimensions(width=2384, height=3370)
- A1 = Dimensions(width=1684, height=2384)
- A2 = Dimensions(width=1191, height=1684)
- A3 = Dimensions(width=842, height=1191)
- A4 = Dimensions(width=595, height=842)
- A5 = Dimensions(width=420, height=595)
- A6 = Dimensions(width=298, height=420)
- A7 = Dimensions(width=210, height=298)
- A8 = Dimensions(width=147, height=210)
- C4 = Dimensions(width=649, height=918)
Add blank page with PaperSize
1from pypdf import PaperSize, PdfWriter
2
3writer = PdfWriter(clone_from="sample.pdf")
4writer.add_blank_page(PaperSize.A8.width, PaperSize.A8.height)
5with open("output.pdf", "wb") as output_stream:
6 writer.write(output_stream)
Insert blank page with PaperSize
1from pypdf import PaperSize, PdfWriter
2
3writer = PdfWriter(clone_from="sample.pdf")
4writer.insert_blank_page(PaperSize.A8.width, PaperSize.A8.height, 1)
5with open("output.pdf", "wb") as output_stream:
6 writer.write(output_stream)