Course Content
Manipulating and Combining PDFs
Manipulating and Combining PDFs
Swipe to show menu
Add Page
add_page()
is a PyPDF2
function that allows developers to add new pages to an existing PDF document. It's useful for creating reports, adding new content to an existing document, and modifying the structure of a PDF file. With add_page()
, developers can automate the process of adding new pages to a PDF document in Python.
Let's add the first page from sample.pdf to a new file out.pdf and compress the page content in 2 times.
The sample.pdf content:
Task
Swipe to show code editor
- Read in a PDF called
"sample.pdf"
; - Select the page at index 0 and scale it by 0.5;
- Write the PDf to a file called
"out.pdf"
.
Solution
The <out.pdf> file:
Mark tasks as Completed
Switch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?
Thanks for your feedback!
Section 1. Chapter 6
AVAILABLE TO ULTIMATE ONLY