The pdf template generates a PDF document from HTML or Markdown content.
Content Schema
HTML content to render as PDF
Markdown content to render as PDF (alternative to HTML)
Custom CSS styles for the PDF
Page size: a4, letter, legal (default: a4)
Page orientation: portrait, landscape (default: portrait)
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
| Size | Dimensions |
|---|
a4 | 210 x 297 mm |
letter | 8.5 x 11 in |
legal | 8.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