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 :: smtp python set subject 
Python :: python runserver port 
Python :: Python write value in next row of existing .text file 
Python :: install poetry on linux 
Python :: python how to play mp3 file 
Python :: csv file sort python 
Python :: sort and reverse list in python 
Python :: creating an apis with python and flask 
Python :: lambda function dataframe 
Python :: 2d arrays using python numpy 
Python :: migrations.rename_field django 
Python :: what does % do in python 
Python :: np.random.exponential 
Python :: serialization in django 
Python :: random.uniform python 
Python :: download folder collab 
Python :: Rectangle with python 
Python :: create pandas dataframe 
Python :: how to add captcha in django forms 
Python :: sort dictionary by key 
Python :: duplicates in python list 
Python :: Shapes (None, 1) and (None, 5) are incompatible 
Python :: cuda memory in pytorch 
Python :: random seed generator minecraft 
Python :: gensim show_topics get topic 
Python :: how to define a class in python 
Python :: restrict ticks to integers matplotlib 
Python :: making your own range function in python 
Python :: input function python 
Python :: python select from list by condition 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =