PDF Creation with fpdf2 for Openclaw

Create lightweight, searchable, Unicode-safe PDF documents with Python and fpdf2 when reportlab is unavailable or unsuitable.

mina-atef-00
v1.0.0
Sep 19, 2026
0
131
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install pdf-creation

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install pdf-creation using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is PDF Creation with fpdf2?

This Openclaw Skills integration provides a practical fpdf2 workflow for generating PDFs from Python on Linux. It is designed as a lightweight alternative to reportlab for simple documents, searchable text, Unicode content, styled tables, headings, and rapid iteration.

The skill emphasizes reliable font registration, correct fpdf2 table APIs, automatic page breaks, and predictable PDF output. It is especially useful when PIL or Imaging dependencies conflict with reportlab, when working in uv-managed virtual environments, or when a smaller PDF-generation stack is preferred.

PDF Creation with fpdf2 Use Cases

  • Generate searchable PDFs containing Unicode characters such as em dashes, arrows, bullets, and non-Latin text.
  • Create lightweight reports, summaries, invoices, documentation, and data exports from Python.
  • Produce formatted multi-row tables with headings, alternating fills, borders, and custom typography.
  • Replace reportlab when PIL dependencies are unavailable or conflicting.
  • Rapidly prototype PDF layouts with automatic page breaks and millimeter-based coordinates.
  • Build Linux-based document automation workflows with Openclaw Skills and Python 3.

How PDF Creation with fpdf2 Works

  1. Confirm that the workflow is running on Linux and that Python 3 is available.
  2. Install the fpdf2 package in the active Python environment.
  3. Locate a Unicode-capable TrueType font, such as DejaVu Sans, and register regular, bold, and italic variants with the PDF instance.
  4. Create an FPDF document with the required page orientation, units, page size, margins, and automatic page-break settings.
  5. Add pages and write content using methods such as cell() for short lines and multi_cell() for wrapped Unicode-safe text.
  6. Build tables with the fpdf2 table context manager, FontFace styles, heading configuration, effective-page-width limits, and optional alternating row fills.
  7. Export the finished document with pdf.output() to a chosen .pdf path.
  8. Validate the output visually and confirm that registered fonts prevent FPDFUnicodeEncodingException for non-Latin-1 characters.

PDF Creation with fpdf2 Setup

  1. Ensure Linux and Python 3 are available. The skill metadata declares python3 as the required binary.
  2. Install fpdf2:
pip install fpdf2
  1. Install or locate a Unicode-capable TTF font. Common Linux locations include /usr/share/fonts/dejavu-sans-fonts/ and /usr/share/fonts/truetype/dejavu/.
  2. Register the font before writing any non-ASCII content. A minimal document setup is:
from fpdf import FPDF

FONT_DIR = "/usr/share/fonts/dejavu-sans-fonts"
pdf = FPDF("P", "mm", "A4")
pdf.add_font("DJS", "", f"{FONT_DIR}/DejaVuSans.ttf")
pdf.add_font("DJS", "B", f"{FONT_DIR}/DejaVuSans-Bold.ttf")
pdf.add_font("DJS", "I", f"{FONT_DIR}/DejaVuSans-Oblique.ttf")
pdf.set_auto_page_break(auto=True, margin=20)
pdf.add_page()
pdf.set_font("DJS", "B", 26)
pdf.cell(0, 10, "Title", align="C")
pdf.ln(12)
pdf.set_font("DJS", "", 9.5)
pdf.multi_cell(0, 5, "Unicode-safe text with em-dashes and arrows.")
pdf.output("output.pdf")
  1. For tables, use fpdf2 2.8 or newer and keep the declared table width at or below pdf.epw. The skill does not require a separate configuration file; document structure is defined in Python code and generated PDF paths.

PDF Creation with fpdf2 Data Schema & Taxonomy

The skill uses a code-defined document model rather than a fixed JSON or database schema.

Data or artifact Organization Notes
Skill metadata YAML front matter with name, description, version, and metadata.openclaw Declares Linux support, homepage, and the required python3 binary.
Font assets External TTF files registered under a logical family such as DJS Regular, bold, and italic variants can be selected through font emphasis.
Document settings FPDF instance configuration Includes orientation, units, page size, margins, and automatic page breaks.
Text content cell() and multi_cell() calls Supports searchable text when a Unicode-capable font is registered.
Tables pdf.table() context manager with rows and FontFace styles Supports headings, column widths, fills, borders, alignment, and line height.
Generated files PDF paths passed to pdf.output() Typical outputs include output.pdf and table.pdf; filenames are user-defined.

Important constraints include the top-left coordinate origin, millimeter units, Unicode font registration for characters outside Latin-1, and table widths that do not exceed the effective page width.

PDF Creation with fpdf2 Advanced Features

  • Unicode-safe TrueType font registration for searchable text beyond Latin-1.
  • Separate regular, bold, and italic font variants within a reusable logical family.
  • Automatic page breaks configured with a page-bottom margin.
  • Styled tables using FontFace for family, emphasis, point size, text color, and fill color.
  • Table-level alternating row backgrounds with cell_fill_mode="ROWS" and RGB cell_fill_color values.
  • Heading rows configured with first_row_as_headings=True and headings_style.
  • Minimal table borders, custom column widths, text alignment, and line-height control.
  • Compatibility guidance for fpdf2 2.8 table APIs, including the renamed first_row_as_headings parameter.
  • Lightweight operation without a mandatory Pillow dependency; missing Pillow affects images but not text or table generation.
  • A focused alternative to reportlab for Openclaw Skills workflows that prioritize fast iteration and fewer imaging dependencies.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*