I need to split a roughly 380 page pdf file into sets of 10 pages using python. My initial thoughts are to use PyPDF2 but I have no experience with it. I do need a mechanism to ensure the final PDF is saved despite it being under 10 pages. (eg. 383 page pdf should save as 38 10-page PDF and a 3 page pdf).
Asked
Active
Viewed 66 times
-1
-
Have you tried reading the PyPDF2 docs to achieve this? – Tom McLean Jun 02 '21 at 15:24
-
Can you please [edit] your question and post your current code? See also [ask]. – Robert Jun 02 '21 at 16:34
-
I was able to use PyPDF2 after looking at the docs, thank you. – Sam Oberly Jun 09 '21 at 19:22
1 Answers
-1
Use pyPDF2 to read the PDF file. Use PdfFileReader.getNumPages()
to get the page count. Split the pages into groups of ten, adding each to a PdfFileWriter
instance. Repeat for any leftover pages.
The basic_features.py
sample code in the pyPDF2 repo makes this pretty clear.

Kevin
- 398
- 2
- 7