在 Python 中提取 PDF 水印详细信息
Contents
[
Hide
]
在 Python 中读取 PDF 首页水印工件的文本和边界矩形。
读取水印文本和边界矩形
输出子类型为 WATERMARK 的每个分页工件的文本和边界矩形。
import aspose.pdf as ap
def extract_watermark_from_pdf(infile):
with ap.Document(infile) as document:
watermarks = [
artifact
for artifact in document.pages[1].artifacts
if artifact.type == ap.Artifact.ArtifactType.PAGINATION
and artifact.subtype == ap.Artifact.ArtifactSubtype.WATERMARK
]
for watermark in watermarks:
print(f"{watermark.text} {watermark.rectangle}")