Files

2.1 KiB
Raw Permalink Blame History

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

  1. 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 from pdf.pages_count.
  2. 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.
  3. 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_user with the standard preset menu from the brother-printer skill.
    • Done when: script reports 'Druck erfolgreich abgeschlossen'.

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 via set_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.