AI HTML to PDF API Documentation

Connect your AI agent through MCP, or convert HTML and URLs with the REST API.

Recommended for AI agents

Connect with one prompt

Copy a setup prompt for your client. PixelToPdf exposes PDF and screenshot tools at /mcp.

Full MCP reference →

Claude Code

Codex

Cursor

OpenCode v2

VS Code

Prompts never contain your key. Configure it privately in your client, never in agent chat or source control.

Authentication

All API requests require authentication using an API key. Include your key in the X-API-Key header. MCP clients send the same key as an Authorization: Bearer token.

X-API-Key: sk_your_api_key

Endpoints

POST/convert/pdf
Convert HTML or URL to PDF
POST/convert/png
Convert HTML or URL to PNG image
POST/convert/jpeg
Convert HTML or URL to JPEG image
POST/convert/webp
Convert HTML or URL to WebP image
GET/logs
List your conversion history

Request Options

ParameterTypeDescription
source*stringURL or raw HTML content (required)
formatstringPage format: A4, Letter, Legal, etc.
landscapebooleanUse landscape orientation
use_printbooleanUse print media styles
marginobjectPage margins: {top, right, bottom, left}
headerobjectHeader HTML: {source, height}
footerobjectFooter HTML: {source, height}
cssstringCustom CSS to inject
javascriptstringCustom JavaScript to inject
delaynumberDelay before rendering (ms)
timeoutnumberMax rendering time (seconds)
wait_for_networkbooleanWait for network activity to become idle
lazy_load_imagesbooleanScroll the page to load deferred images
disable_javascriptbooleanDisable page JavaScript execution
pagesstringPDF page ranges, for example 1-5
zoomnumberPDF scale from 0.1 to 2
filenamestringFilename in the response Content-Disposition header
sandboxbooleanSandbox mode (no credits used)
encodebooleanReturn base64 instead of binary

Code Examples

curl -X POST https://api.pixeltopdf.com/convert/pdf \
  -H "X-API-Key: sk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"source": "https://example.com"}' \
  --output document.pdf

Rate Limits

Rate limits depend on your plan:

  • Free: 10 requests per minute
  • Startup: 100 requests per minute
  • Boost: 200 requests per minute
  • Growth and above: 500 to 20,000 requests per minute

Error Codes

CodeDescription
400Bad request - Invalid parameters
401Unauthorized - Invalid or missing API key
402Payment required - No credits remaining
429Too many requests - Rate limit exceeded
500Internal server error - Please retry

Build with the API

Try a conversion interactively or follow a production pattern for your framework and document type.