agentleFS
GalokPengGalokPeng/galokpeng.github.io/skills/_sources/pdf/SKILL.md

pdf

Skill4 starsChanged 6 days agoMITView on GitHub

Read, create, inspect, render, and verify PDF files where visual layout matters, including fillable AcroForms. Use Poppler rendering plus Python tools such as reportlab, pdfplumber, and pypdf for generation and extraction.

  • Installs packages

195 other projects use a version of this, 7 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use gift-evaluator, Podcast Generate and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • dav-niu474Skill

    gift-evaluator

    The PRIMARY tool for Spring Festival gift analysis and social interaction generation. Use this skill when users upload photos of gifts (alcohol, tea, supplements, etc.) to inquire about their value, authenticity, or how to respond socially. Integrates visual perception, market valuation, and HTML card generation.

    Also in 5 projects that use this

  • dav-niu474Skill

    Podcast Generate

    Generate podcast episodes from user-provided content or by searching the web for specified topics. If user uploads a text file/article, creates a dual-host dialogue podcast (or single-host upon request). If no content is provided, searches the web for information about the user-specified topic and generates a podcast. Duration scales with content size (3-20 minutes, ~240 chars/min). Uses z-ai-web-dev-sdk for LLM script generation and TTS audio synthesis. Outputs both a podcast script (Markdown) and a complete audio file (WAV).

    Also in 5 projects that use this

  • huang-x-hSkill

    Video Generation

    Implement AI-powered video generation capabilities using the z-ai-web-dev-sdk. Use this skill when the user needs to generate videos from text prompts or images, create video content programmatically, or build applications that produce video outputs. Supports asynchronous task management with status polling and result retrieval.

    Also in 6 projects that use this

  • huang-x-hSkill

    VLM

    Implement vision-based AI chat capabilities using the z-ai-web-dev-sdk. Use this skill when the user needs to analyze images, describe visual content, or create applications that combine image understanding with conversational AI. Supports image URLs and base64 encoded images for multimodal interactions.

    Also in 6 projects that use this

  • Liang-MHSkill

    stock_analysis

    获取 A 股、基金和港股的实时行情和技术分析数据

    Also in 5 projects that use this

  • SeifBenayedSkill

    file-reading

    Use this skill when a file has been uploaded but its content is NOT in your context — only its path at /mnt/user-data/uploads/ is listed in an uploaded_files block. This skill is a router: it tells you which tool to use for each file type (pdf, docx, xlsx, csv, json, images, archives, ebooks) so you read the right amount the right way instead of blindly running cat on a binary. Triggers: any mention of /mnt/user-data/uploads/, an uploaded_files section, a file_path tag, or a user asking about an uploaded file you have not yet read. Do NOT use this skill if the file content is already visible in your context inside a documents block — you already have it.

    Also in 6 projects that use this

  • +1 more from huang-x-h
  • +2 more from dav-niu474

The file

Show its rules and text

We split this skill into the rules it gives an agent

21 rules. 0 are common, 14 are distinctive, and 7 are very specific to this project.

  • 0

    Common

    Most of the 181 edited versions we read keep these.

  • 14

    Distinctive

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read or review PDF content where layout and visuals matter.

    line 10
  2. Distinctive:

    Create PDFs programmatically with reliable formatting.

    line 11
  3. Distinctive:

    Prefer visual review: render PDF pages to PNGs and inspect them.

    line 17
  4. Very specific:

    Use pdftoppm from the bundled runtime or system Poppler when available.

    line 18
  5. Distinctive:

    If unavailable, install Poppler or ask the user to review the output locally.

    line 19
  6. Very specific:

    Use reportlab to generate PDFs when creating new documents.

    line 20
  7. Very specific:

    Use pdfplumber or pypdf for text extraction and quick checks.

    line 21
  8. Distinctive:

    After each meaningful update, re-render pages and verify alignment, spacing, and legibility.

    line 22
  9. Very specific:

    Keep the result interactive by default.

    line 42
  10. Very specific:

    Use tmp/pdfs/ for intermediate files.

    line 88
  11. Very specific:

    Write final artifacts under output/pdf/ when working in this repo.

    line 89
  12. Distinctive:

    Keep filenames stable and descriptive.

    line 90
  13. Distinctive:

    Prefer the Codex bundled workspace/runtime dependencies when available.

    line 94
  14. Distinctive:

    If a dependency is missing, install only what is needed.

    line 99
  15. Very specific:

    If uv is unavailable:

    line 107
  16. Distinctive:

    If installation is not possible in this environment, tell the user which dependency is missing and how to install it locally.

    line 123
  17. Distinctive:

    No required environment variables.

    line 127
  18. Distinctive:

    Avoid rendering issues: clipped text, overlapping elements, broken tables, black squares, or unreadable glyphs.

    line 138
  19. Distinctive:

    Use ASCII hyphens only. Avoid U+2011 and other Unicode dashes.

    line 140
  20. Distinctive:

    Do not deliver until the latest PNG inspection shows zero visual or formatting defects.

    line 145
  21. Distinctive:

    Keep intermediate files organized or remove them after final approval.

    line 147

“Common” is measured: kept by at least 6 in 10 of the 181 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

PDF Skill

When To Use

  • Read or review PDF content where layout and visuals matter.
  • Create PDFs programmatically with reliable formatting.
  • Fill and validate interactive PDF forms.
  • Validate final rendering before delivery.

Workflow

  1. Prefer visual review: render PDF pages to PNGs and inspect them.
    • Use pdftoppm from the bundled runtime or system Poppler when available.
    • If unavailable, install Poppler or ask the user to review the output locally.
  2. Use reportlab to generate PDFs when creating new documents.
  3. Use pdfplumber or pypdf for text extraction and quick checks; do not rely on text extraction for layout fidelity.
  4. After each meaningful update, re-render pages and verify alignment, spacing, and legibility.

Preserve Chinese, Japanese, and Korean text

For an editable HTML report and its PDF, print the same HTML with its print styles and fonts when browser printing is available. If the fallback draws text with PyMuPDF and embeds a Noto CJK OpenType/CFF face, start from the original face for each weight. When subsetting with FontTools before embedding, retain the glyph IDs. Its default subset renumbers glyphs while the CFF character IDs retain their original values. The PDF can then extract the intended text and paint unrelated glyphs or blank space.

from fontTools import subset

subsetter = subset.Subsetter(options=subset.Options(retain_gids=True))
subsetter.populate(text=all_drawn_text)  # Include headings, labels and page numbers.
subsetter.subset(face)

For this PyMuPDF fallback, save and embed the resulting face. Poppler can display the intended text even when other viewers paint the wrong glyphs. Reopen the final PDF in PyMuPDF, render a page containing each font and weight with page.get_pixmap(), and read a representative source phrase in the saved images. If any characters differ from the source, regenerate with the original face or an embedded TrueType font covering the text and check the images again.

Fill And Validate AcroForms

Visual review alone is not a correctness check for a fillable PDF. A page /Widget annotation can render a value from its appearance stream while the canonical /AcroForm/Fields tree is missing or contains a stale value.

  1. Keep the result interactive by default; set flatten=True only when the user explicitly requests a completed, static form. Preserve the source PDF, and do not flatten a signed PDF without an explicit workflow decision.
  2. Inspect both representations before filling: enumerate fields from reader.get_fields() and /Widget annotations from every page's /Annots, following /Parent and /Kids. If a widget and a canonical field have the same name but are distinct objects with no /Parent relationship, do not call reattach_fields() blindly: it can create a second top-level field with the same name. Report the ambiguity or produce a static result.
  3. Recover genuinely orphaned widgets, fill all pages, and write the result with pypdf:
from pypdf import PdfReader, PdfWriter
from pypdf.generic import NameObject

reader = PdfReader(input_pdf)
writer = PdfWriter()
writer.clone_document_from_reader(reader)

# Restores widgets that are missing from /AcroForm/Fields.
writer.reattach_fields()
fields = writer.get_fields() or {}
missing = set(expected_values) - set(fields)
if missing:
    raise ValueError(f"Form fields not found after repair: {sorted(missing)}")

values_to_write = dict(expected_values)
if flatten:
    # Paint every existing value before removing every widget.
    values_to_write = {
        name: field.get("/V", "/Off" if field.get("/FT") == "/Btn" else "")
        for name, field in fields.items()
    }
    values_to_write.update(expected_values)

writer.update_page_form_field_values(
    None, values_to_write, auto_regenerate=False, flatten=flatten
)

if flatten:
    # pypdf's flatten=True paints appearances but does not remove widgets.
    writer.remove_annotations(subtypes="/Widget")
    writer.root_object.pop(NameObject("/AcroForm"), None)

with open(output_pdf, "wb") as stream:
    writer.write(stream)
  1. Reopen the written PDF before delivery. For an interactive result, require every expected field to be present in get_fields() with the expected /V, enumerate page widgets again, and confirm their effective /V (the widget value or inherited /Parent value) agrees. Confirm each updated widget has a non-empty /AP /N appearance and render the final pages to catch stale or clipped appearances. Do not rely on /NeedAppearances or a successful PNG render as proof that logical field data was updated.
  2. For a flattened result, require zero /Widget annotations and no remaining /AcroForm field tree after reopening, then render the final pages. Keep an editable copy when the user may need to revise the form.

Temp And Output Conventions

  • Use tmp/pdfs/ for intermediate files; delete them when done.
  • Write final artifacts under output/pdf/ when working in this repo.
  • Keep filenames stable and descriptive.

Dependencies

Prefer the Codex bundled workspace/runtime dependencies when available. The primary runtime is expected to include:

  • Python packages: reportlab, pdfplumber, pypdf
  • Rendering tools: pdftoppm and pdfinfo from Poppler

If a dependency is missing, install only what is needed.

Python packages:

uv pip install reportlab pdfplumber pypdf

If uv is unavailable:

python3 -m pip install reportlab pdfplumber pypdf

System tools for rendering:

# macOS (Homebrew)
brew install poppler

# Ubuntu/Debian
sudo apt-get install -y poppler-utils

If installation is not possible in this environment, tell the user which dependency is missing and how to install it locally.

Environment

No required environment variables.

Rendering Command

pdftoppm -png "$INPUT_PDF" "$OUTPUT_PREFIX"

Quality Expectations

  • Maintain polished visual design: consistent typography, spacing, margins, and section hierarchy.
  • Avoid rendering issues: clipped text, overlapping elements, broken tables, black squares, or unreadable glyphs.
  • Charts, tables, and images must be sharp, aligned, and clearly labeled.
  • Use ASCII hyphens only. Avoid U+2011 and other Unicode dashes.
  • Citations and references must be human-readable; never leave tool tokens or placeholder strings.

Final Checks

  • Do not deliver until the latest PNG inspection shows zero visual or formatting defects.
  • Confirm headers, footers, page numbering, and section transitions look polished.
  • Keep intermediate files organized or remove them after final approval.

Final response

Final Response Citations

  • Create/edit: for created or edited PDFs, cite each final deliverable exactly once with purpose="output", in its own paragraph. Briefly describe the result without repeating its filename, path, or link. Never put output directives inside prose or list items.
  • Q&A and summaries: Every file whose contents you summarize or use to support an answer MUST receive a :codex-file-citation{...} with purpose="source" in the final response. Use the source citation in place of the filename, wherever the filename would appear. Do not write the filename separately and append its citation at the end. Files merely inspected but not used in the answer need no citation. Do not emit output citations for unchanged files or read-only answers.
  • Emit :codex-file-citation{...} directly, without backticks, code fences, or a Markdown-link wrapper. Use verified targets only. No need to cite or reference intermediate work.

For file citations, set path to the verified absolute file path on the task host. Omit mode.

Some illustrative examples, real responses use verified targets outside code fences.

:codex-file-citation{path="/absolute/path/review.pdf" purpose="output"}
The review of :codex-file-citation{path="/absolute/path/review.pdf" purpose="source"} is due Friday.

Additional Citation Guidance

For PDF Q&A, inspect complete relevant pages and preserve material headings, table/figure labels, footnotes, sources, and sample sizes. PDF citations support only plain file citations; do not add artifact_kind, page_number, or other locators.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.