Home > Back-end >  I have two excel list with different PDF's that need to be merged. Is there anyway to merge the
I have two excel list with different PDF's that need to be merged. Is there anyway to merge the

Time:11-17

I have two Excel list indicating the path of PDF files that I need to merge- Is there anyway to do this using code? As the manual process takes hours to process.

I've tried using VBA but IO don't have access to adobe API, so that's been stuck down. I am thinking python, any thoughts?

CodePudding user response:

Python is the way to go.

You can do this quite easily by using the pandas and PyMuPDF libraries.

# pip install PyMuPDF
import pandas as pd
import fitz

PDFs = pd.read_excel(«pdfs.xlsx»)
new_pdf = fitz.open()  

for row in PDFs.iterrows():
    filename = row[«pdf_column»]
    in_pdf = fitz.open(filename)

    new_pdf.insert_pdf(in_pdf)

new_pdf.save("merged.pdf")

CodePudding user response:

Check out PyPDF2

Example from pypdf2.readthedocs.io

from PyPDF2 import PdfMerger

merger = PdfMerger()

for pdf in ["file1.pdf", "file2.pdf", "file3.pdf"]:
    merger.append(pdf)

merger.write("merged-pdf.pdf")
merger.close()
  • Related