in workflow3_local/local_docsplitter.py [0:0]
def create_output_pdfs(input_pdf_path, pages_by_class, output_dir_path, output_dir_name):
# loops through each class in the pages_by_class dictionary to get all of the input PDF page numbers
# creates new PDF for each class using the corresponding input PDF's pages
# outputted multi-class PDFs are located in the output folder
with open(input_pdf_path, "rb") as f:
for _class in pages_by_class:
output = PdfFileWriter()
page_numbers = pages_by_class[_class]
input_pdf = PdfFileReader(f)
for page_num in page_numbers:
output.addPage(input_pdf.getPage(page_num))
with open(f"{output_dir_path}/{_class}.pdf", "wb") as output_stream:
output.write(output_stream)
print(f"Created PDF for {_class}")