Recipes
Task-first, copy-pasteable snippets
Recipes index
Each recipe below is a self-contained script you can paste into a Python session and run against a live HWP instance. Snippets that need the HWP COM server are marked eval: false — copy them into your own script and run on Windows.
The recipes are ported from the v1 notebook tutorials (nbs/01_tutorials/*.ipynb) and example scripts (examples/*.py), then rewritten to target the v2 API surface (App.doc.* + collections + context scopes).
| Title | Subtitle |
|---|---|
| Batch-process a folder of .hwp files | Open → transform → save, for every file in a directory |
| Bulk edit | Format N paragraphs / replace across M files |
| Character formatting | Bold, color, size — via scopes and ParameterSets |
| Data to table | DataFrame / list-of-dicts → HWP table |
| Debugging tools | When something’s wrong, here’s where to look |
| Export to PDF, HTML, image, text | Save the active document in any format HWP supports |
| Fill form fields | Bulk-fill 누름틀 fields from a dict or CSV |
| Find and replace | From simple replace_all to nested shape constraints |
| Headers and footers | Insert page headers, footers, and page numbers programmatically |
| Insert a picture | Drop an image into the active document via the v2 escape hatch |
| Mail merge | Template + CSV → N output files |
| Presets gallery | Pre-built formatting macros — highlight, shade, rule lines |
| Quickstart tour | The seven moves every hwpapi script uses |
| Report generation | End-to-end: title + text + table + image + PDF export |
No matching items