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 accepts a JSON request body with three top-level fields. Only html is required — the complete HTML document you want converted to a PDF. The optional source field attaches a label to Lambda log output for tracing, and the optional settings object is forwarded verbatim to Puppeteer’s page.pdf() method, giving you full control over paper size, margins, orientation, and more.
Schema
The complete HTML document to convert to a PDF. Must be a valid HTML string. Supports inline CSS, embedded JavaScript (though scripts do not execute during Puppeteer rendering by default), and standard HTML5 elements. Maximum size is bounded by API Gateway’s 10 MB request limit.
An optional identifier for the request. Used in Lambda log output to correlate log entries with a particular request origin. Has no effect on the generated PDF itself.Example values:
"annual-report", "invoice-12345", "crude-oil-price-report".An options object passed directly to Puppeteer’s
page.pdf() method. If omitted, Puppeteer defaults are used (Letter format, no background printing, 1× scale). See the Puppeteer settings Reference below for the most commonly used fields.Full Example
The following request generates a styled A4 PDF with background colors, custom margins, and asource label for log correlation.
Minimal Example
Only the requiredhtml field is needed. Puppeteer defaults (US Letter, portrait, no background) are applied when settings is omitted.
Puppeteer settings Reference
The settings object is passed verbatim to Puppeteer’s page.pdf() call inside the Lambda handler. Every key-value pair you provide here maps directly to a Puppeteer PDF option. The table below covers the most commonly used properties.
| Property | Type | Description |
|---|---|---|
format | string | Paper format: Letter, Legal, Tabloid, Ledger, A0–A6 |
width | string | number | Page width, e.g. "210mm" (overrides format) |
height | string | number | Page height, e.g. "297mm" (overrides format) |
landscape | boolean | Landscape orientation (default: false) |
printBackground | boolean | Print CSS background colors/images (default: false) |
scale | number | Scale factor 0.1–2 (default: 1) |
margin.top | string | Top margin, e.g. "1cm", "10px" |
margin.bottom | string | Bottom margin |
margin.left | string | Left margin |
margin.right | string | Right margin |
displayHeaderFooter | boolean | Display header/footer template (default: false) |
headerTemplate | string | HTML template for the print header |
footerTemplate | string | HTML template for the print footer |
The full list of supported options is defined by Puppeteer’s PdfOptions. The service passes the
settings object verbatim to page.pdf(), so all Puppeteer v22 options are supported.