PDF processing
Baby Whale builds and manipulates real PDFs through Python code — write the
script, run it with bash using $DSH_OFFICE_PYTHON.
Creating PDFs (reportlab)
- Prefer
platypusflowables:SimpleDocTemplate,Paragraph,Table/TableStyle,Spacer,PageBreak. - Design per document, no default theme: pick a dominant + accent for
THIS topic (reuse a companion deck's constants when one exists). Define
colors.HexColorconstants once; body text stays near-black. - Type scale: title 24–28pt bold, H2 14pt bold in the dominant color, body Helvetica 10.5pt with 14pt leading, generous spacing before headings.
- Tables quiet by default: header band in the dominant color (white bold),
alternating 3% tint rows,
LINEBELOWhairlines only — never full grids. - Callout boxes: tinted single-cell tables, no border stripes.
- Multi-page documents get page numbers + a small running footer via
onPagecallbacks.
Working with existing PDFs (pypdf / pdfplumber)
- Merge/split/reorder pages with pypdf's
PdfWriter. - Extract text with pdfplumber (
page.extract_text()); extract tables withpage.extract_tables(). For scanned pages without a text layer say so — do not invent contents.
Workflow
- For from-scratch documents draft the spine first (see document-report), then encode it in the script.
- Run via bash under
$DSH_OFFICE_PYTHON; iterate on errors. - Verify: page count for writes, non-empty extracted text/pages for manipulations; keep console output to a couple of lines.
- Save
deliverables/<slug>.pdf, call deliver, state the path and a one-line summary of contents.