기존 PDF 문서에서 표 제거
Contents
[
Hide
]
PDF 문서에서 표 제거
파이썬용 Aspose.PDF 파일을 사용하면 PDF에서 테이블을 제거할 수 있습니다.기존 PDF를 열고 첫 페이지의 첫 번째 테이블을 다음과 같이 감지합니다. TableAbsorber, 를 사용하여 해당 테이블을 삭제합니다. remove()를 클릭하고 업데이트된 PDF를 새 파일에 저장합니다.
표를 많이 사용하는 PDF를 정리하거나, 오래된 표 형식 내용을 제거하거나, 재배포하기 전에 문서를 단순화해야 할 때 이 페이지를 사용하십시오.
import aspose.pdf as ap
from os import path
import sys
def remove_one_table(infile: str, outfile: str) -> None:
# Load existing PDF document
document = ap.Document(infile)
# Create TableAbsorber object to find tables
absorber = ap.text.TableAbsorber()
# Visit first page with absorber
absorber.visit(document.pages[1])
# Get first table on the page
table = absorber.table_list[0]
# Remove the table
absorber.remove(table)
# Save PDF
document.save(outfile)
PDF 문서에서 모든 표 제거
라이브러리를 사용하면 PDF의 특정 페이지에서 모든 표를 제거할 수 있습니다.코드는 기존 PDF를 열고, TableAbsorber를 사용하여 두 번째 페이지의 모든 테이블을 탐지하고, 감지된 테이블을 반복하고, 각 테이블을 제거한 다음 수정된 PDF를 새 파일에 저장합니다.나머지 PDF 내용은 그대로 두고 페이지에서 표를 대량으로 제거해야 할 때 유용합니다.
import aspose.pdf as ap
from os import path
import sys
def remove_all_tables(infile: str, outfile: str) -> None:
# Load existing PDF document
document = ap.Document(infile)
# Create TableAbsorber object to find tables
absorber = ap.text.TableAbsorber()
# Visit first page with absorber
absorber.visit(document.pages[1])
# Loop through the copy of collection and removing tables
tables = list(absorber.table_list)
for table in tables:
absorber.remove(table)
# Save document
document.save(outfile)