What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
To render an HTML template to an image with Puppeteer, launch Chromium, load the markup with page.setContent(), wait for the template’s actual assets and application code to be ready, then call page.screenshot(). Set the viewport and device scale explicitly so the output has predictable dimensions. For a template already hosted at a URL, use page.goto() instead.
Render an HTML string to an image
This Node.js example saves a full-page PNG from markup held in a string. Install Puppeteer in your project first with npm install puppeteer; the package manages its compatible browser installation as part of its normal setup.
import puppeteer from 'puppeteer';
const html = `
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body { font: 16px Arial, sans-serif; margin: 0; padding: 32px; }
.card { background: #f2f5f8; border-radius: 12px; padding: 24px; }
</style>
</head>
<body>
<main class="card">
<h1>A rendered template</h1>
<p>Puppeteer captures the page after it has rendered.</p>
</main>
</body>
</html>`;
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.setViewport({ width: 1200, height: 800, deviceScaleFactor: 1 });
await page.setContent(html, { waitUntil: 'networkidle0' });
await page.screenshot({ path: 'render.png', fullPage: true, type: 'png' });
} finally {
await browser.close();
}
setContent() writes the HTML into the page; it is appropriate for a template string you construct or load in your application. networkidle0 waits for network activity to settle, but it is not a universal guarantee that every font, image, or application task is ready. Choose a readiness check that reflects the template, as described below.
Load a template from a URL instead
If the template is served by your application, navigate to its URL rather than copying its markup into setContent(). This preserves the page’s normal document URL and makes relative resource URLs resolve against that page.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
- 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.
await page.goto('https://example.com/template', { waitUntil: 'networkidle0' });
await page.screenshot({ path: 'render.png', fullPage: true, type: 'png' });
The Puppeteer screenshot guide demonstrates launching a browser, creating a page, navigating with a readiness condition, and capturing it with page.screenshot(). For HTML held as a string, the Page API provides page.setContent(). See the Puppeteer Screenshots guide and Page API reference.
Wait for the template—not just the network
There is no single wait condition that proves every page is visually complete. A quiet network can still precede application rendering, and JavaScript may change the page after a navigation event. Conversely, long-lived connections can prevent a network-idle condition from occurring. Use the signal that matches the page you render.
Wait for an application-ready marker
If you control the template, have its JavaScript set a marker after data and layout are ready. Then wait for that marker before capturing:
// In the template's application code, set this after rendering is complete:
// document.documentElement.dataset.renderReady = 'true';
await page.waitForFunction(() =>
document.documentElement.dataset.renderReady === 'true'
);
await page.screenshot({ path: 'render.png', fullPage: true });
For a marker represented by an element instead, use await page.waitForSelector('[data-render-ready="true"]'). The marker should be set only after the data and layout required in the screenshot are present.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsRank #2
- 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.
Wait for images and fonts when they matter
For ordinary document images, check that they have completed and decoded before capture. If the template uses web fonts, wait for the document’s font readiness promise too:
await page.waitForFunction(async () => {
const images = [...document.images];
const imagesReady = images.every(image => image.complete);
await document.fonts.ready;
return imagesReady;
});
This check covers images already present in the document; it does not itself reveal off-screen lazy-loaded images or wait for application code that inserts more assets later. If images load after scrolling, trigger the page’s lazy-load behavior first, then wait for those images and fonts. For dynamic templates, combine asset checks with the application-ready marker rather than treating either check as a substitute for the other.
Choose what to capture and how it looks
Puppeteer’s screenshot options let you choose the capture area, dimensions, format, and background. Configure the viewport before the page renders when layout depends on screen size.
| Need | Approach |
|---|---|
| Visible viewport only | Call page.screenshot({ path: 'view.png' }) without fullPage. |
| Entire document | Set fullPage: true. |
| One component | Find the element and call its screenshot() method. |
| Exact rectangle | Pass a clip rectangle to page.screenshot(). |
| Transparent background | Use omitBackground: true where a transparent output is appropriate. |
| Lossy image compression | Choose a supported lossy format and set quality; the option is format-dependent. |
For an element capture, for example:
const card = await page.$('.card');
if (!card) throw new Error('Template card was not found');
await card.screenshot({ path: 'card.png' });
For a rectangle, define its coordinates and dimensions in the page:
Rank #3
- 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.
await page.screenshot({
path: 'region.png',
clip: { x: 20, y: 30, width: 600, height: 400 }
});
Set the viewport deliberately. CSS pixels determine layout; deviceScaleFactor controls the output pixel density. A higher device scale factor produces more image pixels for the same CSS-sized viewport, which can improve sharpness but also increases output dimensions and file size. Keep the viewport, scale, template data, font sources, and image URLs stable when you need repeatable results.
Handle lazy content and dynamic templates
A full-page capture expands the captured area, but it does not guarantee that every lazy-loaded image has been requested or that every asynchronous component has finished rendering. Trigger the loading behavior your page expects before taking the screenshot. One simple approach for pages that load content as the user scrolls is to scroll through the document, then return to the top and wait for the application’s readiness condition:
await page.evaluate(async () => {
const step = Math.max(1, window.innerHeight);
for (let y = 0; y < document.body.scrollHeight; y += step) {
window.scrollTo(0, y);
await new Promise(resolve => setTimeout(resolve, 100));
}
window.scrollTo(0, 0);
});
await page.waitForFunction(() =>
document.documentElement.dataset.renderReady === 'true'
);
await page.screenshot({ path: 'full.png', fullPage: true });
The delay in this example is an application-specific opportunity for scroll-triggered loading, not a guarantee that a particular site is ready. Prefer explicit completion signals from your own template. If content or assets come from remote services, make those inputs deterministic where possible; changing data, fonts, or image sources can change the result even with identical screenshot settings.
Image output versus PDF
Use page.screenshot() for PNG, JPEG, or WebP image output. Use page.pdf() when the deliverable is a paginated PDF. Puppeteer’s PDF generation uses print CSS by default; if you want screen styles in the PDF, call page.emulateMediaType('screen') before page.pdf(). A screenshot and a PDF are different outputs, so choose based on whether the recipient needs pixels or a document with pages.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Rank #4
- 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
await page.emulateMediaType('screen');
await page.pdf({ path: 'render.pdf', format: 'A4' });
See the Puppeteer Page.pdf API reference for PDF behavior and options.
Reliability, runtime, and cost considerations
- Close the browser in a finally block. This prevents ordinary capture errors from leaving the launched browser process behind.
- Keep each job bounded. Add application-level timeouts around navigation and readiness waits so a stalled resource or missing marker does not hold a worker indefinitely.
- Control concurrency. Each browser page and its rendered assets consume resources. Limit simultaneous captures according to the memory and CPU available to your deployment rather than assuming more parallel pages are always faster.
- Expect variability from external assets. Remote font and image servers, page scripts, and network conditions can affect both readiness and output. Self-host or cache stable inputs when your use case permits.
- Size output intentionally. Full-page captures and high device scale factors can create large images. Choose the capture scope and scale the consumer actually needs.
- Account for infrastructure separately. Puppeteer’s documentation does not establish a universal capture latency or hosting cost. Your cost depends on where Chromium runs, workload, concurrency, and assets.
Troubleshooting Puppeteer image rendering
The screenshot is blank or missing part of the template
Check whether the HTML was assigned to the page, whether scripts completed, and whether the chosen wait condition actually represents visual readiness. For application-rendered markup, wait for a marker or expected selector before capturing. Inspect console errors and failed requests if the page depends on scripts or remote assets.
Images or fonts are absent
Confirm that asset URLs are valid in the rendering context and that the browser can reach them. Relative URLs in content loaded with setContent() may not behave like resources in a normally navigated document; use absolute resource URLs or navigate to the template’s served URL. Wait for images and fonts explicitly, and trigger lazy loading if required.
networkidle0 never completes
A page may keep network connections open or continue requesting resources. Use a different navigation condition where suitable, then wait for a concrete selector, application-ready marker, or required assets. Do not remove the readiness check entirely if the page renders asynchronously.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Best Value
- 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.
The output is clipped, unexpectedly sized, or blurry
For a complete document, set fullPage: true; for a particular component or region, use the element or clip capture instead. Set the viewport before rendering, and adjust deviceScaleFactor when output pixel density is the issue. Verify the resulting dimensions against the CSS layout size and scale.
Transparency does not appear
Use omitBackground: true and ensure the chosen output format and downstream viewer preserve transparency. A template that paints its own background remains opaque regardless of the browser’s default background setting.
Or skip the browser setup
If you need a hosted endpoint rather than managing Chromium, ScreenshotNeo can render a URL with one GET request and return an image or PDF. It also provides options for HTML/CSS-to-image rendering. For URL capture, the cURL example below saves a WebP response; see the ScreenshotNeo API documentation for request parameters and response details.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots.
Recommended Free Tools
Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.
Frequently Asked Questions
Can Puppeteer return the screenshot without saving a file?
Yes. Omit the path option and page.screenshot() returns image data that your application can store or send.
Can I render HTML to an image without opening a visible browser window?
Yes. Puppeteer can launch Chromium in headless mode; its normal launch configuration is headless.
Quick Recap
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.

