This repository has been archived on 2021-09-15. You can view files and clone it, but cannot push or open issues or pull requests.
M2OLA/backend/app/tools/fusion_pdf.py

13 lines
374 B
Python

import os
import PyPDF2
from PyPDF2 import PdfFileReader, PdfFileMerger
files_dir = "C:\\olatest\\app\\pdf"
pdf_files = [f for f in os.listdir(files_dir) if f.endswith("pdf")]
merger = PdfFileMerger()
for filename in pdf_files:
merger.append(PdfFileReader(os.path.join(files_dir, filename), "rb"))
merger.write(os.path.join(files_dir, "merged_full.pdf"))