Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteThe right JavaScript method depends on where the HTML lives. For an element already displayed in a user’s browser, use html2canvas to reconstruct the DOM as a canvas and export that canvas as a JPEG. For a pixel-accurate capture of a page or remote URL, use a real browser such as Playwright. If you do not want to run a browser yourself, use a hosted screenshot API.
Choose the rendering method first
These approaches all produce a JPG, but they do not capture the same thing.
| Approach | Where it runs | Input | What is rendered | Best fit |
|---|---|---|---|---|
| html2canvas | The visitor’s browser | An element or the current document | A DOM/CSS reconstruction drawn onto a canvas | Exporting a card, invoice, chart or other element already on your page |
| Playwright | Your Node.js process and an automated browser | A navigated URL, page or element | The browser’s rendered output | Automated tests, server-side jobs and high-fidelity page captures |
| Hosted screenshot service | The provider’s browser infrastructure | A URL or supplied HTML, depending on the service | A managed browser capture | Remote URLs when operating Chromium yourself is undesirable |
html2canvas’s own documentation is explicit about the distinction: its result is based on information available in the DOM and “may not be 100% accurate to the real representation” because it does not make an actual screenshot. That difference matters for complex CSS, embedded frames and externally hosted images.
Convert an element to a downloadable JPG with html2canvas
Use this recipe when the element is in the current page and your JavaScript can read its contents.
#1 Best Overall
- User-Friendly Portable Photo Printer for iPhone, Android & PC - Get beautiful and colourful memories with Liene 4x6 photo printer! After opening the entire package, you can find one cartridge + 20 sheets of photo paper (placed inside the machine packaging), as well as an additional box containing 80 sheets of photo paper (which includes two cartridges + 80 sheets of photo paper). Full package includes smartphone photo printer, Liene 4x6 photo printer papers (100 sheets), 3 colour cartridges, and fully sealed cassette to prevent dust. Minimalist and magnetic design for compact storage.
- Superior Quality 4x6 Photo Printer - Print photos like no other thanks to the thermal-dye sublimation tech adopted by the picture printer for iphone. The dyes deeply penetrate the paper for vibrant photo printing, and the laminated surface is resistant to water, scratches, fingerprints and fading. Clean the print head promptly if smudges are observed on printed photos during operation. Get Liene photo printers now for yourself and your loved ones, print your happy moments together and keep your love forever!
- Wi-Fi Photo Printer for Smartphone - The built-in hotspot of the photo printer makes it easy to print pictures from your phone, avoiding outside interference with a fast and stable connection. No other networks required! Simply connect your device to the independent instant photo printer 4x6 hotspot.
- Multiple Device Compatibility - Liene phone printer provides instant photo printing for up to 5 simultaneous connections. Share with family and friends or print from your different devices. No additional cables or Bluetooth required when printing photos with this picture printer. Note: Ensure the ink cartridge clicks into place before printing.
- Customize your Printing with the Liene App - Customize your photos with our specialized App! You can add a Square border, insert filters, enhance the contrast and brightness, check printing status, and more. You can even print your ID and Visa photos from home with this photo printer for iphone 4x6 prints.
1. Mark up the element
<section id="receipt">
<h1>Order 1042</h1>
<p>Paid — 29 September 2026</p>
</section>
<button id="download-jpg" type="button">Download JPG</button>
2. Render the element and export JPEG data
import html2canvas from 'html2canvas';
const button = document.querySelector('#download-jpg');
const element = document.querySelector('#receipt');
button.addEventListener('click', async () => {
try {
const canvas = await html2canvas(element, {
backgroundColor: '#ffffff',
scale: window.devicePixelRatio
});
// The second argument is JPEG quality: 0 is smallest, 1 is highest.
const jpegUrl = canvas.toDataURL('image/jpeg', 0.9);
const link = document.createElement('a');
link.href = jpegUrl;
link.download = 'receipt.jpg';
link.click();
} catch (error) {
console.error('Could not export the element:', error);
}
});
The important sequence is select, await the render, export, then download. html2canvas(element) returns a promise for a canvas; it does not itself create a JPG file. The canvas’s toDataURL('image/jpeg', quality) method performs the format conversion.
Control size, crop and background
scalecontrols the canvas resolution. A higher scale gives more pixels but uses more memory. Device-pixel scaling can make text sharper on high-density displays.- Use
backgroundColor: '#ffffff'when the source has transparent areas that should appear white in the JPG. - JPEG has no transparency. If transparent pixels must remain transparent, export PNG instead with
canvas.toDataURL('image/png'). - Capture a smaller child element when you need a predictable image rather than the complete document.
Wait for images, fonts and dynamic content
Start the capture only after the content you expect is present. In practice this means waiting for application data, letting web fonts finish loading and checking that important images have completed. A short delay can be useful for animations or charts, but it is better to wait on an application-specific promise or state change than to rely on an arbitrary timeout.
await document.fonts.ready;
await Promise.all(
[...document.images]
.filter(image => !image.complete)
.map(image => new Promise(resolve => {
image.addEventListener('load', resolve, { once: true });
image.addEventListener('error', resolve, { once: true });
}))
);
const canvas = await html2canvas(document.querySelector('#receipt'));
This readiness code does not make a cross-origin image readable; it only ensures that the browser has finished trying to load it.
Capture a full page or a remote URL with Playwright
Playwright launches a real browser, so it is the stronger choice when you need the browser-rendered result, a URL that is not the current document, or a repeatable server-side job. Its screenshot API supports JPEG, a quality value from 0 to 100, scaling and full-page capture.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Rank #2
- Dock Photo Printer: The KODAK Dock Plus is a home photo printer that produces high-quality 4x6” prints directly from compatible smartphones. Featuring an integrated docking station, users can place their phone on the printer for better connection while simultaneously charging the device during printing.
- Genuine 4PASS dye sublimation printing: Each photo is produced in three color layers and finished with a clear protective lamination layer. In approximately 55 seconds, you receive a smooth, detailed print designed to resist fingerprints, water, and fading for long-lasting quality.
- Easy to Use: Print photos quickly without complicated setup or technical steps. Simply power on, connect wireless bluetooth, and start printing within seconds. The Dock Plus is built for straightforward operation, making it ideal for first time users and everyday photo printing.
- Home Printing Station: Designed for stable desktop use, this dock photo printer connects to a power outlet for consistent performance and larger 4x6” prints. Ideal for home printing, photo albums, framing, family events, and everyday picture printing.
- KODAK Photo Printer APP: Featuring integrated Bluetooth connectivity, this portable printer connects to compatible iOS and Android devices through the KODAK Photo Printer app. Edit, crop, and customize your photos before printing for creative results.
Install and capture a full-page JPEG
import { chromium } from 'playwright';
const browser = await chromium.launch();
const page = await browser.newPage({
viewport: { width: 1440, height: 900 },
deviceScaleFactor: 1
});
await page.goto('https://example.com', { waitUntil: 'networkidle' });
await page.screenshot({
path: 'example-full.jpg',
type: 'jpeg',
quality: 85,
fullPage: true
});
await browser.close();
fullPage: true extends the capture beyond the visible viewport. The quality setting is JPEG-specific; Playwright documents 80 as the default when you do not supply one. Choose a lower value for smaller files and a higher value when small text or fine lines are important.
Capture one element instead of the whole page
const card = page.locator('[data-export="card"]');
await card.screenshot({
path: 'card.jpg',
type: 'jpeg',
quality: 90
});
Locators wait for the element to be available before taking the screenshot. You still need to make sure its data, fonts and images are ready; an element can exist while its contents are still loading.
Handle authentication and browser state
For a protected page, establish the session before navigation or create the context with the required cookies and headers. Keep credentials out of source control. If the page depends on a particular viewport, color scheme, timezone or locale, set those on the browser context so automated captures are consistent.
Use a hosted HTML-to-image endpoint when you do not want to run Chromium
Hosted services generally offer one of two models. An HTML endpoint accepts supplied markup and may execute inline scripts; a screenshot endpoint navigates to a URL and allows that page’s own scripts to run. The HTML-to-image documentation for one such service describes a 30-second execution budget for inline scripts and supports waiting for a selector or a delay. Those limits and options are provider-specific, so check the endpoint’s current documentation before designing a long-running render.
Rank #3
- 2x3" Portable Photo Printer: The upgraded PP01 photo printer uses advanced inkjet technology. This portable photo printer produces vivid, full-color prints on premium sticky-backed photo paper that is smudge-proof, water-resistant, and tear-resistant. The Nelko mini photo printer is pocket-sized and weighs only 308g, making it ultra-portable for school, travel, and field trips. Each ink cartridge prints up to 80 full-color 2x3 photos on sticky-backed paper
- Easy Printing via Bluetooth: The PP01 mini photo printer is compatible with iOS and Android phones via Bluetooth. Simply download the Nelko app from Google Play or the App Store. Load the 2x3 photo paper with the smooth side facing down. Install the ink cartridge, connect via Bluetooth, and print directly using the Nelko app. A USB charging cable is included; the adapter is not included
- High Photo Quality: This mini photo printer uses advanced inkjet technology for clear, vibrant prints. This portable photo printer produces 600 DPI high-resolution images with precise colors, capturing fine details and realistic tones. Each photo comes with adhesive backing, perfect for scrapbooks and preserving your memories. Personalize every photo for holidays, birthdays, or daily events
- Powerful App: The Nelko 2x3" PP01 photo printer app lets you edit photos and offers a variety of frame designs, making it perfect for personalizing your photos for projects like scrapbooking or journaling. Download the Nelko app to create collages and customize photos with filters, graffiti, borders, stickers, text, AI image editing, and many other features. Edit photos on your phone, then send them to the Nelko app for instant printing in under 90 seconds
- Versatile Usage Scenarios: This portable photo printer is ideal for travel journals, party favors, and family gatherings. Students use it for planners and photo printing. Crafters use it for DIY projects, custom labels, and scrapbooking. It's a practical tool for bloggers, small businesses, and event photographers to create instant giveaways. Perfect for Mother's Day surprises and heartfelt moments with loved ones using Nelko sticky-backed photo paper.
A hosted browser is useful for scheduled URL captures, serverless functions with no browser package, or a service that needs consistent rendering across many jobs. It also moves browser patching, process isolation and scaling out of your application. The trade-off is another network dependency and the provider’s rules for authentication, request headers, retention and billing.
Or skip the browser setup: ScreenshotNeo
ScreenshotNeo is a website screenshot API and MCP server for developers. One GET request returns a PNG, JPEG, WebP or PDF. It is a practical alternative when your input is a remote URL and you would rather not install or operate Playwright.
Use the API documentation at https://screenshotneo.com/docs/ for the complete option list. The service supports full-page captures with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets plus custom viewports, retina scale, PDF paper and page controls, HTML/CSS-to-image, custom JavaScript and CSS, pre-capture clicks, hidden selectors, waits for selectors, delays or network idle, request and resource blocking, custom headers, cookies, user agents and Authorization, timezone and geolocation, transparent backgrounds, resizing, configurable-TTL caching, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify migration.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
The same request from 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)
And from 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(`Screenshot failed: ${res.status}`);
const bytes = new Uint8Array(await res.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('shot.webp', bytes));
ScreenshotNeo removes cookie and consent banners, newsletter popups and chat widgets before capture; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the page result and billing status with X-Page-Verdict and X-Billed headers. Its MCP server exposes take_screenshot, get_page_info and capture_pdf for Claude, Cursor and other MCP clients.
| Plan | Included shots | Price |
|---|---|---|
| Free | 1,000 per month | $0, no card |
| Starter | 3,000 | $5 |
| Growth | 15,000 | $15 |
| Pro | 60,000 | $39 |
| Scale | 250,000 | $99 |
| Business | 1,000,000 | $249 |
Every feature is available on every plan, and yearly billing provides two months free. You can sign up for 1,000 free screenshots a month with no card.
Rank #4
- Dual 4x6" & 3x3" Photo Printer Paper Tray Convenience: Seamlessly print both 6-inch standard photo paper and 3-inch sticky-backed paper with our innovative dual tray design. This compact phone photo printer for smartphone offers easy storage and quick access, making it perfect for diverse printing needs without taking up much space. Enjoy vibrant, high-quality prints every time.
- Fast Bluetooth Connectivity: Experience lightning-fast printing with our liene photo printer's Bluetooth connection, which pairs in just 13 seconds. Enjoy a seamless and efficient printing experience, perfect for capturing and sharing memories on the go without the hassle of cables or complex setups.
- Superior Quality Photo Printer 4x6 - Print photos like no other thanks to the thermal-dye sublimation tech adopted by the picture printer for iphone. The dyes deeply penetrate the paper for vibrant photo printing, and the laminated surface is resistant to water, scratches, fingerprints and fading. Get Liene photo printers now as amazing gifts for yourself and your loved ones, print your happy moments together and keep your love forever!
- Multiple Device Compatibility - Liene picture printer for iphone provides instant photo printing for up to mutiple simultaneous connections. Share with family and friends or print from your different devices. No additional cables required when printing photos with this phone printer.
- Customize your Printing with the Liene App - Customize your photos with our specialized App! You can add a Polaroid border, insert filters, enhance the contrast and brightness, check printing status, and more. You can even print your ID and Visa photos from home with this iphone photo printer for 4x6 & 3x3 prints.
Security and fidelity limits you must plan for
Cross-origin images can taint the canvas
When html2canvas encounters an image hosted on another origin, the image server must allow the browser’s CORS request or the image may be omitted. If an image taints the canvas, calls such as toDataURL() can fail with a security exception. Setting useCORS: true asks html2canvas to make a CORS request; it cannot override the image server’s response headers or browser security rules. A proxy is another documented option, but it must fetch and serve the asset with appropriate permissions.
Cross-origin iframes are a hard boundary
JavaScript on one origin cannot read the document inside a cross-origin iframe. html2canvas therefore cannot faithfully render that iframe’s contents. Capture the framed page separately, use a same-origin integration, or use an automated browser or hosted service that is authorized to load the target.
DOM reconstruction is not pixel identity
Unsupported CSS, browser-specific painting, filters, video, canvas content and timing-sensitive effects can differ in an html2canvas export. If the requirement is “what a user sees in Chromium,” Playwright or a hosted browser is the safer architecture.
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 →JPEG is lossy
JPEG reduces file size by discarding image information and cannot represent transparency. Use a higher quality for text-heavy interfaces, compare the resulting file size, and choose PNG when lossless pixels or alpha transparency are required.
Best Value
- Instant Photo Printing: The KODAK Mini 2 Retro is a portable photo printer designed to turn smartphone pictures into high quality prints in seconds. Whether capturing family moments, travel highlights, journaling pages, or creative projects, this mini printer lets you print real photos anytime, anywhere.
- Genuine 4PASS dye sublimation printing: Each photo is produced in three color layers and finished with a clear protective lamination layer. In approximately 55 seconds, you receive a smooth, detailed print designed to resist fingerprints, water, and fading for long-lasting quality.
- Easy to Use: Print photos quickly without complicated setup or technical steps. Simply power on, connect wireless bluetooth, and start printing within seconds. The Mini 2 Retro is built for straightforward operation, making it ideal for first time users and everyday photo printing.
- Print Anytime, Anywhere: Small enough to fit in your hand, bag, or even a pocket, the Mini 2 Retro is built for on-the-go printing. Ideal for parties, trips, school projects, scrapbooks, and spontaneous moments where you want real prints without waiting.
- KODAK Photo Printer APP: Featuring integrated Bluetooth connectivity, this portable printer connects to compatible iOS and Android devices through the KODAK Photo Printer app. Edit, crop, and customize your photos before printing for creative results.
Troubleshooting common failures
- “The canvas is tainted” or
toDataURLthrows: identify external images and fonts, configure CORS on the asset server, serve the asset through an approved proxy, or move the capture to Playwright or a hosted browser. - Images are missing: wait for image loading, confirm the final image URL is reachable, and check whether its origin permits CORS. Lazy-loaded images may require scrolling or an explicit capture option that loads them.
- The JPG is blank or captures a loading shell: wait for application data, fonts and animations to settle. In Playwright, use a meaningful readiness condition rather than assuming that navigation completion means the page is visually ready.
- Text wraps differently: fix the viewport, device scale, font availability and zoom. A remote font that fails to load can change layout before either library captures it.
- Only the visible portion is captured: html2canvas captures the element you pass; select the intended container and size it deliberately. In Playwright, add
fullPage: truefor the whole document. - Playwright cannot start: install the Playwright browser binaries in the deployment image, provide the required sandbox permissions for that environment, and verify that the process has enough memory for the chosen viewport and page.
- A protected URL returns a login page: pass the required cookies or authorization headers in the browser context or API request. Never expose reusable credentials in a client-side bundle.
- A transparent design turns black or unexpected in JPEG: set an explicit background before exporting or switch to PNG.
Performance, reliability and cost decisions
- Client-side html2canvas: no server or browser fleet is required, but rendering consumes the user’s CPU and memory and is limited by that page’s security boundaries.
- Playwright: a browser process adds startup and memory overhead. Reuse a browser where safe, create isolated contexts per job, close pages, and cap concurrency so several full-page captures do not exhaust the host.
- Hosted capture: your application avoids browser operations and can submit asynchronous or bulk jobs, but it depends on network availability and the provider’s quotas and billing rules.
- Reduce output cost: capture only the required element, choose a reasonable viewport and scale, use an appropriate JPEG quality, and cache deterministic pages when the freshness requirement allows it.
A practical decision checklist
- Is the source an element in the current browser page? Start with html2canvas.
- Must the image match the browser’s painted output, include a remote URL, or run on a server? Use Playwright or a hosted browser.
- Does the page contain cross-origin images or iframes you cannot configure? Do not promise a client-side DOM export; move capture to an authorized browser environment.
- Do you need a repeatable service, bulk jobs, cleanup of consent UI or AI-agent access? Evaluate ScreenshotNeo’s API and MCP server.
- Choose JPEG only when lossy output and no transparency are acceptable; otherwise export PNG.
FAQ
Can html2canvas run in Node.js?
No. Its documented getting-started guidance targets browser execution. For Node.js, use Playwright or a hosted browser endpoint.
What does the JPEG quality number mean?
For canvas export, the quality argument is a value from 0 to 1; for Playwright’s JPEG screenshot option it is documented as 0 to 100. Higher values generally preserve more detail and create larger files.
Can I turn an arbitrary public URL into a JPG from front-end JavaScript?
Not reliably with html2canvas: your page cannot read another origin’s DOM, and its assets may be blocked by CORS. Navigate an automated browser to the URL or call a hosted screenshot API instead.
Frequently Asked Questions
Can html2canvas run in Node.js?
No. Its documented getting-started guidance targets browser execution. For Node.js, use Playwright or a hosted browser endpoint.
What does the JPEG quality number mean?
For canvas export, the quality argument is a value from 0 to 1; for Playwright’s JPEG screenshot option it is documented as 0 to 100. Higher values generally preserve more detail and create larger files.
Can I turn an arbitrary public URL into a JPG from front-end JavaScript?
Not reliably with html2canvas: your page cannot read another origin’s DOM, and its assets may be blocked by CORS. Navigate an automated browser to the URL or call a hosted screenshot API instead.
The Bottom Line
Use html2canvas for a readable element already in the browser, Playwright for a browser-faithful page or URL, and ScreenshotNeo when you want the hosted browser and cleanup work handled through one API call.
Free tools Windows power users keep installed
One-click scans. No signup required.
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.

