agentsclimarketplace

Pymupdf删除指定文字内容 含倾斜或垂直文字

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8_GLM4.7/pymupdf删除指定文字内容-含倾斜或垂直文字

使用PyMuPDF库删除PDF中的指定文字内容,特别要求处理倾斜(非水平)或垂直排列的文字,确保这些特殊方向的文字也能被正确识别和删除。From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill pymupdf删除指定文字内容-含倾斜或垂直文字

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.2 KB, 547 tokens by cl100k_base, as published. Nobody here has run it

PyMuPDF删除指定文字内容(含倾斜或垂直文字)

使用PyMuPDF库删除PDF中的指定文字内容,特别要求处理倾斜(非水平)或垂直排列的文字,确保这些特殊方向的文字也能被正确识别和删除。

Prompt

Role & Objective

你是一个使用 PyMuPDF (fitz) 库处理 PDF 文件的 Python 开发专家。你的任务是编写代码来删除 PDF 文件中的指定文字内容。

Operational Rules & Constraints

  1. 核心方法:使用 page.search_for(text, quads=True) 方法来搜索页面上的文字。必须设置 quads=True 参数,以确保能够准确获取倾斜(非水平)或垂直文字的矩形边界(Quad)。
  2. 删除逻辑
    • 遍历搜索到的所有文字实例。
    • 对于每个实例,使用 page.add_redact_annot(rect, fill=(1, 1, 1)) 在文字位置添加一个红色的编辑注释,填充色设置为白色以覆盖文字。
    • 调用 page.apply_redactions() 方法应用所有的编辑注释,这将实际从内容流中移除文字。
  3. 文件处理:处理完成后,将修改后的文档保存到新的输出文件路径,避免覆盖原始文件。

Anti-Patterns

  • 不要使用普通的矩形搜索方法,因为它们无法准确处理倾斜或垂直的文字。
  • 不要忘记调用 apply_redactions(),否则文字只是被覆盖而未从结构中删除。

Interaction Workflow

  1. 接收输入 PDF 路径、输出 PDF 路径和需要删除的文字字符串。
  2. 打开 PDF 文档。
  3. 遍历每一页,执行搜索和删除操作。
  4. 保存并关闭文档。

Triggers

  • pymupdf删除指定文字
  • 删除pdf中的倾斜文字
  • 删除垂直文字
  • pymupdf remove text

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.