VisualActive

HTML to PDF

Render a URL or raw HTML string to PDF. Returns pdf_base64 (base64 PDF — decode to get raw bytes) and page_count. Provide url OR html — never both. Supports format (A4/Letter/Legal), landscape boolean, and margin settings (top/bottom/left/right in CSS units). Use for invoices, reports, or printable document generation.

Endpointx402 Payment Required

POST

https://agentsvc.io/api/v1/proxy/html-to-pdf

Price

$0.008 USDC

Latency P99

~3.5s

Provider

agentsvc.io

Input Schema

{ "description": "Provide either 'url' OR 'html' (not both). Common fields (format, landscape, margin) apply to both.", "oneOf": [ { "type": "object", "required": [ "url" ], "properties": { "url": { "type": "string", "format": "uri", "description": "URL to render as PDF (must be publicly accessible)" }, "format": { "type": "string", "enum": [ "A4", "Letter", "Legal" ], "default": "A4", "description": "Page format" }, "landscape": { "type": "boolean", "default": false, "description": "Landscape orientation" }, "margin": { "type": "object", "description": "Page margins (CSS units, e.g. '1cm', '10mm', '0.5in')", "properties": { "top": { "type": "string", "default": "1cm" }, "bottom": { "type": "string", "default": "1cm" }, "left": { "type": "string", "default": "1cm" }, "right": { "type": "string", "default": "1cm" } } } } }, { "type": "object", "required": [ "html" ], "properties": { "html": { "type": "string", "description": "Raw HTML string to render as PDF" }, "format": { "type": "string", "enum": [ "A4", "Letter", "Legal" ], "default": "A4", "description": "Page format" }, "landscape": { "type": "boolean", "default": false, "description": "Landscape orientation" }, "margin": { "type": "object", "description": "Page margins (CSS units, e.g. '1cm', '10mm', '0.5in')", "properties": { "top": { "type": "string", "default": "1cm" }, "bottom": { "type": "string", "default": "1cm" }, "left": { "type": "string", "default": "1cm" }, "right": { "type": "string", "default": "1cm" } } } } } ] }

Output Schema

{ "type": "object", "required": [ "pdf_base64", "page_count", "file_size_bytes", "generated_at" ], "properties": { "pdf_base64": { "type": "string", "description": "Base64-encoded PDF bytes (decode to get raw PDF file)" }, "page_count": { "type": "integer", "description": "Number of pages in the generated PDF" }, "file_size_bytes": { "type": "integer", "description": "Size of the PDF in bytes" }, "generated_at": { "type": "string", "format": "date-time", "description": "ISO 8601 timestamp of generation" } }, "example": { "pdf_base64": "JVBERi0xLjQKJeLjz9MKMyAwIG9iago8PC9...", "page_count": 2, "file_size_bytes": 14867, "generated_at": "2026-04-07T12:00:00.000Z" } }

Code Examples

# Step 1: Call without payment → receive 402 with requirements
curl -X POST "https://agentsvc.io/api/v1/proxy/html-to-pdf" \
  -H "Content-Type: application/json" \
  -d '{
  "url": "https://example.com"
}'

# Step 2: Sign payment using x402 SDK, then retry
curl -X POST "https://agentsvc.io/api/v1/proxy/html-to-pdf" \
  -H "Content-Type: application/json" \
  -H "X-Payment: x402 usdc base <your-signed-payment>" \
  -d '{
  "url": "https://example.com"
}'

Tags

#pdf#browser#document#playwright#convert

Service Info

Service IDsvc_htmlpdf_04
Categoryvisual
StatusActive
ChainBase (USDC)
Protocolx402
Read API Documentation →