2.1 KiB
2.1 KiB
name, description
| name | description |
|---|---|
| pdf-onepager | Generate styled one-page PDFs in the sandbox via fpdf2 and print with brother-printer. |
PDF One-Pager (fpdf2)
Generate a styled, single-page PDF in the sandbox, then print it with the brother-printer skill.
Steps
- Draft the content as a Python script using
fpdf2(FPDF, A4,set_auto_page_break(False), margins ~15mm). Build layout with helper functions: colored title, section headers with rule line, label+text bullets, a filled warning box (set_fill_color+multi_cell(fill=True)), and a small gray source footer. Do not use emoji/HTML-entities in text: fpdf2 core fonts (helvetica) support only Latin-1 — replace emoji with plain words.- Done when: the script is saved (e.g.
/tmp/make_pdf.py) with an absolute output path and prints a pages count frompdf.pages_count.
- Done when: the script is saved (e.g.
- Run
uv run --with fpdf2 /tmp/make_pdf.py.- Do NOT attempt
weasyprint(fails in this sandbox: missing system libs) or wkhtmltopdf/chromium/pandoc (not installed). Go straight to fpdf2. - Done when: script prints
done, pages: 1(or expected count) and the PDF file exists.
- Do NOT attempt
- Verify the file (
ls -la <path>), then print per the brother-printer skill:uv run /home/node/mop-skills/mop-skills/skills/brother-printer/scripts/brother_printer.py print --file <pdf> --title <title> --color monochrome --nup 1 --duplex two-sided-long-edge --chat-id <chat_id>.- For print-option selection, use
ask_userwith the standard preset menu from the brother-printer skill. - Done when: script reports 'Druck erfolgreich abgeschlossen'.
- For print-option selection, use
Reference
- fpdf2 API:
pdf.cell(w, h, text, new_x="LMARGIN", new_y="NEXT")for labels/headers;pdf.multi_cell(W, h, text, new_x="LMARGIN", new_y="NEXT")for wrapped text; colors viaset_text_color/set_fill_color/set_draw_color(RGB tuples). - Keep single-page fit: font 9–9.5pt body, 11–11.5pt headers, 17pt title; if content overflows, trim bullets rather than shrinking below 9pt.
- Save the PDF in the workspace (e.g.
/home/openclaw/.openclaw/workspace/<Name>.pdf) so it can be resent later.