Skip to content

Commit

Permalink
Update deprecated command (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccollins22 authored Oct 28, 2024
1 parent 343c81b commit 90929ab
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions artistools/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,18 +1003,18 @@ def movavgfilterfunc(ylist: t.Any) -> t.Any:

def merge_pdf_files(pdf_files: list[str]) -> None:
"""Merge a list of PDF files into a single PDF file."""
from pypdf import PdfMerger
from pypdf import PdfWriter

merger = PdfMerger()
merger = PdfWriter()

for pdfpath in pdf_files:
with Path(pdfpath).open("rb") as pdffile:
merger.append(pdffile) # type: ignore[attr-defined]
merger.append(pdffile)
Path(pdfpath).unlink()

resultfilename = f"{pdf_files[0].replace('.pdf', '')}-{pdf_files[-1].replace('.pdf', '')}"
with Path(f"{resultfilename}.pdf").open("wb") as resultfile:
merger.write(resultfile) # type: ignore[attr-defined]
merger.write(resultfile)

print(f"Files merged and saved to {resultfilename}.pdf")

Expand Down

0 comments on commit 90929ab

Please sign in to comment.