TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/barchart/aws-lambda-pdf-generator/llms.txt
Use this file to discover all available pages before exploring further.
POST /print endpoint returns one of three HTTP response types. A 200 OK is returned when PDF generation succeeds, delivering the binary PDF directly in the response body. A 400 Bad Request is returned when the request is malformed — most commonly because the required html field is absent. A 500 Internal Server Error is returned when Puppeteer or headless Chromium encounters an unexpected failure during rendering. Both error responses share the same JSON envelope shape, making client-side error handling straightforward.
200 — Success
When PDF generation succeeds, the API returns the binary PDF file directly in the response body.- Content-Type:
application/pdf - Body: Raw binary PDF data
curl to send a minimal request and save the returned PDF to disk:
- Gzip-compressed — The response body is compressed and includes a
Content-Encoding: gzipheader. Most HTTP clients and libraries decompress this automatically. - S3 redirect — The response is an HTTP
303 See Otherwith aLocationheader pointing to a pre-signed Amazon S3 URL where the PDF can be downloaded. Most HTTP clients follow this redirect automatically.
400 — Bad Request
A400 response is returned when the request body fails validation. The most common cause is omitting the required html field.
- Content-Type:
application/json - Error code:
PRINT_FAILED_HTML_MISSING
value object with a machine-readable code and a human-readable message, plus a children array for nested failure details.
Top-level failure descriptor for this error item.
An array of nested failure objects. Empty for top-level validation errors.
500 — Internal Server Error
A500 response is returned when Puppeteer or headless Chromium encounters an error during PDF generation. This may be caused by a malformed HTML document that triggers a renderer crash, an unhandled exception in the Lambda handler, or an infrastructure-level problem.
- Content-Type:
application/json - Error code:
REQUEST_GENERAL_FAILURE
400 response.
Example response:
Large Response Handling
AWS Lambda and API Gateway impose payload size limits that can be exceeded by large generated PDFs. The service handles this transparently using two strategies: Gzip compression — If the PDF can be reduced to an acceptable size through compression, the response is returned inline with aContent-Encoding: gzip header. Verify your HTTP client is configured to decompress gzip responses (most are by default).
S3 pre-signed URL redirect — If the compressed PDF still exceeds the payload limit, the service uploads the file to Amazon S3 and returns an HTTP 303 See Other response. The Location header contains a time-limited pre-signed S3 URL from which the PDF can be retrieved. Most HTTP clients (including curl with -L and browser fetch) follow 303 redirects automatically.
For deeper background on these two strategies and how to configure them, see Large Responses.