Complete API reference with request schema, parameter contracts, cURL examples, and sample responses.
Switch between APIs
Document APIs
Security APIs
Conversion APIs
OCR APIs
Utility APIs
Generate PDF from URL or HTML/CSS input.
Field-level request contract for this endpoint
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| url | string | Conditional | Target webpage URL. Required when html_content is not provided. | https://example.com |
| html_content | string | Conditional | Raw HTML markup. Required when url is not provided. | <h1>Hello</h1> |
| css_content | string | No | CSS styles used with html_content. | h1{font-size:32px;} |
| wait_till | number | No | Wait time in ms before rendering screenshot/PDF. | 10000 |
| full_page | boolean | No | Capture full scroll height for URL rendering. | true |
| viewPortWidth | number | No | Viewport width in px. | 1080 |
| viewPortHeight | number | No | Viewport height in px. | 720 |
| output_format | "url" | "file" | No | Return file URL or binary file response. | url |
| output_filename | string | No | Output filename (without extension). | document |
{
"url": "https://example.com",
"full_page": true,
"wait_till": 10000,
"viewPortWidth": 1080,
"viewPortHeight": 720,
"output_format": "url",
"output_filename": "document"
}{
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "Target webpage URL. Required when html_content is not provided.",
"example": "https://example.com"
},
"html_content": {
"type": "string",
"description": "Raw HTML markup. Required when url is not provided.",
"example": "<h1>Hello</h1>"
},
"css_content": {
"type": "string",
"description": "CSS styles used with html_content.",
"example": "h1{font-size:32px;}"
},
"wait_till": {
"type": "number",
"description": "Wait time in ms before rendering screenshot/PDF.",
"example": "10000"
},
"full_page": {
"type": "boolean",
"description": "Capture full scroll height for URL rendering.",
"example": "true"
},
"viewPortWidth": {
"type": "number",
"description": "Viewport width in px.",
"example": "1080"
},
"viewPortHeight": {
"type": "number",
"description": "Viewport height in px.",
"example": "720"
},
"output_format": {
"type": "string",
"description": "Return file URL or binary file response.",
"example": "url"
},
"output_filename": {
"type": "string",
"description": "Output filename (without extension).",
"example": "document"
}
},
"required": []
}{
"success": true,
"pdf_url": "https://storage.example.com/document-a1b2.pdf"
}{
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": true
},
"data": {
"type": "object",
"description": "Endpoint-specific response payload."
}
}
}curl -X POST https://pdfapihub.com/api/v1/generatePdf \
-H "CLIENT-API-KEY: your-api-key" \
-H "Content-Type: application/json" \
-d '{ "url": "https://example.com", "full_page": true, "wait_till": 10000, "viewPortWidth": 1080, "viewPortHeight": 720, "output_format": "url", "output_filename": "document" }'Common and endpoint-specific API error responses
Headers: CLIENT-API-KEY: <your-api-key> Content-Type: application/json Success HTTP status: 200 Success
| Code | Type | Reason |
|---|---|---|
| 400 | Invalid Request | Malformed JSON, invalid body shape, or missing required fields. |
| 401 | Unauthorized | Missing or invalid CLIENT-API-KEY. |
| 429 | Rate Limited | Request quota exceeded for current API key. |
| 500 | Internal Error | Unexpected processing failure. |
| 422 | Render Validation Failed | Invalid URL, unsupported HTML payload, or rendering options conflict. |
Generate endpoint-level OpenAPI JSON for SDK/client generation
{
"openapi": "3.0.3",
"info": {
"title": "PDF API Hub - Generate PDF",
"version": "1.0.0"
},
"paths": {
"/generatePdf": {
"post": {
"summary": "Generate PDF from URL or HTML/CSS input.",
"security": [
{
"ApiKeyAuth": []
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "Target webpage URL. Required when html_content is not provided.",
"example": "https://example.com"
},
"html_content": {
"type": "string",
"description": "Raw HTML markup. Required when url is not provided.",
"example": "<h1>Hello</h1>"
},
"css_content": {
"type": "string",
"description": "CSS styles used with html_content.",
"example": "h1{font-size:32px;}"
},
"wait_till": {
"type": "number",
"description": "Wait time in ms before rendering screenshot/PDF.",
"example": "10000"
},
"full_page": {
"type": "boolean",
"description": "Capture full scroll height for URL rendering.",
"example": "true"
},
"viewPortWidth": {
"type": "number",
"description": "Viewport width in px.",
"example": "1080"
},
"viewPortHeight": {
"type": "number",
"description": "Viewport height in px.",
"example": "720"
},
"output_format": {
"type": "string",
"description": "Return file URL or binary file response.",
"example": "url"
},
"output_filename": {
"type": "string",
"description": "Output filename (without extension).",
"example": "document"
}
},
"required": []
}
}
}
},
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": true
},
"data": {
"type": "object",
"description": "Endpoint-specific response payload."
}
}
}
}
}
}
}
}
}
},
"components": {
"securitySchemes": {
"ApiKeyAuth": {
"type": "apiKey",
"in": "header",
"name": "CLIENT-API-KEY"
}
}
}
}