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

First check what the invoice actually is: if it is rendered as a webpage, use Playwright’s page.pdf(); if the portal provides a PDF attachment, capture its download instead. For an e-Invoice, check the relevant portal’s official PDF or print option before creating a browser printout. These routes produce different artifacts, and GST invoices do not all use the same portal or interface.

Choose the right way to save the invoice

What the portal displays Use Important distinction
Invoice content rendered in the browser as HTML page.pdf() Creates a PDF from the page; print CSS is used by default.
A portal control that downloads a PDF attachment page.expect_download() and save_as() Saves the file provided by the portal rather than printing the page.
An e-Invoice with an official PDF or print facility Use the relevant portal’s own facility where available Portal access, formats, and steps vary. A browser-generated PDF is not automatically signed or authenticated e-Invoice data.

For the GSTN e-Invoice facility documented in its manual, users log in and select PDF or JSON to download an e-Invoice; the facility is unavailable in pre-login mode. The manual also says generated files remain in Download History for two days, after which they must be generated again. See the GSTN e-Invoice download manual.

The IRIS IRP portal FAQ describes a print flow using an acknowledgement number or a 64-character IRN and says signed JSON can be converted to PDF for sharing. Those directions apply to that portal; they are not universal GST portal instructions. The FAQ also says the seller must place the QR code on the invoice to enable validation.

Install Playwright for Python

Install the Python package and its browser binaries in the environment where the script will run:

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.
pip install playwright
playwright install

Playwright provides both synchronous and asynchronous Python APIs. The examples below use the synchronous API for a compact, runnable pattern. They are templates: authentication steps and invoice selectors must match the portal you are authorized to use.

Save a rendered HTML invoice with page.pdf()

Use a logged-in session obtained through the portal’s normal, authorized process. This example navigates to an invoice page, waits for a site-specific invoice element, and writes an A4 PDF with background graphics enabled:

from pathlib import Path
from playwright.sync_api import sync_playwright

INVOICE_URL = "https://example.com/invoices/123"
INVOICE_SELECTOR = "[data-invoice]"  # Replace with the portal's actual invoice selector.

with sync_playwright() as p:
    browser = p.chromium.launch(headless=True)
    context = browser.new_context(accept_downloads=True)
    page = context.new_page()

    # Sign in through the portal's normal authorized flow, or use an
    # authorized saved session configured for your environment.
    page.goto(INVOICE_URL, wait_until="domcontentloaded")
    page.locator(INVOICE_SELECTOR).wait_for(state="visible", timeout=30000)

    page.pdf(
        path="invoice.pdf",
        format="A4",
        print_background=True,
    )

    context.close()
    browser.close()

INVOICE_URL and INVOICE_SELECTOR are placeholders, not known GST portal URLs or selectors. The example’s A4 format and background setting are a reasonable starting configuration, not a tested recipe for a particular portal. Playwright documents that page.pdf() generates a PDF using print CSS media by default; see the Python Page API.

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.

Wait for the actual invoice content

A successful navigation does not necessarily mean the invoice is ready. Pages can populate invoice details after JavaScript runs. Wait for a selector that identifies the rendered invoice, and use a selector that appears only when the relevant content is available. If the invoice is built in stages, wait for a stable element or state specific to the portal instead of relying only on a fixed sleep.

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

Print CSS or screen CSS

By default, page.pdf() uses print media. This may invoke print-specific styles that hide controls, change spacing, or rearrange content. If you specifically need the screen appearance, switch media before generating the PDF:

page.emulate_media(media="screen")
page.pdf(path="invoice-screen.pdf", format="A4", print_background=True)

Use screen media only when it better matches the intended output. The page’s styles still determine how content fits on paper, so inspect the resulting PDF for clipping, missing backgrounds, or unexpected page breaks.

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.

Useful PDF options

  • format="A4" selects a common paper size. Playwright also supports other paper formats.
  • print_background=True includes background graphics, which are otherwise off by default.
  • margin lets you set page margins when the portal’s print layout needs adjustment.
  • prefer_css_page_size=True gives CSS @page size rules preference over the PDF options when the page defines them.

Choose settings based on the invoice’s layout and verify page breaks, totals, and any QR code in the saved file. A printed rendering does not itself establish that the output is a digitally authenticated e-Invoice.

Save a PDF attachment from a portal button

If clicking a portal control returns a PDF download, wait for the download event before clicking, then save the download to a durable path. Playwright’s download documentation explains that a page emits a download event for attachments and that context-managed temporary downloads are removed when the browser context closes. See Playwright downloads.

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.
from pathlib import Path
from playwright.sync_api import sync_playwright

INVOICE_URL = "https://example.com/invoices/123"
DOWNLOAD_BUTTON = "button:has-text('Download PDF')"  # Replace for your portal.

with sync_playwright() as p:
    browser = p.chromium.launch(headless=True)
    context = browser.new_context(accept_downloads=True)
    page = context.new_page()

    # Complete the portal's normal authorized sign-in before this step.
    page.goto(INVOICE_URL, wait_until="domcontentloaded")

    with page.expect_download(timeout=30000) as download_info:
        page.locator(DOWNLOAD_BUTTON).click()

    download = download_info.value
    destination = Path("invoice.pdf")
    download.save_as(destination)

    context.close()
    browser.close()

Replace the example button selector with the actual control on the portal. Keep expect_download() around the action that initiates the download; starting to wait afterward can miss the event. Call save_as() before closing the context so the file is preserved at the chosen destination.

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

Handle sign-in and portal controls safely

Use only an account and session you are authorized to access. Do not put GST credentials directly in source code or publish them in logs. If you automate a normal sign-in, keep secrets in an appropriate local secret store or environment configuration and follow the portal’s terms and access controls.

  • Do not try to bypass a CAPTCHA, MFA challenge, access restriction, or other portal control. Complete required checks through the portal’s permitted process.
  • Do not assume a selector, route, or login flow works across GST systems. Confirm it against the specific portal and account.
  • Respect portal terms and rate limits, and avoid repeated or unnecessarily frequent requests.
  • Preserve the portal-provided PDF or signed data when authenticity or validation matters. A browser printout is a copy of rendered content, not proof of a digital signature.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot blank or incomplete PDFs

The PDF is blank or missing invoice details

The page may have loaded before its invoice content was rendered. Wait for a visible invoice-specific element, then check whether the expected content is present before calling page.pdf(). If the portal shows an attachment rather than HTML, use the download-event pattern instead.

The printout looks different from the browser

Print CSS is the default for page.pdf(). If the screen layout is the intended output, call page.emulate_media(media="screen") first. If print layout is desired, check the portal’s print styles and adjust PDF margins or paper format as appropriate.

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

The invoice appears in a frame or a new tab

Check where the invoice content actually opened. Playwright treats popups as separate Page objects, so a new tab may need to be handled as its own page; an invoice inside a frame may require locating and inspecting that frame before capture. The Playwright pages documentation covers pages and popups. These are general automation cases, not claims about a particular GST portal’s layout.

No download event arrives

Confirm that the selected control really downloads a file rather than opening a PDF in the page or a new tab. Check that the selector targets the intended button, and keep the click inside the expect_download() block. If the portal displays the PDF directly, inspect that page or use its official download control rather than assuming an attachment event will occur.

The saved download disappears

Save it with download.save_as() before closing its browser context. Playwright’s managed temporary download files are removed when the context closes.

Or skip the browser setup

For a URL that is accessible to ScreenshotNeo, one GET request can return a screenshot or PDF. The example below requests a PDF of an invoice page; choose a target URL you are authorized to access. See the ScreenshotNeo API documentation for request options.

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

ScreenshotNeo accepts cookie and consent banners and removes known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and the response identifies page verdict and billing status in headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots. It is a capture option, not a replacement for a portal’s official signed e-Invoice data or access controls. Visit ScreenshotNeo or sign up free for 1,000 screenshots a month with no card.

Frequently Asked Questions

Does page.pdf() work with Playwright Firefox or WebKit?

The Python Page API documents PDF generation for Chromium; use Chromium for this workflow unless the current API documentation confirms support in another browser.

Can I treat a browser-generated PDF as the signed e-Invoice?

No. It is a rendering of page content. Use the portal’s official signed data or PDF facility when validation or digital authenticity is required.

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.

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