AWS Lambda PDF Generator is a serverless web service that accepts an HTML document over a REST API and returns a rendered PDF file — all without managing a single server. Built for developers and teams that need reliable, on-demand PDF generation inside an AWS environment, it deploys entirely within your own AWS account using the Serverless framework, AWS API Gateway, and AWS Lambda. Under the hood, a headless Chromium browser (loaded from a Lambda Layer) renders the HTML with full CSS and JavaScript support before Puppeteer captures the output as a PDF binary.Documentation 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.
Quickstart
Deploy the service and generate your first PDF in under 10 minutes.
Deployment
Configure stages, regions, and AWS permissions for your deployment.
API Reference
Explore the
/print endpoint request schema and response formats.Architecture
Understand how API Gateway, Lambda, and the Chromium Layer work together.
How It Works
Every PDF is generated through a single HTTP round-trip. The client sends aPOST request containing the HTML source to the API Gateway endpoint. API Gateway forwards the request payload to the Lambda function, which parses the JSON body and launches a headless Chromium browser via @sparticuz/chromium. Puppeteer loads the HTML into a new browser page, waits for all network activity to settle (networkidle0), then calls page.pdf() to render the page as a PDF binary. The binary is returned directly in the HTTP response with a Content-Type: application/pdf header.
The flow in summary:
- Client — sends
POST /printwith a JSON body containinghtml(required),source(optional label), andsettings(optional Puppeteer PDF options). - AWS API Gateway — receives the request, enforces CORS, and proxies the payload to Lambda.
- AWS Lambda — runs the Node.js 20.x handler, loads Chromium from the attached Lambda Layer, and starts Puppeteer.
- Puppeteer + Chromium — renders the HTML document fully (including CSS and JavaScript) and generates a PDF binary.
- Response — the Lambda function returns the PDF binary to API Gateway, which streams it back to the client as
application/pdf.
ARM architecture is not currently supported. The
@sparticuz/chromium Lambda Layer that provides the headless Chromium binary has not yet released ARM-compatible builds, so the service must be deployed to x86_64 Lambda functions. Follow the @sparticuz/chromium project for updates on ARM support.Technology Stack
The service is built entirely on open-source tooling and managed AWS services:- Serverless Framework v3 — infrastructure-as-code tool that provisions and deploys API Gateway, Lambda, and IAM resources from a single
serverless.ymlconfiguration. - AWS API Gateway — HTTP endpoint that receives client requests, handles CORS, and proxies events to the Lambda function.
- AWS Lambda (Node.js 20.x) — serverless compute runtime that executes the PDF generation handler with 2,048 MB of memory and a 30-second timeout.
- Puppeteer v22 (
puppeteer-core22.4.0) — high-level browser automation library used to load HTML content and callpage.pdf()to produce the PDF output. - Chromium v122 (via AWS Lambda Layer) — headless browser engine packaged as a Lambda Layer artifact (
chromium-v122.zip) and mounted at runtime. @sparticuz/chromium122.0.0 — Node.js package that provides the correct Chromium executable path, launch arguments, and graphics-mode configuration tuned for the Lambda execution environment.