Программирование: Объединение PDF-файлов с помощью PyPDF2…

Sign up for ДуровЛох to chat with friends, comment and like posts.
Signup
Объединение PDF-файлов с помощью PyPDF2

Установите библиотеку с помощью pip.

pip install PyPDF2

Вы можете легко объединить PDF-файлы, используя приведенный ниже код. Просто замените имена в списке pdf-файлов на имена pdf-файлов, которые вы хотите объединить (если они находятся в том же каталоге, что и ваш Python-скрипт), или на ссылки на pdf-файлы.

import PyPDF2

def merge files (pdf files: list):
# Create a PDF merger obiect
pdf merger = PyPDF2.PdfFileMerger ()
# Loop through the list and append each PDF to the merger
for pdf_file in pdf_files:
pdf_merger.append(pdf_file)
# Output file for the merged PDF
output_pdf = "merged_file.pdf"
pdf_merger.write(output_pdf)
pdf_merger.close()

# List of PDF files to merge
pdf_files = @Bookflow
Comments 0
No comments yet