A service that generates PDFs from web pages using Puppeteer.
Convert a webpage to PDF format.
{
"url": "https://example.com",
"goto": {
// Optional Puppeteer GoTo options
// See: https://pptr.dev/api/puppeteer.gotooptions
},
"pdf": {
// Optional PDF generation options
// See: https://pptr.dev/api/puppeteer.pdfoptions
}
}
/api/render?url=https://example.com
- URLs must be valid and properly formatted
- If
ALLOWED_PREFIXES
environment variable is set, URLs must start with one of the allowed prefixes - If
ALLOWED_PREFIXES
is empty, all valid URLs are allowed
- CORS restrictions are enforced based on the
ALLOWED_CORS
environment variable - If
ALLOWED_CORS
is empty, all origins are allowed - Origins must match exactly with the whitelist entries
- Content-Type:
application/pdf
- Body: PDF file buffer
{
"status": "error",
"message": "Invalid URL"
}
{
"status": "error",
"message": "This URL is not allowed"
}
Variable | Description | Format |
---|---|---|
ALLOWED_PREFIXES |
Comma-separated list of allowed URL prefixes | prefix1, prefix2, ... |
ALLOWED_CORS |
Comma-separated list of allowed CORS origins | origin1, origin2, ... |
curl -X POST https://pdf-api.mass.build/api/render \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com"}'
curl -X POST https://pdf-api.mass.build/api/render \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"pdf": {
"format": "A4",
"printBackground": true
}
}'
curl https://pdf-api.mass.build/api/render?url=https://example.com