I created all three PDFs and checked them. The one oddity is that the bullet characters in terms.pdf come out as (cid:127) when extracted.
Files (in the working folder, built by scripts/make.py, checked by scripts/check.py):
invoice.pdfis 1 page. It has a title for "Northwind Sample Co" and three line items, and everything is marked as sample.terms.pdfis 1 page. It has the heading "Sample Terms" and three bullet terms.combined.pdfis 2 pages, with the invoice first and the terms second. That matches 1 + 1 pages.
Text extracted from combined.pdf
- Page 1 has the invoice title, the "fictional / made-up sample data" note, the table rows, and the "SAMPLE - not a real invoice." footer.
- Page 2 has "Sample Terms" and the three terms: payment due in 30 days, 1% monthly late fee, and goods remaining sample property until paid. Each one is marked "(sample term)".
Table extracted from page 1 (one table found):
| Item | Qty | Unit Price | Amount |
|---|---|---|---|
| Sample Widget | 10 | $5.00 | $50.00 |
| Sample Gadget | 2 | $25.00 | $50.00 |
| Sample Service Hour | 4 | $30.00 | $120.00 |
| Total | $220.00 |
Verification: The line items add up: 50 + 50 + 120 = 220, which matches the stated total. The extracted table has the same 5 rows and 4 columns I built, with no merged or missing cells.
Problem: pdfplumber reads the bullet glyph as (cid:127) instead of "•". That is how the built-in Helvetica font encodes the bullet, so it is probably an extraction quirk and the bullets should display normally. I haven't rendered the pages, so I can't confirm how they look. If clean extracted text matters to you, I can switch to a plain "-" marker.
Test run: two sample one-page PDFs built with reportlab, merged with pypdf, then read back with pdfplumber, in a temporary folder. The run was allowed to write files and run python3 only. I re-opened the files myself: 1 + 1 pages merged into 2, and the table text matched. The model flagged that the bullet glyph extracts as (cid:127). Pages were not rendered, so appearance was not checked. All content is sample.
하는 일
널리 쓰이는 세 라이브러리를 씁니다. 구조(병합, 분할, 순서 변경, 회전, 양식, 메타데이터)는 pypdf, 텍스트와 표는 pdfplumber, 새 PDF 생성은 reportlab입니다. 먼저 각 입력을 살펴보고(쪽수, 크기, 암호화, 양식 필드, 쪽마다 추출 가능한 글자 수로 스캔 페이지를 일찍 발견), 작업을 실행한 뒤, 각 결과물을 다시 열어 쪽수, 텍스트 샘플, 양식 값, 파일 크기를 확인합니다. 추출 가능한 글자가 없는 페이지는 OCR이 필요하다고 알리고, 추출한 표가 믿기 어려울 수 있으면 경고합니다. 보호된 PDF는 사용할 권리가 있는 파일에 대해 비밀번호를 주었을 때만 열며 보호를 풀려고 시도하지 않습니다.
결과물
새 PDF 파일과 만든 스크립트, 바뀐 내용, 확인 결과, 스캔 페이지나 글꼴 누락 같은 문제.
이런 때 좋습니다
문서 병합과 분할, 보고서의 표 추출, 워터마크와 쪽 번호 넣기, 양식 채우기, 간단한 청구서나 보고서 생성.
중간 위험:지침만 있는 파일로 자체 스크립트는 없지만, Python을 쓰고 실행해 작업 폴더에 파일을 만들며 가상 환경에 pypdf, pdfplumber, reportlab 설치를 권할 수 있습니다. 원본을 덮어쓰지 않고 비밀번호 보호를 풀려 하지 않습니다. 임시 폴더에서 샘플 PDF로 한 번 시험했고 PDF 두 개를 만들어 병합하고 표를 제대로 추출했습니다. 글머리표 기호는 추출 시 (cid:127)로 나왔고 페이지를 그리지 않아 겉모습은 확인하지 못했습니다. AIBars 제작(MIT).