HTML to PDF API

POST /v1/pdf

Convert webpages or raw HTML content into high-quality PDF documents. Supports custom page sizes, orientations, margins, and headers/footers.

Endpoint

POST https://api.devutils.io/v1/pdf

Parameters

You must provide either url or html, but not both.

ParameterTypeRequiredDescription
urlstringConditionalURL of the webpage to convert
htmlstringConditionalRaw HTML content to convert
pageSizestringNoPage size: A4, Letter, Legal, Tabloid. Default: A4
orientationstringNoportrait or landscape. Default: portrait
marginobjectNoPage margins {top, right, bottom, left} in pixels or CSS units
printBackgroundbooleanNoInclude background graphics. Default: true

Example Request

Convert URL to PDFbash
curl -X POST https://api.devutils.io/v1/pdf \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "pageSize": "A4",
    "orientation": "portrait",
    "margin": {
      "top": "20px",
      "right": "20px",
      "bottom": "20px",
      "left": "20px"
    }
  }'
Convert Raw HTML to PDFbash
curl -X POST https://api.devutils.io/v1/pdf \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "html": "<html><body><h1>Hello World</h1><p>This is a test PDF.</p></body></html>",
    "pageSize": "Letter"
  }'

Response

Success Responsejson
{
  "success": true,
  "data": {
    "pdf_url": "https://cdn.devutils.io/pdfs/xyz789.pdf",
    "pages": 3,
    "size": "245KB"
  }
}

The pdf_url is valid for 24 hours. Download or store the PDF before expiration.