Split PDF to single pages with simple Python script

Pubblicato il: 09 agosto 2022
sul canale di: Rafal Kobus
432
8

Rafal Kobus

  / rafa%c5%82-kobus-b6051314b  

from PyPDF2 import PdfFileReader, PdfFileWriter
import os
import sys
import glob
abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)

if getattr(sys, 'frozen', False):
_location_ = os.path.dirname(os.path.realpath(sys.executable))
elif __file__:
_location_ = os.path.realpath(
os.path.join(os.getcwd(), os.path.dirname(__file__)))

for file in glob.glob(__location__ + "/*.pdf"):
if file.endswith('.pdf'):
pdf_file = open(os.path.join(__location__, file), 'rb')
pdf_reader = PdfFileReader(pdf_file)

pageNumbers = pdf_reader.getNumPages()

for i in range (pageNumbers):
pdf_writer = PdfFileWriter()
pdf_writer.addPage(pdf_reader.getPage(i))
split_motive = open('Page ' + str(i+1) + '.pdf', 'wb')
pdf_writer.write(split_motive)
split_motive.close()

pdf_file.close()

#PyPDF2 #PDF #Python


In questa pagina del sito puoi guardare il video online Split PDF to single pages with simple Python script della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Rafal Kobus 09 agosto 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 432 volte e gli è piaciuto 8 spettatori. Buona visione!