Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a currently supported Lambda runtime for a new function. AWS lists nodejs18.x as deprecated, with function-creation blocking scheduled for February 1, 2027 and function-update blocking for March 3, 2027. If Node.js 18 is an existing compatibility requirement, you can still apply the deployment pattern below, but verify the dates in AWS’s runtime table before shipping. The same architecture works on a supported Node.js runtime after you confirm that your Chromium distribution and browser library support it.

The difficult parts are not the page.pdf() call: you must package a Linux-compatible Chromium binary, fit it within Lambda’s deployment limits, allocate enough memory and temporary storage, and test the result with the fonts, images and network conditions your HTML actually uses.

What you need to decide first

  • Runtime: Treat Node.js 18 as a legacy constraint. Select a currently supported Node.js runtime for new functions, then verify browser-library support for that runtime.
  • Browser stack: Choose a maintained Chromium distribution and a compatible Puppeteer (or equivalent) release. Confirm Linux compatibility, version, architecture (x86_64 or arm64) and launch arguments from that package’s documentation. No single pairing is universally safe.
  • Deployment format: Use a ZIP/layer when the complete artifact fits Lambda’s limits; evaluate a container image when Chromium and native libraries make ZIP packaging impractical.
  • Resources: Size memory, timeout and /tmp storage from measurements of your largest PDFs, not from the service maximums.

AWS recommends putting the SDK modules and other dependencies a function uses in the deployment package or a Lambda layer. Keep the browser binary and native libraries in the same artifact strategy, and inspect the final artifact rather than estimating from source-code size.

ZIP versus container image

Deployment Limits and characteristics Use it when
ZIP (direct upload) 50 MB zipped maximum for direct Lambda API or SDK upload. The combined unzipped function and layer contents cannot exceed 250 MB. A larger ZIP may be uploaded through Amazon S3, but the 250 MB unzipped ceiling still applies. Your measured Chromium, native libraries and application fit the limits and your team prefers the simpler ZIP workflow.
Container image Lambda’s documented maximum uncompressed image size is 10 GB. AWS supplies Node.js base images with the runtime and Lambda Runtime Interface components. You need more control over OS libraries or the ZIP artifact is too large or difficult to reproduce.

Container images do not make an oversized or unmaintained browser installation a good design. Build in an environment compatible with the target Lambda operating system and architecture, pin versions, and inspect the resulting image. AWS describes three Node.js image approaches: AWS Node.js base images, AWS OS-only base images, and non-AWS base images.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Lambda handler: render HTML and return a PDF

The following handler is a deployment template, not a claim that a particular Chromium package/version has been validated. It uses puppeteer-core and expects your chosen Chromium distribution to expose an executable path through CHROMIUM_PATH. Before deploying, install versions that explicitly support your selected Lambda runtime and architecture, then test the complete artifact in a Lambda-like environment.

const puppeteer = require('puppeteer-core');

exports.handler = async (event) => {
  const html = event.html || '<!doctype html><html><body><h1>PDF test</h1></body></html>';
  const browser = await puppeteer.launch({
    executablePath: process.env.CHROMIUM_PATH,
    headless: true,
    args: [
      '--no-sandbox',
      '--disable-setuid-sandbox',
      '--disable-dev-shm-usage'
    ]
  });

  try {
    const page = await browser.newPage();
    await page.setContent(html, { waitUntil: 'networkidle0' });
    await page.emulateMediaType('print');
    const pdf = await page.pdf({
      format: 'A4',
      printBackground: true,
      preferCSSPageSize: true,
      margin: { top: '16mm', right: '16mm', bottom: '16mm', left: '16mm' }
    });

    return {
      statusCode: 200,
      headers: { 'Content-Type': 'application/pdf' },
      isBase64Encoded: true,
      body: pdf.toString('base64')
    };
  } finally {
    await browser.close();
  }
};

networkidle0 waits until there are no active network connections. For pages with analytics, long polling or deliberately delayed content, use a bounded wait strategy instead: wait for a specific selector, wait for fonts/images, or use a short delay followed by an explicit readiness check. Do not let an unbounded page wait consume the whole invocation timeout.

Handling a URL instead of an HTML string

const target = event.url;
if (!target || !/^https?:///i.test(target)) {
  throw new Error('event.url must be an http(s) URL');
}
await page.goto(target, { waitUntil: 'networkidle0', timeout: 60000 });
const pdf = await page.pdf({ format: 'A4', printBackground: true });

Validate and authorize URLs in your own API layer. Otherwise, a public function can become a server-side request forgery proxy. Decide how authentication, cookies, custom headers and private network access are supplied; none is automatic merely because Chromium runs inside Lambda.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Packaging and configuration checklist

  1. Select the runtime. For a new function, choose a supported Node.js runtime. Keep Node.js 18 only when a migration or compatibility constraint requires it, and record an upgrade plan.
  2. Pin and verify the browser stack. Confirm the selected Chromium distribution’s supported runtime, architecture, executable path and required shared libraries. Confirm the Puppeteer release expects the same browser revision or document the supported combination.
  3. Build for Lambda’s Linux environment. Native modules compiled on an incompatible workstation can fail at startup. Build in a compatible Linux environment or use a container build that targets the Lambda architecture.
  4. Install production dependencies. Copy the handler, lockfile-resolved production modules, Chromium binary and required libraries into the ZIP or image. Do not rely on development-only files that are omitted by your packaging command.
  5. Inspect the artifact. For ZIP, check both compressed size and uncompressed size, including layers. For a container, inspect the uncompressed image size and verify the browser executable and shared libraries exist at runtime.
  6. Set Lambda resources. Configure memory, timeout and ephemeral storage, then measure cold starts, rendering time and peak disk use with representative documents.
  7. Return or store the result deliberately. A synchronous API response is convenient for small PDFs. Larger output may require object storage and a signed download URL; choose that pattern based on your payload and retention requirements.

Memory, timeout and /tmp sizing

Lambda allows 128 MB through 10,240 MB of memory and a maximum standard timeout of 900 seconds (15 minutes). Memory also affects available CPU. These are platform ceilings, not recommended PDF settings. Start with a realistic value, then test the largest HTML, embedded images, web fonts and concurrent invocations you expect.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Ephemeral storage at /tmp defaults to 512 MB and can be configured from 512 MB through 10,240 MB. Chromium extraction, its cache, downloaded assets and temporary PDF files can all consume this space. Increase it when measurements show a need, and remove files you create. The directory is temporary and unique to each execution environment; never treat it as durable storage.

What to measure

  • Cold-start time, including browser extraction and launch.
  • Time spent loading HTML and remote assets.
  • Peak memory while rendering the largest page.
  • Peak /tmp usage and PDF size.
  • Failure rate for missing fonts, blocked resources, timeouts and malformed HTML.

No generic latency, success-rate or cost benchmark applies to every Chromium build. Measure your own document mix and concurrency.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

PDF fidelity details that commonly surprise developers

Fonts and print CSS

Install or bundle every font you require, and wait for document.fonts.ready before calling page.pdf(). Use print styles deliberately: Chromium prints the page’s print media by default, and printBackground: true is needed for colored backgrounds. preferCSSPageSize: true honors a CSS @page size when present.

Images and lazy content

Lazy-loaded images may not exist when the PDF command runs. Scroll through the document or trigger the application’s loading mechanism, then wait for image completion:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.evaluate(async () => {
  for (const img of document.images) img.loading = 'eager';
  await Promise.all(Array.from(document.images).map(img =>
    img.complete ? Promise.resolve() : new Promise(resolve => {
      img.addEventListener('load', resolve, { once: true });
      img.addEventListener('error', resolve, { once: true });
    })
  ));
  await document.fonts.ready;
});

Page breaks and very large documents

Use CSS such as break-inside: avoid for table rows or cards, and test long tables across page boundaries. A single huge DOM can increase memory and timeout pressure; split independent documents when your workflow permits.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Security and reliability safeguards

  • Restrict outbound destinations or validate URLs to reduce SSRF risk.
  • Set navigation and operation timeouts; handle failed requests explicitly.
  • Do not place secrets in HTML sent to an untrusted URL. Pass private credentials through controlled headers or cookies and avoid logging them.
  • Close the browser in a finally block so failures do not leave a process running.
  • Log a request identifier, render phase and error class, but avoid logging full private HTML.
  • Test both architectures if you may migrate between x86_64 and arm64; a binary built for one cannot simply be reused on the other.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common errors and fixes

Symptom Likely cause Fix
Failed to launch the browser process Wrong executable path, missing shared library, incompatible architecture or unsupported launch flags. Log and verify the path inside the deployed artifact; inspect native dependencies; rebuild for the Lambda architecture and follow the selected package’s documented flags.
ZIP rejected or deployment succeeds but import fails Compressed or uncompressed package exceeds a limit, or production dependencies were omitted. Measure the final ZIP including layers, prune unused files, or move to a container image. Run the handler with the exact production install.
Function times out during navigation Slow or hanging remote resources, network restrictions or an overly broad network-idle wait. Set bounded navigation timeouts, wait for a known selector, reduce third-party resources and verify VPC egress/DNS.
Blank or incomplete PDF Rendering started before fonts, images or client-side data finished. Wait for application readiness, fonts and images; capture console and page-error events during diagnosis.
No space left on device Chromium, cache, assets or output exhausted /tmp. Increase ephemeral storage within the documented range, disable unnecessary caching, delete temporary files and monitor peak usage.
Layout differs from local Chrome Different browser revision, fonts, viewport, timezone or media settings. Pin the browser stack, bundle fonts, set viewport/timezone explicitly and compare PDFs in a Lambda-like environment.

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server when you need a rendered capture without maintaining Chromium in Lambda. It accepts a URL and returns PNG, JPEG, WebP or PDF. Before capture it accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server exposes take_screenshot, get_page_info and capture_pdf for Claude, Cursor and other MCP clients.

One-call example (see the ScreenshotNeo documentation for options):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

You can also use Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Or Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
require('fs').writeFileSync('shot.webp', Buffer.from(await res.arrayBuffer()));

Every feature is included on every plan. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to try it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

FAQ

Can I create a new Lambda function with Node.js 18?

AWS lists the managed runtime as deprecated and schedules creation blocking for February 1, 2027. Use a supported runtime for new work and reserve Node.js 18 for explicitly managed legacy deployments.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Should I always use a container image for Chromium?

No. A ZIP is appropriate when the complete measured artifact fits the 50 MB direct-upload and 250 MB uncompressed limits. Choose a container when native dependencies or reproducibility make that route more practical.

Is increasing memory enough to solve PDF failures?

No. Failures can come from architecture mismatches, missing libraries, fonts, network access, navigation waits or /tmp exhaustion. Diagnose the failing phase and measure the corresponding resource.

Frequently Asked Questions

Where should the generated PDF be stored?

Return it synchronously only when the response size and invocation pattern suit your API. For larger or asynchronous workflows, store the bytes in durable object storage and return a controlled download URL.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do Lambda layers remove the ZIP size limit?

No. Function and layer contents count toward Lambda’s combined uncompressed ZIP limit, so measure the complete deployment.

Can Chromium use arm64 on Lambda?

Only if the exact Chromium distribution and its native dependencies support arm64. Verify the package documentation and build artifact; do not assume an x86_64 binary will run there.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.