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

Use browser automation to capture an invoice page as an image, or generate a PDF directly if the deliverable needs to be a PDF. They are different outputs: a screenshot records rendered pixels, while a PDF is laid out according to the page’s print or screen styles. With Playwright, open the invoice, wait for its content, and call either a screenshot method or page.pdf(). The workflow below shows both approaches and how to validate the result before storing it.

Choose the file you actually need

Decide whether the goal is to preserve the invoice as it appears on screen, or to create a PDF document. A screenshot is an image of rendered content; it may be useful for a visual record, but text and layout are not the same as a document PDF. A generated PDF is usually the better choice when the file must be a PDF, especially if the page provides a print layout.

  • Visible viewport: Capture only the portion currently visible in the browser.
  • Invoice element: Capture a specific invoice container while excluding navigation, buttons, and other application chrome.
  • Full page: Capture the full scrollable page as one image. This can make a long invoice hard to read or cumbersome to store.
  • PDF: Generate a PDF from the page rather than taking an image and converting it. Playwright’s PDF method uses print CSS by default; you can emulate screen media first if you need the screen-styled version. See the Playwright Page API.

The Playwright screenshots and PDF CLI guide also documents viewport, element, and full-page captures, plus PDF export.

Automate an invoice capture with Playwright

This Node.js example opens an invoice page, waits for an invoice-specific element, and saves either an element screenshot or a PDF. Replace the URL and selector with the ones used by your application. It assumes the invoice page can be opened without a login step; see the authentication note below if it cannot.

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.

Install Playwright

  1. Install Node.js for your environment.
  2. In a new project directory, run npm init -y.
  3. Install Playwright with npm install playwright.
  4. Install the browser binaries with npx playwright install chromium.

Save this script as capture-invoice.mjs

import { chromium } from 'playwright';

const invoiceUrl = process.env.INVOICE_URL;
const invoiceSelector = process.env.INVOICE_SELECTOR ?? '[data-testid="invoice"]';
const output = process.env.OUTPUT ?? 'invoice.png';
const format = process.env.FORMAT ?? 'png';

if (!invoiceUrl) {
  throw new Error('Set INVOICE_URL to the invoice page URL.');
}
if (!['png', 'jpeg'].includes(format)) {
  throw new Error('FORMAT must be png or jpeg.');
}

const browser = await chromium.launch({ headless: true });
try {
  const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
  const response = await page.goto(invoiceUrl, {
    waitUntil: 'domcontentloaded',
    timeout: 60000,
  });

  if (!response || !response.ok()) {
    throw new Error(`Invoice navigation failed: HTTP ${response?.status() ?? 'no response'}`);
  }

  const invoice = page.locator(invoiceSelector);
  await invoice.waitFor({ state: 'visible', timeout: 30000 });

  if (process.env.FORMAT === 'pdf') {
    await page.pdf({ path: output, format: 'A4', printBackground: true });
  } else if (process.env.SCOPE === 'full-page') {
    await page.screenshot({ path: output, fullPage: true, type: format });
  } else {
    await invoice.screenshot({ path: output, type: format });
  }
  console.log(`Saved ${output}`);
} finally {
  await browser.close();
}

Run an element screenshot with INVOICE_URL='https://example.com/invoices/123' OUTPUT='invoice.png' node capture-invoice.mjs. For a full-page image, set SCOPE=full-page. To create an A4 PDF, set FORMAT=pdf OUTPUT='invoice.pdf'. The selector in this example is illustrative; use a stable selector actually present on the invoice page.

Choose a reliable readiness signal

domcontentloaded means the initial document has been parsed; it does not guarantee that client-rendered invoice details or images are ready. The script then waits for a visible invoice element. Prefer an invoice-specific heading, total, or container that appears only when the record is loaded. Waiting for a fixed number of seconds can be useful for a known animation or delayed resource, but it is less reliable than waiting for the content your capture depends on.

If a logo or other image is still missing when the capture occurs, wait for that image to finish loading as well. If the page updates after the invoice container first appears, wait for the final state you need, such as a settled status label. Do not wait for network idle by default on applications that maintain persistent connections; they may never become idle.

Make the image or PDF match the intended invoice

Viewport, element, and full-page screenshots

The example uses an element screenshot by default, which avoids capturing surrounding application controls. If the invoice itself is not a single stable element, capture the viewport with page.screenshot({ path: output, type: format }), or use fullPage: true to capture the scrollable document. Full-page images can become extremely tall; check their legibility at the size at which they will be reviewed or printed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

Playwright supports PNG and JPEG screenshots and exposes options for full-page capture, quality, scaling, and masking in its API documentation. JPEG quality is relevant when saving JPEG output; do not set it for PNG. For a reproducible capture, choose the browser viewport deliberately and keep it consistent across runs. If invoice content is responsive, a different viewport can change line wrapping and pagination.

PDF rendering and print styles

page.pdf() produces a PDF and follows print CSS by default. A site may hide navigation in print, change colors, or paginate the invoice differently from the browser screen. If you need the screen presentation in the PDF, call await page.emulateMedia({ media: 'screen' }) before page.pdf(). If you need a print-ready document, leave print media selected and inspect page breaks, margins, and background colors in the result. The API supports PDF options such as paper format, margins, landscape orientation, and page ranges; consult the current Page API reference for exact option names and behavior.

Do not assume that a PDF exported from the page and a screenshot converted into a PDF are interchangeable. The former uses browser document rendering and print rules; the latter simply places an image into a document. Choose the image-based route only when preserving the visual pixels is the requirement.

Run it safely for invoices

  • Use the application’s supported authentication flow. The sample opens a URL directly and does not implement sign-in. For a private invoice, automate the application’s intended login or provide browser state through a controlled, secure mechanism. Do not put passwords, session cookies, or bearer tokens in source code, shell history, or filenames.
  • Protect captured files. Invoices can contain names, addresses, tax details, and payment information. Restrict output directories, access, retention, and log contents to what the workflow requires. Avoid placing personal or payment data in filenames; a non-sensitive invoice identifier may be enough if your storage policy permits it.
  • Validate before forwarding or archiving. Confirm that the output belongs to the intended invoice record and that the date, line items, totals, and any required status are visible. A successful browser call only establishes that a file was written, not that it is the correct invoice.
  • Make the workflow repeatable. Use explicit output paths and a stable selector. If processing multiple records, handle each record independently so one missing or inaccessible invoice does not silently produce a misleading file.

Troubleshooting common capture failures

The script reports that the invoice selector timed out

The selector may not exist on that page, may have changed, or may only appear after sign-in. Inspect the rendered page and replace the example selector with a stable invoice-specific locator. Also verify that navigation reached the expected invoice rather than a login or error page.

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.
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.

The file exists but is blank or incomplete

A page can return successfully before its application has rendered the invoice. Wait for the visible invoice content and any critical delayed elements, then capture. If the document is long, use full-page capture or a PDF instead of assuming everything is in the viewport.

The PDF looks different from the browser

That is often a rendering-mode difference: PDF generation uses print CSS by default. Inspect the site’s print layout; if the screen version is required, emulate screen media before generating the PDF. Also verify paper size, margins, orientation, and page breaks.

Navigation fails or returns an unexpected response

Check that the URL is correct and reachable from the machine running the browser. A private page may redirect to sign-in, and a site may reject automated access. Use only the site’s supported access method and review its policies; do not treat a timeout or access-denied page as a completed invoice capture.

Capture works locally but not in a scheduled job

Confirm that the scheduled environment has the same Playwright package and Chromium browser installed, can reach the invoice application, and has access to any required credentials or state. Use explicit timeouts and output directories, and make failures visible in job logs without logging secrets.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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

Where Adobe Acrobat and PDF Services fit

Do not assume that automating a desktop copy of Acrobat is an approved substitute for browser capture. Adobe’s article, last updated 2025-06-02, says enterprise automation of a licensed Acrobat copy through scripts or RPA is not permitted except for the Acrobat Pro Action Wizard allowance it describes; it characterizes that allowance as user-initiated tasks on the same client machine that do not interact with third-party applications. Check current license terms and product documentation before designing around Acrobat: Adobe Acrobat automation and document workflows.

Adobe PDF Services is a separate option for downstream PDF work. Adobe describes APIs for creating, converting, transforming, securing, and extracting PDF content, and lists Microsoft Power Automate and UiPath integrations. Those capabilities may fit a document-processing workflow after capture, but the service overview does not establish that it captures browser screenshots: Adobe PDF Services API.

Acrobat’s Snapshot Tool is a manual way to select and print a page region, not an automated invoice capture workflow. See the Acrobat DC Reference for that documented procedure.

Or skip the browser setup

For a page accessible at a URL, ScreenshotNeo can return a screenshot image or PDF from one GET request. Its clean-capture steps accept cookie or consent banners and remove 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 report 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 with no card; paid plans start at $5 for 3,000 shots. See the ScreenshotNeo API documentation for available parameters and response details.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://example.com/invoices/123 
  -o invoice.webp

This is a URL-based capture, not a replacement for a Playwright flow that must first sign in and navigate an application. ScreenshotNeo also accepts custom headers and cookies, but handle any credentials as secrets and consult its documentation before applying them to a private invoice. Start with 1,000 free screenshots a month, with no card required.

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.

Keep the output dependable

For a single run, success means more than a file appearing on disk: the right record must have loaded, the chosen capture scope must include all required details, and the PDF or image must be readable. For a recurring workflow, record non-sensitive run status, handle navigation and selector failures explicitly, and verify a sample of stored outputs. A browser capture is a visual artifact; if the business process needs structured invoice data, use a suitable document extraction step rather than relying on the screenshot alone.

Frequently Asked Questions

Can I automate screenshots from invoices inside a private account?

Yes, if you automate the application’s supported authentication and access flow, but the example script itself does not sign in. Keep credentials and session state out of source code and logs.

Can a screenshot prove that an invoice was paid?

Not by itself. It records visible page content; confirm invoice status against the application or system of record when payment state matters.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy 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.