Xpersona
P

Pdf Generator

CLAWHUB · Unverified

Generate professional PDFs from Markdown, HTML, data, or code. Reports, invoices, contracts, and documents with best practices. Skill: Pdf Generator Owner: ivangdavila Summary: Generate professional PDFs from Markdown, HTML, data, or code. Reports, invoices, contracts, and documents with best practices. Tags: latest:1.0.1 Version history: v1.0.1 | 2026-02-19T01:52:00.711Z | user Improved security documentation and scope clarity v1.0.0 | 2026-02-19T01:30:56.902Z | auto PDF Generator 1.0.0 – Initial Release - Generate professional PDFs from Mar

62
Rank
84
Safety
14k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 14K downloads reported by the source. Last updated 11/16/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s178jdk12x4qj3gs2se3etxf3h83h7ft:pdf-generator
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-ivangdavila-pdf-generator-enerator-2/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

47,436 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: PDF Generator
slug: pdf-generator
version: 1.0.1
homepage: https://clawic.com/skills/pdf-generator
description: Generate professional PDFs from Markdown, HTML, data, or code. Reports, invoices, contracts, and documents with best practices.
metadata: {"clawdbot":{"emoji":"📄","requires":{"bins":[]},"os":["linux","darwin","win32"]}}
---

## When to Use

User needs to create, generate, or export PDF documents. Agent handles document generation from multiple sources (Markdown, HTML, JSON, templates), formatting, styling, and batch processing.

## Scope

This skill ONLY:
- Provides code patterns and implementation guidance for PDF generation
- Explains tool selection, CSS for print, and document structure
- Shows reference examples for common document types

This skill NEVER:
- Executes code or generates files directly
- Makes network requests
- Accesses files outside user's working directory

All code examples are reference patterns for the user to implement.

## Quick Reference

| Topic | File |
|-------|------|
| Tool selection | `tools.md` |
| Document types | `templates.md` |
| Advanced operations | `advanced.md` |

## Core Rules

### 1. Choose the Right Tool

| Source | Best Tool | Why |
|--------|-----------|-----|
| Markdown | pandoc | Native support, TOC, templates |
| HTML/CSS | weasyprint | Best CSS support, no LaTeX |
| Data/JSON | reportlab | Programmatic, precise control |
| Simple text | fpdf2 | Lightweight, fast |

**Default recommendation:** weasyprint for most HTML-based documents.

### 2. Structure Before Style

```python
# CORRECT: semantic structure
html = """
<article>
  <header><h1>Report Title</h1></header>
  <section>
    <h2>Summary</h2>
    <p>Content...</p>
  </section>
</article>
"""

# WRONG: style-first approach
html = "<div style='font-size:24px'>Report Title</div>"
```

### 3. Handle Page Breaks Explicitly

```css
/* Force page break before */
.new-page { page-break-before: always; }

/* Keep together */
.keep-together { page-break-inside: avoid; }

/* Headers never orphaned */
h2, h3 { page-break-after: avoid; }
```

### 4. Always Set Metadata

```python
# Example pattern for weasyprint
html = """
<html>
<head>
  <title>Document Title</title>
  <meta name="author" content="Author Name">
</head>
...
"""
```

### 5. Use Print-Optimized CSS

```css
@media print {
  body {
    font-family: 'Georgia', serif;
    font-size: 11pt;
    line-height: 1.5;
  }
  
  @page {
    size: A4;
    margin: 2cm;
  }
  
  .no-print { display: none; }
}
```

### 6. Validate Output

After generating any PDF:
1. Check file size (0 bytes = failed)
2. Open and verify page count
3. Verify fonts render correctly

## Common Traps

| Trap | Consequence | Fix |
|------|-------------|-----|
| Missing fonts | Fallback to defaults | Use web-safe fonts |
| Absolute image paths | Images missing | Use relative paths |
| No page size | Unpredictable layout | Set `@page { size: A4; }` |
| Large images | Huge files | Compress before use |

## Secu

_meta.json

{
  "ownerId": "kn73vp5rarc3b14rc7wjcw8f8580t5d1",
  "slug": "pdf-generator",
  "version": "1.0.1",
  "publishedAt": 1771465920711
}

advanced.md

# Advanced PDF Operations

## Merge PDFs

```python
from pypdf import PdfWriter, PdfReader

def merge_pdfs(input_files, output_file):
    writer = PdfWriter()
    
    for pdf_path in input_files:
        reader = PdfReader(pdf_path)
        for page in reader.pages:
            writer.add_page(page)
    
    with open(output_file, "wb") as f:
        writer.write(f)

# Usage
merge_pdfs(["doc1.pdf", "doc2.pdf"], "merged.pdf")
```

## Split PDF

```python
from pypdf import PdfReader, PdfWriter

def split_pdf(input_file, output_dir="."):
    reader = PdfReader(input_file)
    
    for i, page in enumerate(reader.pages):
        writer = PdfWriter()
        writer.add_page(page)
        with open(f"{output_dir}/page_{i+1}.pdf", "wb") as f:
            writer.write(f)

def split_by_range(input_file, ranges, output_file):
    """Extract specific pages. ranges = [(1,3), (5,7)]"""
    reader = PdfReader(input_file)
    writer = PdfWriter()
    
    for start, end in ranges:
        for i in range(start - 1, end):
            writer.add_page(reader.pages[i])
    
    with open(output_file, "wb") as f:
        writer.write(f)
```

## Fill PDF Forms

```python
from pypdf import PdfReader, PdfWriter

def fill_form(input_pdf, output_pdf, field_data):
    """
    field_data = {"field_name": "value"}
    """
    reader = PdfReader(input_pdf)
    writer = PdfWriter()
    
    writer.append(reader)
    writer.update_page_form_field_values(writer.pages[0], field_data)
    
    with open(output_pdf, "wb") as f:
        writer.write(f)

# Get field names from PDF
def list_form_fields(pdf_path):
    reader = PdfReader(pdf_path)
    fields = reader.get_form_text_fields()
    for name, value in fields.items():
        print(f"{name}: {value}")
```

## Add Watermark

```python
from pypdf import PdfReader, PdfWriter
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4
from io import BytesIO

def create_watermark(text):
    buffer = BytesIO()
    c = canvas.Canvas(buffer, pagesize=A4)
    c.setFont("Helvetica", 50)
    c.rotate(45)
    c.drawString(200, 100, text)
    c.save()
    buffer.seek(0)
    return buffer

def add_watermark(input_pdf, output_pdf, watermark_text):
    watermark_buffer = create_watermark(watermark_text)
    watermark_reader = PdfReader(watermark_buffer)
    watermark_page = watermark_reader.pages[0]
    
    reader = PdfReader(input_pdf)
    writer = PdfWriter()
    
    for page in reader.pages:
        page.merge_page(watermark_page)
        writer.add_page(page)
    
    with open(output_pdf, "wb") as f:
        writer.write(f)
```

## Batch Processing

```python
from pathlib import Path
from weasyprint import HTML

def batch_generate(template_html, data_list, output_dir):
    """Generate multiple PDFs from template + data."""
    Path(output_dir).mkdir(exist_ok=True)
    
    for item in data_list:
        html = template_html.format(**item['data'])
        output_path = f"{output_dir}/{item['filename']}.pdf"
        HTML(

skill-card.md

## Description:

Generate professional PDFs from Markdown, HTML, data, or code for reports, invoices, contracts, and documents with best practices.

This skill is ready for commercial/non-commercial use.

## Publisher:

[ivangdavila](https://clawhub.ai/user/ivangdavila)

### License/Terms of Use:


## Use Case:

Developers and agents use this skill to choose PDF-generation tools and produce implementation patterns for reports, invoices, contracts, forms, and batch document workflows from Markdown, HTML, data, or code.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: Sample PDF-output paths could overwrite important files or write to unintended locations when copied into real applications.

Mitigation: Write outputs only to user-chosen directories, validate destination paths, sanitize filenames, and check before overwriting existing files.

Risk: HTML templating examples can be unsafe when populated with untrusted user data.

Mitigation: Escape untrusted data, use a safe templating library, and review generated HTML before PDF conversion.

Risk: PDF rendering tools such as WeasyPrint may fetch local or remote resources if inputs are not restricted.

Mitigation: Restrict resource fetching and only render trusted or pre-sanitized HTML and assets.

## Reference(s):

- [ClawHub skill page](https://clawhub.ai/ivangdavila/skills/pdf-generator)
- [Skill homepage](https://clawic.com/skills/pdf-generator)
- [PDF Tools - Selection Guide](artifact/tools.md)
- [Document Templates](artifact/templates.md)
- [Advanced PDF Operations](artifact/advanced.md)

## Skill Output:

**Output Type(s):** [Text, Markdown, Code, Shell commands, Configuration guidance]

**Output Format:** [Markdown with Python, HTML, CSS, and bash code blocks]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [Reference-only guidance; the skill does not execute code, create files, make network requests, or access system files.]

## Skill Version(s):

1.0.1 (source: server release and frontmatter)

## Ethical Considerations:

Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.

templates.md

# Document Templates

## Invoice

```python
from weasyprint import HTML, CSS

def generate_invoice(data):
    html = f"""
    <!DOCTYPE html>
    <html>
    <head>
        <style>
            body {{ font-family: Arial, sans-serif; margin: 40px; }}
            .header {{ display: flex; justify-content: space-between; }}
            .company {{ font-size: 24px; font-weight: bold; }}
            .invoice-title {{ font-size: 32px; color: #333; }}
            table {{ width: 100%; border-collapse: collapse; margin: 20px 0; }}
            th, td {{ padding: 12px; text-align: left; border-bottom: 1px solid #ddd; }}
            th {{ background: #f5f5f5; }}
            .total {{ font-size: 18px; font-weight: bold; text-align: right; }}
        </style>
    </head>
    <body>
        <div class="header">
            <div class="company">{data['company']['name']}</div>
            <div class="invoice-title">INVOICE</div>
        </div>
        
        <p><strong>Invoice #:</strong> {data['invoice']['number']}</p>
        <p><strong>Date:</strong> {data['invoice']['date']}</p>
        <p><strong>Due:</strong> {data['invoice']['due_date']}</p>
        
        <h3>Bill To:</h3>
        <p>{data['client']['name']}<br>{data['client']['address']}</p>
        
        <table>
            <tr><th>Description</th><th>Qty</th><th>Rate</th><th>Amount</th></tr>
            {''.join(f"<tr><td>{item['desc']}</td><td>{item['qty']}</td><td>${item['rate']}</td><td>${item['qty'] * item['rate']}</td></tr>" for item in data['items'])}
        </table>
        
        <p class="total">Total: ${sum(item['qty'] * item['rate'] for item in data['items'])}</p>
    </body>
    </html>
    """
    HTML(string=html).write_pdf(f"invoice-{data['invoice']['number']}.pdf")

# Usage
invoice_data = {
    "company": {"name": "Acme Inc"},
    "client": {"name": "Client Corp", "address": "123 Main St"},
    "invoice": {"number": "INV-001", "date": "2025-02-19", "due_date": "2025-03-19"},
    "items": [
        {"desc": "Consulting", "qty": 10, "rate": 150},
        {"desc": "Development", "qty": 20, "rate": 200},
    ]
}
generate_invoice(invoice_data)
```

## Report

```python
from weasyprint import HTML

def generate_report(title, sections):
    toc = "".join(f'<li><a href="#section-{i}">{s["title"]}</a></li>' 
                  for i, s in enumerate(sections))
    
    content = "".join(f'''
        <section id="section-{i}">
            <h2>{s["title"]}</h2>
            <p>{s["content"]}</p>
        </section>
    ''' for i, s in enumerate(sections))
    
    html = f"""
    <!DOCTYPE html>
    <html>
    <head>
        <style>
            @page {{ size: A4; margin: 2cm; }}
            body {{ font-family: Georgia, serif; line-height: 1.6; }}
            h1 {{ color: #2c3e50; border-bottom: 2px solid #3498db; }}
            h2 {{ color: #34495e; page-break-after: avoid; }}
            section {{ page-break-inside: avoid; }}
            .toc {{ background: #f9f9f9; padding: 20px; margin:

Sponsored

Ads related to Pdf Generator and adjacent AI workflows.