PDF v2

PDF Rendering with WeasyPrint

Print-ready PDFs with CMYK, ICC profiles, bleed, trim marks, and PDF/X-4 support.

Overview

The /render/pdfv2 endpoint uses WeasyPrint instead of Chromium for PDF generation. This provides full CSS Paged Media support and professional print features that Chromium cannot offer.

Featurev1 (Chromium)v2 (WeasyPrint)
RGB PDFYesYes
CMYK (DeviceCMYK)NoYes
ICC ProfilesNoYes
PDF/X-4 (Print Standard)NoYes
Bleed / Trim MarksNoYes
CSS @page (full)PartialComplete
FallbackChromium (auto)

Endpoint

POST https://supaserv.io/render/pdfv2
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Request Body

FieldTypeDefaultDescription
htmlstringSelf-contained HTML with inline CSS (required)
formatstring"A4"A4, A3, A5, Letter, Legal, Tabloid
landscapebooleanfalseLandscape orientation
marginobject{}Page margins: {top, right, bottom, left} in CSS units
print_backgroundbooleantrueRender CSS backgrounds
color_modestring"rgb""rgb" or "cmyk" — CMYK uses DeviceCMYK colors
icc_profilestringnullICC profile: "iso-coated-v2-300", "fogra39", "srgb"
bleedstring"0mm"Bleed area, e.g. "3mm" for print
trim_marksbooleanfalseAdd crop and cross marks
pdf_versionstring"auto""auto", "1.7", or "x-4" (PDF/X-4 for print production)

Examples

Simple RGB PDF

curl -X POST https://supaserv.io/render/pdfv2 \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "html": "<h1>Hello PDF v2</h1><p>Rendered with WeasyPrint</p>",
    "format": "A4"
  }' \
  --output simple.pdf

Print-Ready CMYK with Bleed

curl -X POST https://supaserv.io/render/pdfv2 \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "html": "<div style=\"background:#000;color:#fff;padding:40px\"><h1>Print Flyer</h1></div>",
    "format": "A4",
    "color_mode": "cmyk",
    "icc_profile": "iso-coated-v2-300",
    "bleed": "3mm",
    "trim_marks": true,
    "pdf_version": "x-4"
  }' \
  --output flyer-cmyk.pdf

Landscape with Custom Margins

curl -X POST https://supaserv.io/render/pdfv2 \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "html": "<table>...</table>",
    "format": "A3",
    "landscape": true,
    "margin": {"top": "15mm", "right": "20mm", "bottom": "15mm", "left": "20mm"}
  }' \
  --output report-landscape.pdf

HTML Guidelines

WeasyPrint uses its own rendering engine (not a browser). Keep these in mind:

CMYK & Print Production

When color_mode: "cmyk" is set, WeasyPrint outputs DeviceCMYK colors in the PDF. For professional print:

For screen/digital PDFs (reports, invoices), color_mode: "rgb" (default) is sufficient.

ICC Profiles

ValueProfileUse Case
iso-coated-v2-300ISO Coated v2 300%European offset printing (standard)
fogra39Fogra 39LEuropean offset, older standard
srgbsRGB IEC61966-2.1Screen/digital output

Fallback Behavior

If WeasyPrint fails (e.g. unsupported CSS), the endpoint automatically falls back to the Chromium engine (same as /render/pdf). The response header X-PDF-Engine: chromium-fallback indicates when this happens.

Error Responses

// 400 — Missing HTML
{ "error": "html is required (string)" }

// 500 — Both engines failed
{ "error": "PDF failed (both engines): ..." }

← Back to API Docs