From 59d64b32ba33754c119e437cba2baafa8fd814d8 Mon Sep 17 00:00:00 2001 From: Sitan Coulibaly Date: Fri, 20 Jan 2017 11:12:10 +0000 Subject: [PATCH] TG-46 ajout fusion_pdf.py Fichier de fusion des documents pdf --- backend/app/fusion_pdf.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 backend/app/fusion_pdf.py diff --git a/backend/app/fusion_pdf.py b/backend/app/fusion_pdf.py new file mode 100644 index 0000000..1447f78 --- /dev/null +++ b/backend/app/fusion_pdf.py @@ -0,0 +1,12 @@ +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"))