Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python split pdf pages

from PyPDF2 import PdfFileWriter, PdfFileReader

inputpdf = PdfFileReader(open("document.pdf", "rb"))

for i in range(inputpdf.numPages):
    output = PdfFileWriter()
    output.addPage(inputpdf.getPage(i))
    with open("document-page%s.pdf" % i, "wb") as outputStream:
        output.write(outputStream)
Comment

split pdf python

import os
from PyPDF2 import PdfFileReader, PdfFileWriter

pdf = PdfFileReader(path)
for page in range(pdf.getNumPages()):
    pdf_writer = PdfFileWriter()
    pdf_writer.addPage(pdf.getPage(page))

    output_filename = '{}_page_{}.pdf'.format(fname, page+1)

    with open(output_filename, 'wb') as out:
        pdf_writer.write(out)

    print('Created: {}'.format(output_filename))
Comment

PREVIOUS NEXT
Code Example
Python :: pandas insert column in the beginning 
Python :: python filter array 
Python :: python sort dictionary alphabetically by key 
Python :: bee movie script 
Python :: django versatileimagefield 
Python :: python flask query params 
Python :: put text on image python 
Python :: draw a line pygame 
Python :: numpy mean 2 arrays 
Python :: how to install python3 in ubuntu 
Python :: find all nan columns pandas 
Python :: convert seconds to hours python 
Python :: check if string url python 
Python :: how to replace a word in csv file using python 
Python :: filter dataframe with list 
Python :: print type of exception python 
Python :: python system year 
Python :: python loop through directory 
Python :: python random 
Python :: find the closest position by time list python 
Python :: get first of current month python 
Python :: py get mouse coordinates 
Python :: read txt file pandas 
Python :: get time taken to execute python script 
Python :: python jwt parse 
Python :: python: transform as type numeirc 
Python :: draw heart with python 
Python :: how to remove coma in python 
Python :: discord.py add reaction to message 
Python :: cv display image in full screen 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =