This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This script consist of: | |
* Collect Pdf Files from uploads folder | |
* Split Pdf Files page by page. | |
* Save Splitted pdf pages to output Folder. | |
""" | |
import os | |
from PyPDF2 import PdfFileReader, PdfFileWriter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from PyPDF2 import PdfFileReader, PdfFileWriter | |
#Solution based in two functions: | |
#1.pdf remove : Remove existed pdf documents(result for your last split operation) | |
#2.pdf splitter : Split your main pdf document into group of documents. | |
def pdf_remove (length): | |
for i in range(length): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
from PyPDF2 import PdfFileWriter, PdfFileReader | |
def merger(output_path, input_paths): | |
pdf_writer = PdfFileWriter() | |
for path in input_paths: | |
pdf_reader = PdfFileReader(path) | |
for page in range(pdf_reader.getNumPages()): | |
pdf_writer.addPage(pdf_reader.getPage(page)) | |
with open(output_path, 'wb') as fh: | |
pdf_writer.write(fh) |