aipoch/open-science / resources/skills/pdf-generation
pdf-generation
VerifiedUse when creating a PDF report, handout, or poster with Python, or when merging, splitting, rotating, watermarking, encrypting, filling forms in, or extracting tables from an existing PDF inside the Notebook. Covers ReportLab layout with embedded Unicode/CJK fonts, pypdf and pdfplumber processing, page rendering for visual QA, and Artifact delivery. For reading or citing a library paper, prefer read_document, list_pdf_elements, and read_library_pdf.
| File | Kind | Size |
|---|---|---|
| README.md | markdown | 2.0 KB |
| SKILL.md | skill md | 12.0 KB |
| kernel.py | script | 13.7 KB |
| open-science.json | config | 367 B |
| references/forms.md | markdown | 4.6 KB |
| references/processing.md | markdown | 6.4 KB |
README.md
View on GitHub# PDF generation and processing skill
On-demand skill for creating PDFs with ReportLab and processing existing PDFs
with pypdf, pdfplumber, and pypdfium2 inside the Open Science Notebook.
## Execution boundary
The Notebook and shell cannot necessarily read this skill directory. Code that
the model needs at run time is in `kernel.py`, registered in `open-science.json`
and injected with `kernelSkillIds: ["pdf-generation"]`. The helpers import their
third-party packages lazily, so injection succeeds before the packages are
installed; a call reports the missing module through the normal recovery flow,
and the model installs packages with `manage_packages`. No command-line PDF tool,
Office engine, or font is bundled.
## Helpers
- `register_pdf_fonts`: registers an embeddable TrueType family. CJK lookup covers
macOS (STHeiti, Songti, Arial Unicode), Windows (Microsoft YaHei, SimHei,
SimSun), and common Linux packages (WenQuanYi, Droid Sans Fallback). CFF-based
fonts such as Hiragino and most `.otf` files are skipped because ReportLab cannot
embed them. The non-CJK default is matplotlib's DejaVu Sans.
- `render_pdf_pages`: pypdfium2 rendering sized for `host.viewImage` (1568 px).
- `inspect_pdf`: text-layer, font-embedding, outline, and form summary.
- `pdf_form_fields`, `fill_pdf_form`: AcroForm listing and validated filling.
## Attribution
The workflow and form-filling procedure are adapted from the `pdf` skill in
[anthropics/skills](https://github.com/anthropics/skills) (Apache-2.0). Changes:
Open Science execution and Artifact delivery, removal of CLI tools that are not
bundled, embedded-font handling, helper functions in place of scripts.
## Validation
```sh
python3 -m unittest discover -s test/pdf-generation -v
npx vitest run src/main/skills/pdf-generation.test.ts
```
The Python suite skips when ReportLab, pypdf, pdfplumber, or pypdfium2 are not
installed in the test interpreter; set `OPEN_SCIENCE_TEST_PYTHON` to an
interpreter that has them for a full run.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |