The PDF Generator can be exercised at two distinct stages of the development lifecycle: locally before any AWS resources exist, and against the live deployed endpoint after a successfulDocumentation 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.
yarn deploy:prod or yarn deploy:stage. Local invocation uses the Serverless CLI to simulate the Lambda execution environment on your machine, which is useful for rapid iteration. Post-deployment testing validates the full AWS path — API Gateway, Lambda cold start, Chromium layer, and S3 large-response handling — using plain HTTP clients such as curl.
Local Testing
Local invocation runs the Lambda handler directly on your machine using the Serverless framework’sinvoke local command. No AWS credentials or live infrastructure are needed; the framework resolves environment variables from serverless.yml and loads the handler from source.
Navigate to the API package
All
sls commands must be run from within the packages/api directory, where serverless.yml is located:Invoke with the standard test payload
Run the The file The
print function using the bundled test event file:print/test/print.json contains a pre-built API Gateway proxy event. Its body field is a base64-encoded JSON string that decodes to:isBase64Encoded: true flag instructs the handler to decode the body before passing it to Puppeteer, mirroring exactly how API Gateway forwards binary-encoded POST requests.Invoke with the 5 MB stress-test payload
To verify that large-payload handling works correctly (including the S3 fallback path for responses that exceed Lambda’s 6 MB synchronous response limit), use the 5 MB test fixture:This payload contains a significantly larger HTML document and exercises the code path that writes the PDF to S3 and returns a pre-signed URL instead of embedding the binary directly in the Lambda response.
Testing the Deployed Endpoint
After a successful deployment, the Serverless framework prints the base URL of your API Gateway stage to the console. Use that URL to send live HTTP requests.Convert HTML to PDF — POST /print
Send an HTML document in the request body and save the binary PDF response to a local file:
--output result.pdf flag writes the raw PDF bytes returned by the service directly to disk. Open result.pdf in any PDF viewer to confirm a successful conversion.
Read service metadata — GET /service/version
Verify that the service is reachable and inspect its version metadata:
Interpreting Results
| HTTP Status | Meaning | Common cause |
|---|---|---|
| 200 OK | PDF generated successfully | The response body is a binary application/pdf document |
| 400 Bad Request | Request validation failed | The required html field is missing or the request body is malformed JSON |
| 500 Internal Server Error | Server-side processing error | Chromium failed to launch, Puppeteer encountered a rendering error, or the S3 large-response bucket is unreachable |
Replace
{api-identifier} and {stage} in the example URLs with the actual values printed by the Serverless framework after deployment. For example, a production endpoint might look like https://abc123xyz.execute-api.us-east-1.amazonaws.com/prod/print.