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

Automatically generating an invoice image means rendering structured invoice data through a repeatable template. Your application supplies fields such as invoice number, seller and buyer details, line items, totals, dates, notes, logo and accent color; a renderer produces a PNG (or, when a document is preferable, a PDF). This removes one-off design work while keeping every invoice consistent.

The reliable workflow is: validate and localize the data, render an HTML/CSS invoice, wait for fonts and images, capture the page at a fixed size, then store and deliver the resulting file. The same data model can feed an invoice-image API, a PDF document-generation service, or an accounting platform.

Choose the output before you build

Need Best fit Important trade-off
Image for an email, portal preview or social-sized attachment PNG or JPEG rendering Text is rasterized; recipients cannot select or reflow it.
Conventional invoice delivery, printing or archival PDF generation Pagination, fonts and paper margins require document-layout testing.
Invoices inside a billing system Accounting or billing API Branding and attachment features do not necessarily render an invoice image.

A documented HTML-to-image invoice template returns a 1240 × 1754 sRGB PNG by default and can return PDF instead. Treat those dimensions as the vendor’s specification, not an independently tested benchmark. The documented payload includes invoice number, business and client information, line items, totals, logo URL and accent color.

Design a stable invoice data model

Keep calculation and presentation separate. Store money as decimal values or integer minor units, not binary floating-point numbers, and calculate subtotal, tax and grand total on the server. Then pass already formatted strings to the template when locale-specific output is required.

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.
{
  "invoiceNumber": "INV-2026-0042",
  "issueDate": "2026-09-29",
  "dueDate": "2026-10-29",
  "currency": "USD",
  "business": {"name":"Northwind Studio","address":"10 Market Street","taxId":"US-EXAMPLE"},
  "client": {"name":"Example Client","address":"20 High Street"},
  "items": [
    {"description":"Website maintenance","quantity":"2","unitPrice":"450.00","amount":"900.00"}
  ],
  "subtotal":"900.00",
  "taxLabel":"Sales tax (8.25%)",
  "tax":"74.25",
  "total":"974.25",
  "notes":"Payment due by the date shown above.",
  "logoUrl":"https://example.com/logo.png",
  "accentColor":"#2457A6"
}

Validate before rendering

  • Require a unique invoice number, seller, buyer, currency, line items and total.
  • Reject negative quantities or prices unless your business rules explicitly support credits.
  • Check that the sum of line amounts, subtotal, tax and total reconcile after rounding.
  • Allow per-customer tax labels and prepare currency strings for the buyer’s locale.
  • Limit description length or define wrapping rules so a long item cannot break the layout.
  • Fetch logos from an allowed, reliable source and provide an alt-text or fallback mark.

DIY method: render HTML and capture it

HTML/CSS gives you precise control over branding and is easy to preview in a browser. The example below uses Node.js and Playwright. Install it with npm install playwright, then install the browser binary required by your environment. The script writes a PNG; change the output option to create a PDF.

1. Create the template

<!-- invoice.html -->
<!doctype html>
<html><head><meta charset="utf-8">
<style>
@page { size: A4; margin: 0; }
* { box-sizing: border-box; }
body { margin:0; background:#eef1f5; font:14px Arial,sans-serif; color:#202630; }
.sheet { width:1240px; min-height:1754px; margin:0 auto; padding:72px 80px; background:#fff; }
.header { display:flex; justify-content:space-between; border-bottom:4px solid var(--accent); padding-bottom:28px; }
h1 { margin:0; color:var(--accent); font-size:38px; }
.meta { text-align:right; line-height:1.7; }
.columns { display:grid; grid-template-columns:1fr 1fr; gap:60px; margin:42px 0; }
.label { color:#687386; text-transform:uppercase; font-size:11px; letter-spacing:.08em; }
table { width:100%; border-collapse:collapse; margin-top:24px; }
th,td { padding:16px 12px; border-bottom:1px solid #dfe4eb; text-align:left; }
th:last-child,td:last-child { text-align:right; }
.totals { width:360px; margin:28px 0 0 auto; }
.total { font-size:22px; font-weight:bold; color:var(--accent); }
.footer { margin-top:80px; color:#687386; white-space:pre-wrap; }
</style></head><body>
<main class="sheet" style="--accent: {{accentColor}}">
  <header class="header"><div><img src="{{logoUrl}}" style="max-width:220px;max-height:70px" alt="Business logo"><h1>INVOICE</h1></div>
  <div class="meta"><strong>{{invoiceNumber}}</strong><br>Issued: {{issueDate}}<br>Due: {{dueDate}}</div></header>
  <section class="columns"><div><div class="label">From</div><strong>{{business.name}}</strong><br>{{business.address}}<br>{{business.taxId}}</div>
  <div><div class="label">Bill to</div><strong>{{client.name}}</strong><br>{{client.address}}</div></section>
  <table><thead><tr><th>Description</th><th>Qty</th><th>Unit price</th><th>Amount</th></tr></thead><tbody>{{itemsRows}}</tbody></table>
  <div class="totals">Subtotal: {{subtotal}}<br>{{taxLabel}}: {{tax}}<hr><div class="total">Total: {{total}}</div></div>
  <div class="footer">{{notes}}</div>
</main></body></html>

Use a real HTML escaping function when inserting text. Do not concatenate untrusted descriptions, notes or addresses directly into markup. If you support logos from arbitrary URLs, proxy or allow-list them to avoid leaking browser requests and to make rendering deterministic.

2. Render and capture with Node.js

import { chromium } from 'playwright';
import fs from 'node:fs/promises';

const invoice = JSON.parse(await fs.readFile('invoice.json', 'utf8'));
const esc = s => String(s ?? '').replace(/[&<>"']/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
const rows = invoice.items.map(i => `<tr><td>${esc(i.description)}</td><td>${esc(i.quantity)}</td><td>${esc(i.unitPrice)}</td><td>${esc(i.amount)}</td></tr>`).join('');
let html = await fs.readFile('invoice.html', 'utf8');
const values = {
  accentColor: esc(invoice.accentColor || '#2457A6'), logoUrl: esc(invoice.logoUrl || ''),
  invoiceNumber: esc(invoice.invoiceNumber), issueDate: esc(invoice.issueDate), dueDate: esc(invoice.dueDate),
  'business.name': esc(invoice.business.name), 'business.address': esc(invoice.business.address), 'business.taxId': esc(invoice.business.taxId),
  'client.name': esc(invoice.client.name), 'client.address': esc(invoice.client.address), itemsRows: rows,
  subtotal: esc(invoice.subtotal), taxLabel: esc(invoice.taxLabel), tax: esc(invoice.tax), total: esc(invoice.total), notes: esc(invoice.notes)
};
for (const [key, value] of Object.entries(values)) html = html.replaceAll(`{{${key}}}`, value);
const browser = await chromium.launch({headless:true});
const page = await browser.newPage({ viewport: { width:1240, height:1754 }, deviceScaleFactor:1 });
await page.setContent(html, { waitUntil:'networkidle' });
await page.evaluate(() => document.fonts.ready);
await page.screenshot({ path:'invoice.png', fullPage:true, type:'png' });
// PDF alternative: await page.pdf({ path:'invoice.pdf', format:'A4', printBackground:true });
await browser.close();

Use an invoice-image or document API instead

An invoice-image endpoint is practical when you do not want to maintain browser infrastructure. Send the documented fields as JSON, receive a hosted file URL, and save or pass that URL to your billing workflow. A PDF document-generation API follows the same pattern: provide structured JSON and a template, then deliver the generated PDF. Adobe’s documented example uses Node.js, JavaScript, Express, HTML and CSS, while noting that production data must be fetched from an external API. Salesforce documents individual and batch invoice PDF generation in Lightning Experience for Enterprise, Unlimited and Developer editions with a Revenue Cloud Billing license.

FreshBooks documents presentation settings such as fonts, colors, logos and banners, plus uploading image or PDF attachments. Those capabilities can support an accounting workflow, but an attachment API should not be treated as an image renderer unless its documentation explicitly says it renders the invoice.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Localization and layout checks

  • Format dates and currency for the recipient’s locale, including decimal separators, symbol placement and currency code.
  • Use the customer’s tax terminology rather than a hard-coded “sales tax” label.
  • Test zero-tax, reverse-charge, discount, credit and multi-rate cases.
  • Render the longest realistic product description and the largest customer name.
  • Check missing logos, slow logo hosts, broken fonts, right-to-left text and page overflow.
  • Keep a stable template version with each generated invoice so later CSS changes do not alter old documents.

Performance, reliability and cost controls

Browser rendering consumes more memory and startup time than a direct file service. Reuse a browser process for batches, set a bounded navigation timeout, wait for fonts and images, and close pages after each job. Queue large batches instead of launching one browser per invoice. Cache immutable logos and template assets, but never cache an invoice whose data can change unless its invoice identifier and version are part of the cache key.

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.

Store the source JSON alongside the output and record template version, locale, currency, generation time and a content hash. Retry transient asset or network failures with a limit; do not silently issue a second invoice number. Before delivery, verify that the output exists, has the expected MIME type and is not an empty or partial file.

The cited materials do not establish comparative pricing, throughput or reliability for the available providers, so select on integration, licensing, output and controls rather than unsupported performance claims.

Troubleshooting

Blank or partly rendered image

Cause: capture occurred before fonts, images or client-side data finished loading. Fix: wait for network idle, await document.fonts.ready, wait for a specific logo selector, and use a bounded delay only as a fallback.

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

Text overlaps or spills onto another page

Cause: untested long descriptions, unexpected font metrics or fixed-height containers. Fix: allow wrapping, set minimum row heights, test worst-case data and inspect at the target viewport and device scale.

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.

Wrong totals

Cause: floating-point arithmetic, premature rounding or recalculating values in the template. Fix: calculate once on the server using decimal-safe arithmetic, pass formatted values, and compare the rendered totals with the source record.

Logo or remote asset is missing

Cause: blocked request, expired URL, certificate issue or cross-origin policy. Fix: use an accessible HTTPS asset, proxy it through an allow-listed host, or embed a validated data URL; provide a text fallback.

PDF looks different from PNG

Cause: print CSS, page margins and pagination differ from screen capture. Fix: define @page, enable print backgrounds, choose one paper size, and test PDF separately rather than assuming the PNG layout transfers unchanged.

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

Salesforce feature is unavailable

Cause: edition or license mismatch. The documented Salesforce workflow requires Lightning Experience, Enterprise, Unlimited or Developer edition, and a Revenue Cloud Billing license. Confirm those prerequisites with your administrator.

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
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo can capture a hosted invoice HTML page with one request. Publish your rendered invoice at a URL, then call the API (see the ScreenshotNeo documentation):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/invoices/INV-2026-0042 -o invoice.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://example.com/invoices/INV-2026-0042"}, timeout=90)
r.raise_for_status()
open("invoice.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com/invoices/INV-2026-0042' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
await Bun.write('invoice.webp', res);

ScreenshotNeo accepts options for full-page capture, CSS selectors, viewport and device presets, retina scale, PDF paper settings, custom CSS or JavaScript, waits, headers, cookies, user agent, timezone, geolocation, transparent backgrounds, resizing, caching, signed links, asynchronous jobs, webhooks and bulk capture. Before capture it can accept consent banners and remove more than 60 known consent platforms, newsletter popups and chat widgets. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info and capture_pdf for AI agents.

The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

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

FAQ

Should an invoice be PNG or PDF?

Use PNG when an image preview or raster attachment is specifically required. Use PDF when selectable text, printing or conventional document delivery matters.

Can I generate invoices directly from an accounting system?

Yes, when its API exposes invoice data or document generation. Verify whether its branding and attachment features actually render a new image.

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.

How do I prevent a template change from altering old invoices?

Persist the source data, output file and template version for each invoice, and regenerate only when your accounting policy permits it.

Frequently Asked Questions

Should an invoice be PNG or PDF?

Use PNG for an image preview or raster attachment; use PDF for selectable text, printing or standard document delivery.

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

Can I generate invoices directly from an accounting system?

Yes, if its API exposes invoice data or document generation. Confirm that branding and attachment features render an invoice rather than merely storing a file.

How do I keep old invoices unchanged after a redesign?

Store the original data, generated file and template version, and regenerate only under an explicit accounting policy.

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.