Skip to content

Latest commit

 

History

History
21 lines (14 loc) · 476 Bytes

20240711112142.md

File metadata and controls

21 lines (14 loc) · 476 Bytes

merge PDF files

TIL how to merge PDF files in Python -> the pypdf library makes this really easy:

from itertools import islice
from pathlib import Path

from pypdf import PdfWriter

with PdfWriter() as merger:
    files = (Path.home() / "code" / "articles" / "outputs").glob('*.pdf')
    for file in islice(files, 3):
        merger.append(file)
    merger.write("output.pdf")

Source project where I found this: https://github.com/ahmedlemine/pdf-merger

#pdf