1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Pythonで複数のPDFファイルを結合する方法

Last updated at Posted at 2023-05-24

プログラムについて

スキャンしたPDFを1つのPDFにまとめるためのプログラムです.

環境

  • Python 3.8.10

プログラム

パス名は自分の環境に合わせて変更してください.

コメント欄でご指摘いただいた通り,プログラムに冗長な部分があったため修正しました(2023/5/25)

merge.py
import glob
from PyPDF2 import PdfMerger

merge = PdfMerger()

for filename in sorted(glob.glob('*.pdf')):
    merge.append(filename)
    print(filename)

merge.write('merge.pdf')

merge.close()

実行方法

python3 merge.py

実行結果

merge.pdfというファイルが出力されているはずです.

1
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?