Python에서 PDF 배경 제거

Python에서 PDF 첫 페이지의 배경 아티팩트를 제거합니다.

배경 아티팩트 제거

삭제하기 전에 하위 유형이 BACKGROUND인 페이지 매김 아티팩트를 모으세요.

import aspose.pdf as ap

def remove_background(infile, outfile):
    with ap.Document(infile) as document:
        backgrounds = [
            artifact
            for artifact in document.pages[1].artifacts
            if artifact.type == ap.Artifact.ArtifactType.PAGINATION
            and artifact.subtype == ap.Artifact.ArtifactSubtype.BACKGROUND
        ]

        for background in backgrounds:
            document.pages[1].artifacts.delete(background)

        document.save(outfile)

관련 항목