在 Python 中删除 PDF 背景
Contents
[
Hide
]
在 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)