Bootstrap

批量合并PDF

import os
from PyPDF2 import *

path = r'C:\Users\HP\Desktop\'  # pdf目录文件
pdf_lst = [f for f in os.listdir(path) if f.endswith('.pdf')]
pdf_lst = [os.path.join(path, filename) for filename in pdf_lst]

file_merger = PdfMerger()
for pdf in pdf_lst:
    file_merger.append(pdf,import_outline=False)     # 合并pdf文件

file_merger.write(r"C:\Users\HP\Desktop\合并文件.pdf")

;