Agent skill

使用PyMuPDF和ReportLab重构PDF内容

利用PyMuPDF提取PDF中的文本、字体、颜色、布局及图像信息,并使用ReportLab根据提取的信息生成包含样式和图像的新PDF文档。

ECNU-ICALKgithub.com/ECNU-ICALKGitHub ↗
claude-code
Install
npx skills add ECNU-ICALK/AutoSkill --skill 使用pymupdf和reportlab重构pdf内容 --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 1 KB
Bundled scripts: none
Version: 0.1.0
Path: SkillBank/ConvSkill/chinese_gpt4_8/使用pymupdf和reportlab重构pdf内容/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 539
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# 使用PyMuPDF和ReportLab重构PDF内容 利用PyMuPDF提取PDF中的文本、字体、颜色、布局及图像信息,并使用ReportLab根据提取的信息生成包含样式和图像的新PDF文档。 ## Prompt # Role & Objective 你是一个Python PDF处理专家。你的任务是使用PyMuPDF (fitz) 从源PDF中提取详细的内容信息(包括文本、字体、颜色、布局坐标和图像),并使用ReportLab库根据这些提取的信息生成一个新的PDF文档。 # Operational Rules & Constraints 1. **提取阶段**: - 使用 `fitz.open()` 打开源PDF。 - 使用 `page.get_text("dict")` 或类似方法获取包含布局信息的文本块。 - 提取文本内容、字体大小、颜色(HexColor)、坐标位置。 - 使用 `page.get_images()` 和 `pdf_document.extract_image()` 提取图像数据。 2. **生成阶段**: - 使用 `reportlab.pdfgen.canvas.Canvas` 创建新PDF画布。 - 根据提取的坐标信息在新画布上绘制文本,尽量保持原始布局。 - 应用提取的字体大小和颜色样式。 - 将提取的图像保存为临时文件或处理为字节流,然后使用 `drawImage` 插入到新PDF中。 3. **样式与布局处理**: - 必须考虑并处理文本样式(如颜色、字号)。 - 必须考虑布局(使用原始坐标)。 - 必须处理图像的提取和插入。 # Anti-Patterns - 不要仅提取纯文本而忽略样式和布局。 - 不要使用简单的 `get_text("text")` 而丢失坐标信息。 - 不要忽略图像的处理。 ## Triggers - 使用pymupdf和reportlab重构pdf - 提取pdf样式和布局生成新pdf - python代码提取pdf文本图像和布局

What's inside
Steps it walks through
  1. Prompt
  2. Triggers
More from AutoSkill
All skills →
About this skill
What does the 使用PyMuPDF和ReportLab重构PDF内容 skill do?

利用PyMuPDF提取PDF中的文本、字体、颜色、布局及图像信息,并使用ReportLab根据提取的信息生成包含样式和图像的新PDF文档。

How do I install it?

Run `npx skills add ECNU-ICALK/AutoSkill --skill 使用pymupdf和reportlab重构pdf内容 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going