PDF Generation API

Convert HTML content to PDF documents with our reliable and easy-to-use API.

Overview

The PDF Generation API allows you to convert HTML content into high-quality PDF documents. This is useful for generating reports, invoices, certificates, and other documents that need to be distributed in PDF format.

Our API uses Playwright under the hood for accurate rendering, ensuring that your PDFs look exactly as intended with proper CSS styling, images, and layout.

Key Features

  • Convert any valid HTML content to PDF
  • Control output filename
  • Choose between direct download or URL access
  • Option to receive Base64-encoded PDF data
  • Secure input validation and rate limiting

API Reference

POST https://wiseapis.com/api/generate-pdf

Generate PDF

Converts HTML content to a PDF document.

Request Parameters

Parameter Type Required Description
api_key string Yes Your API key
api_name string Yes Must be "generate-pdf"
html string Yes The HTML content to convert to PDF
filename string No Custom filename for the PDF (default: "document.pdf")
download string No Set to "true" to download the PDF directly instead of returning a URL
include_base64 string No Set to "true" to include the PDF as base64-encoded data in the response

Response Format

The API returns JSON with the following structure:

{
  "success": true,
  "execution_time": 1.25,
  "file_size": 125840,
  "pdf_url": "https://wiseapis.com/pdfs/6123a8b7c9d0e/document.pdf",
  "error": null
}

If base64 encoding is requested, the response includes the PDF data:

{
  "success": true,
  "execution_time": 1.25,
  "file_size": 125840,
  "pdf_base64": "JVBERi0xLjUKJcOkw7...[truncated]",
  "error": null
}

Error Responses

Status Code Description Example
400 Bad Request - Missing or invalid parameters {"success": false, "error": "HTML content is required"}
401 Unauthorized - Invalid API key {"success": false, "error": "API key is required"}
429 Too Many Requests - Rate limit exceeded {"success": false, "error": "Rate limit exceeded. Try again later."}
500 Internal Server Error {"success": false, "error": "PDF generation failed"}

Code Examples

curl -X POST https://wiseapis.com/api/API.php \
  -F "api_key=your_api_key" \
  -F "api_name=generate-pdf" \
  -F "html=<html><body><h1>Hello World</h1><p>This is a test.</p></body></html>" \
  -F "filename=my-document.pdf"

Limitations & Notes

Rate Limits

This API is limited to 100 requests per hour per API key. If you exceed this limit, your requests will be rejected until the limit resets.

HTML Restrictions

For security reasons, only a subset of HTML tags are allowed:

  • Allowed tags: html, body, div, p, h1-h6, span, strong, em, ul, ol, li, table, tr, td, th, thead, tbody, br, img
  • JavaScript is not allowed in the HTML content
  • Maximum HTML size: 5MB

PDF Storage

PDFs generated with this API are stored temporarily and will be automatically deleted after 24 hours. If you need long-term storage, download the file or use the base64 encoding option.