Skip to main content
The pdf template generates a PDF document from HTML or Markdown content.

Content Schema

content.html
string
HTML content to render as PDF
content.markdown
string
Markdown content to render as PDF (alternative to HTML)
content.css
string
Custom CSS styles for the PDF
content.pageSize
string
Page size: a4, letter, legal (default: a4)
content.orientation
string
Page orientation: portrait, landscape (default: portrait)
content.margins
object
Page margins with top, right, bottom, left in pixels
Provide either html or markdown, not both. If both are provided, html takes precedence.

Example: HTML to PDF

curl -X POST https://genui.sh/api/artifacts \
  -H "Authorization: Bearer $GENUI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "template": "pdf",
    "title": "Invoice #1234",
    "content": {
      "html": "<h1>Invoice #1234</h1><p>Date: January 15, 2024</p><table><tr><th>Item</th><th>Amount</th></tr><tr><td>Consulting</td><td>$5,000</td></tr><tr><td>Development</td><td>$10,000</td></tr></table><p><strong>Total: $15,000</strong></p>",
      "css": "body { font-family: Arial; } table { width: 100%; border-collapse: collapse; } th, td { border: 1px solid #ddd; padding: 8px; }",
      "pageSize": "letter",
      "margins": {"top": 50, "right": 50, "bottom": 50, "left": 50}
    }
  }'

Example: Markdown to PDF

{
  "template": "pdf",
  "title": "Project Proposal",
  "content": {
    "markdown": "# Project Proposal\n\n## Overview\n\nThis document outlines our proposed solution.\n\n## Timeline\n\n| Phase | Duration |\n|-------|----------|\n| Discovery | 2 weeks |\n| Development | 8 weeks |\n| Testing | 2 weeks |\n\n## Budget\n\n**Total: $50,000**",
    "pageSize": "a4",
    "orientation": "portrait"
  }
}

Response with Download URL

{
  "id": "art_pdf_abc123",
  "template": "pdf",
  "title": "Invoice #1234",
  "status": "active",
  "downloadUrl": "https://genui.sh/api/artifacts/art_pdf_abc123/download",
  "createdAt": "2024-01-15T12:00:00Z"
}

Page Sizes

SizeDimensions
a4210 x 297 mm
letter8.5 x 11 in
legal8.5 x 14 in

Use Cases

  • Invoices: Billing documents
  • Contracts: Agreements and legal documents
  • Reports: Formal reports and summaries
  • Certificates: Awards and certifications
  • Exports: Printable versions of any content