Skip to main content

Setting HTML content

You can set the HTML content of the page to render dynamically generated content as well.

danger

When this propriety is set, the url propriety must not be present.

Rest API (Without Stealth)

Here’s the request in the specified format, with examples for curl, JavaScript, Python, Java and C#.

Bot detection

Browserless recommends using our REST API to generate PDFs, unless you need to get past bot detectors.

curl -X POST \
https://production-sfo.browserless.io/pdf?token=YOUR_API_TOKEN_HERE \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"html": "<h1>Hello World!</h1>",
"options": {
"displayHeaderFooter": true,
"printBackground": false,
"format": "A0"
}
}'
warning

We do not allow to set a options.path

BQL (Stealth)

If the /pdf API is getting blocked by bot detectors, then we would recommend trying BrowserQL.

curl --request POST \
--url 'https://production-sfo.browserless.io/chromium/bql?token=YOUR_API_TOKEN_HERE' \
--header 'Content-Type: application/json' \
--data '{"query":"mutation PDF {\ncontent(html: \"<h1>Hello, World!</h1>\") {\n status\n}\n\npdf(displayHeaderFooter: true, printBackground: false, format: a0) {\n base64\n}\n}","variables":"","operationName":"PDF"}'
BQL Schemas

For more details on BQL mutations, refer to the BrowserQL Schema reference pages.