Skip to content

Commit

Permalink
DOC: Simplify PaperSize examples (#2504)
Browse files Browse the repository at this point in the history
  • Loading branch information
j-t-1 authored Mar 6, 2024
1 parent c7a07ec commit dee4c35
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions docs/modules/PaperSize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,21 @@ Add blank page with PaperSize
.. code-block:: python
:linenos:
from pypdf import PaperSize, PdfReader, PdfWriter
from pypdf import PaperSize, PdfWriter
pdf_reader = PdfReader("sample.pdf")
pdf_writer = PdfWriter()
pdf_writer.append_pages_from_reader(pdf_reader)
pdf_writer.add_blank_page(PaperSize.A8.width, PaperSize.A8.height)
writer = PdfWriter(clone_from="sample.pdf")
writer.add_blank_page(PaperSize.A8.width, PaperSize.A8.height)
with open("output.pdf", "wb") as output_stream:
pdf_writer.write(output_stream)
writer.write(output_stream)
Insert blank page with PaperSize
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
:linenos:
from pypdf import PaperSize, PdfReader, PdfWriter
from pypdf import PaperSize, PdfWriter
pdf_reader = PdfReader("sample.pdf")
pdf_writer = PdfWriter()
pdf_writer.append_pages_from_reader(pdf_reader)
pdf_writer.insert_blank_page(PaperSize.A8.width, PaperSize.A8.height, 1)
writer = PdfWriter(clone_from="sample.pdf")
writer.insert_blank_page(PaperSize.A8.width, PaperSize.A8.height, 1)
with open("output.pdf", "wb") as output_stream:
pdf_writer.write(output_stream)
writer.write(output_stream)

0 comments on commit dee4c35

Please sign in to comment.