About this endpoint
What it does
Renders the HTML you send into a PDF, with right-to-left layout and Arabic fonts. Returns the PDF as base64 inside JSON, or as raw application/pdf bytes.
Request Body
| Parameter | Type | Description |
|---|---|---|
| html | String | Required. The HTML to render. A fragment or a full document. Length: 1 to 3,000,000 characters. |
| css | String | Extra CSS applied to the page. Length: 1 to 500,000 characters. |
| font | ENUM | Arabic font family. Allowed values: naskh, kufi, sans, amiri. Default: naskh. |
| format | ENUM | Page size. Allowed values: A4, A5, Letter, Legal, receipt-80mm, receipt-58mm. Default: A4. |
| direction | ENUM | Text direction. Allowed values: auto, rtl, ltr. Default: auto, which uses rtl when the content has Arabic. |
| landscape | Boolean | Render the page in landscape orientation. Default: false. |
| margin_mm | Number | Page margin in millimetres. Range: 0 to 40. |
| header_html | String | HTML for the page header. Length: 1 to 20,000 characters. |
| footer_html | String | HTML for the page footer. Length: 1 to 20,000 characters. |
| page_numbers | Boolean | Add page numbers. Default: false. |
| output | ENUM | Response format. Allowed values: base64, binary. Default: base64. binary returns the PDF bytes with Content-Type: application/pdf. |
| filename | String | Download name sent in the Content-Disposition header when output is binary. Must match ^[\w.\- ]{1,100}$. Default: document.pdf. Ignored for base64. |
Response
Returns a JSON object with data (the PDF and its size) and meta (request details). With output set to binary, the body is the PDF file instead.
| Parameter | Type | Description |
|---|---|---|
| data.pdf_base64 | String | The PDF file, base64 encoded. Starts with JVBERi (%PDF). |
| data.bytes | Integer | Size of the PDF in bytes, before base64 encoding. |
| data.pages | Integer | Number of pages in the PDF. |
| meta.request_id | String | Request identifier, for example req_434ed7a6101436fa. Quote it in support requests. |
| meta.version | String | API version. Currently v1. |
Errors return a JSON object with error and meta.request_id.
| Parameter | Type | Description |
|---|---|---|
| error.code | String | validation_error when the input does not match the schema, render_failed when the page could not be rendered. |
| error.message | String | Short human-readable summary. |
| error.field | String | The request field that failed validation. Present for validation_error only. |
| error.detail | String | What exactly was wrong, for example body/html must NOT have fewer than 1 characters. |
| error.docs | String | Link to the provider's documentation for this error. |
Notes
- Success returns HTTP
201forbase64and HTTP200forbinary. Validation and render errors return HTTP422. - Scripts in the HTML do not run. Send the final, already-built page.
- Embed images as
data:URIs so the PDF does not depend on outside servers. - Large pages take longer. In testing, 100,000 characters of text rendered in about 3.4 seconds (24 pages). Pages of 250,000 characters and more timed out or returned
render_failed. - Extra fields are rejected with
validation_error.



