【发布时间】:2022-09-26 16:26:25
【问题描述】:
我需要使用 Python 从 pdf 文档中删除文本 \"DRAFT\"。我可以找到包含文本的文本框,但找不到如何使用 pymupdf 编辑 pdf 文本元素的示例。
在下面的示例中,草稿对象包含 DRAFT 文本元素的坐标和文本。
import fitz
fname = r\"original.pdf\"
doc = fitz.open(fname)
page = doc.load_page(0)
draft = page.search_for(\"DRAFT\")
# insert code here to delete the DRAFT text or replace it with an empty string
out_fname = r\"final.pdf\"
doc.save(out_fname)
添加于 2022 年 4 月 28 日 我找到了一种删除文本的方法,但不幸的是,它也会删除 DRAFT 周围框下方的任何重叠文本。我真的只想删除草稿字母而不修改底层
# insert code here to delete the DRAFT text or replace it with an empty string
rl = page.search_for(\"DRAFT\", quads = True)
page.add_redact_annot(rl[0])
page.apply_redactions()
-
在这种情况下,从 ArcGIS Pro 导出的地图,草稿只是覆盖在其他文本上的水平文本元素。我不确定 anylyser 是什么