- PDF read 할 수 있는 패키지 설치
pip install PyPDF2
Collecting PyPDF2
Downloading pypdf2-3.0.1-py3-none-any.whl (232 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 232.6/232.6 kB 5.2 MB/s eta 0:00:00a 0:00:01
Installing collected packages: PyPDF2
Successfully installed PyPDF2-3.0.1
pip install PdfMerger
Requirement already satisfied: PdfMerger in ./anaconda3/lib/python3.10/site-packages (0.5.0)
Requirement already satisfied: PyPDF2 in ./anaconda3/lib/python3.10/site-packages (from PdfMerger) (3.0.1)
- 한 폴더에 PDF 파일 몰아넣고, Read 해서 concat
from PyPDF2 import PdfFileMerger, PdfMerger
# import PdfMerger
import os, tqdm
file_path = '/Users/hjkim/Desktop/integrate_pdf/'
pdf_list = [x for x in os.listdir(file_path) if x[-3:]=='pdf']
print('PDF FILES: {}'.format(len(pdf_list)))
merger = PdfMerger()
for pdf in tqdm.tqdm(pdf_list):
merger.append(file_path + pdf)
merger.write(file_path + "integrated_file.pdf")
merger.close()
'Python Code' 카테고리의 다른 글
Config 파일 관리 (argparse) (0) | 2023.10.10 |
---|---|
Cut-off 별 Sensitivity(민감도), Specificity(특이도) 성능 측정 코드 (0) | 2023.10.10 |
pytorch 딥러닝 학습/평가 코드 (0) | 2023.09.27 |
Docker 자주 쓰는 명령어 정리 (0) | 2023.09.23 |
Config 파일 관리 (yaml) (0) | 2023.09.19 |