ScreenshotNeo

BlogHow-to

How to Capture GST Invoice Webpages as PDFs with HTMLCSStoImage

Download an invoice PDF from the GST or IRP portal when available. If you need a webpage capture, use HTML/CSS to Image with these steps and examples.

By the ScreenshotNeo team4 October 202610 min read

First, check whether the GST or IRP portal can download the invoice PDF directly. That gives you the portal’s invoice artifact without recreating it from a webpage. Use HTML/CSS to Image when capturing a public invoice page is actually necessary. Its documented API can capture a public URL as a PDF, but the reviewed documentation does not establish that it can enter a private taxpayer account or reuse your logged-in browser session.

This guide shows the public-page workflow, server-side examples in cURL, Python, and Node.js, and what to do when the invoice is only available behind a login.

1. Choose the right route: portal PDF or webpage capture

Situation Recommended route Why
The invoice is available in the GST or IRP portal’s invoice search or view Download or generate its PDF in the portal You get the invoice PDF provided by that workflow directly.
You need a PDF of a public invoice webpage Capture the fully qualified public URL with HTML/CSS to Image The URL capture endpoint accepts a public webpage URL and supports PDF output.
The page requires a GST login or an active browser session Use the portal’s own download, or an approved workflow that explicitly supports authentication HTML/CSS to Image’s reviewed URL documentation does not promise taxpayer-session access.

The GST e-Invoice JSON Download manual describes searching invoice records and using the download action to obtain a PDF; it also describes a JSON download option. IRIS IRP documents a separate workflow under Manage > View Invoices: generate the PDF through Print, then download it when processing succeeds. The IRIS guide says its default view covers invoices with acknowledgement dates in the prior two days; older records can depend on a VAS or VAS Premium plan. That availability detail applies to IRIS IRP, not every IRP. GST e-Invoice JSON Download manual · IRIS IRP invoice viewing and download guide.

Do not confuse an individual invoice PDF with the GSTR-1 workflow for downloading e-invoice details as an Excel file. The GST GSTR-1 guide describes that spreadsheet as return-preparation data, including download history for larger record sets. GST GSTR-1 user guide.

2. Know what HTML/CSS to Image can capture

The documented create-image endpoint is POST https://hcti.io/v1/image. A request must supply either url or html; the API accepts JSON or form data. When both are present, url takes precedence, so provide only the input you intend to render. For URL capture, use a fully qualified public webpage URL. You can set format to pdf; PNG, JPG, and WebP are also documented. Full-page capture is an available option, although the precise rendering of a particular invoice page has not been verified here. See the vendor’s API usage documentation and URL capture documentation.

Authentication uses HTTP Basic authentication: the API ID is the username and the API key is the password. Keep both server-side, load them from environment variables or a secret manager, and treat the key like a password. Never put the credentials in browser JavaScript, a public page, a repository, or an article link.

3. Try the portal’s direct PDF download first

  1. Sign in to the GST or IRP portal through its normal route.
  2. Open the invoice search or invoice view and locate the record using the portal’s available identifiers.
  3. Choose the portal’s PDF download action, or generate/print the PDF if that is the portal’s documented flow.
  4. Wait for generation to finish if the portal reports a processing status, then download the file.
  5. Open the PDF and check the invoice identity, visible details, legibility, and page count against the portal record.

For GST’s e-Invoice JSON Download workflow, use its search and download instructions. For IRIS IRP specifically, use Manage > View Invoices, choose Print to generate the PDF, and download after successful processing. If an older IRIS record is not available, check the service condition described in its guide. Do not assume that another IRP has the same menus, date window, or plan requirements.

4. Capture a public invoice webpage as a PDF

The examples below use https://example.com/ as a harmless illustrative public URL. Replace it only with a page you are authorized to capture and that the capture service can reach without relying on your private GST login. The examples show API credentials supplied through environment variables. Configure HCTI_API_ID and HCTI_API_KEY in your server environment before running them.

cURL

curl --fail --silent --show-error \
  --user "$HCTI_API_ID:$HCTI_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{"url":"https://example.com/","format":"pdf"}' \
  https://hcti.io/v1/image

The create-image response provides an output URL. Fetch the artifact from that returned URL and save it as a PDF; do not assume the creation response itself is the PDF bytes. For example, if the response JSON has been saved as response.json and its documented output URL is in the url field, download that URL with:

OUTPUT_URL="$(python3 -c 'import json; print(json.load(open("response.json"))["url"])')"
curl --fail --location --output invoice.pdf "$OUTPUT_URL"

Keep the response URL handling aligned with the response schema for your account and API version. Treat generated URLs as potentially sensitive if the captured page contains invoice data.

Python

import os
import requests

api_id = os.environ["HCTI_API_ID"]
api_key = os.environ["HCTI_API_KEY"]

response = requests.post(
    "https://hcti.io/v1/image",
    auth=(api_id, api_key),
    json={"url": "https://example.com/", "format": "pdf"},
    timeout=90,
)
response.raise_for_status()
data = response.json()

# The create call returns an artifact URL. Download the generated PDF from it.
output_url = data["url"]
pdf_response = requests.get(output_url, timeout=90)
pdf_response.raise_for_status()
with open("invoice.pdf", "wb") as pdf_file:
    pdf_file.write(pdf_response.content)

Node.js

const apiId = process.env.HCTI_API_ID;
const apiKey = process.env.HCTI_API_KEY;
if (!apiId || !apiKey) throw new Error("Set HCTI_API_ID and HCTI_API_KEY");

const credentials = Buffer.from(`${apiId}:${apiKey}`).toString("base64");
const response = await fetch("https://hcti.io/v1/image", {
  method: "POST",
  headers: {
    "Authorization": `Basic ${credentials}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ url: "https://example.com/", format: "pdf" }),
  signal: AbortSignal.timeout(90000),
});
if (!response.ok) throw new Error(`Create request failed: ${response.status} ${await response.text()}`);
const result = await response.json();

// Download the artifact from the URL returned by the create-image response.
const pdfResponse = await fetch(result.url, { signal: AbortSignal.timeout(90000) });
if (!pdfResponse.ok) throw new Error(`PDF download failed: ${pdfResponse.status}`);
const fs = await import("node:fs/promises");
await fs.writeFile("invoice.pdf", Buffer.from(await pdfResponse.arrayBuffer()));

Request options and practical choices

Option Use Consideration
url Capture a reachable, public page Use a complete URL with scheme and hostname. Private portal-session support is not established.
html Render HTML you supply instead of navigating to a URL The API requires either url or html; avoid sending invoice or taxpayer data unless your data-handling requirements permit it.
css Apply styling to a URL capture or supplied HTML Can adjust presentation, but cannot make an inaccessible authenticated page public to the renderer.
format Choose pdf, png, jpg, or webp Use PDF for a document; image formats are useful for raster snapshots.
Full-page capture Include content beyond the initial viewport when supported by the request configuration Long pages may produce multiple PDF pages or large output; inspect page breaks and completeness.

Consult the vendor documentation for the exact option names and accepted values for your account. The examples intentionally do not invent a real GST portal URL or assert that a login-protected invoice will work.

5. Inspect the PDF before using or sharing it

  • Confirm the taxpayer and invoice identifiers match the portal record.
  • Check that all expected invoice details are present and readable at normal zoom.
  • Check page count, orientation, clipping, and page breaks, especially for full-page captures.
  • Compare the captured page with the portal’s own invoice record. A webpage capture is a rendering of what the page showed, not proof that the invoice’s tax or filing status is correct.
  • Store and share the PDF according to your organization’s handling rules for invoice data. Avoid putting generated links or files in public locations.

6. Troubleshooting

Symptom Likely cause What to do
Authentication is rejected The API ID and key are missing, reversed, mistyped, or not being sent as Basic authentication. Check the server environment variables and send the API ID as the Basic-auth username and API key as its password. Rotate a key if it was exposed.
The API reports missing input Neither url nor html was supplied, or the body was not encoded as expected. Send one input in JSON or form data and set the matching content type. Use a fully qualified URL for URL capture.
The wrong content is captured Both url and html were sent; the documented behavior gives url precedence. Remove the unused input and verify the target URL resolves to the intended public page.
The capture shows a login page, access-denied page, or no invoice The target requires an authenticated taxpayer session, or the service cannot reach the page. Use the portal’s own PDF download. The reviewed docs do not establish reuse of your browser login or GST credentials.
The result is HTML or JSON rather than a PDF The request did not select PDF output, or the create response was saved instead of downloading its output artifact. Set format to pdf, inspect the create response, and download the returned artifact URL.
The file is incomplete or hard to read The page has content below the fold, delayed content, or a layout that does not print cleanly. Use the documented full-page option where appropriate, then inspect the PDF. If fidelity matters, prefer the portal-native PDF.
The portal has no recent invoice in view The selected portal’s search window or service conditions may limit visible history. Check that portal’s official history/download instructions. IRIS IRP documents a prior-two-day default view and VAS conditions for older records; this is IRIS-specific.
The PDF download request times out Page rendering or artifact retrieval took longer than the client timeout. Use a reasonable bounded timeout, log the request and response status without logging secrets, and retry transient network failures with backoff. Avoid repeated rapid retries.

7. Performance, reliability, and cost

There is no capture benchmark or test result in the research for a GST page, so allow for both page rendering and the separate artifact download when setting client timeouts. A slow or changing public page can affect the captured result. For workflows where correctness matters, use the portal PDF when available and inspect the output rather than treating a successful API response as validation of invoice content.

HTML/CSS to Image requires API credentials and a create request, followed by retrieval of the returned artifact. Avoid logging credentials, minimize retention of invoice PDFs and generated URLs, and apply your organization’s access controls. The reviewed sources do not establish pricing for this workflow, so check the vendor’s current pricing directly before estimating per-invoice cost. The GST portal’s Excel download for GSTR-1 is a separate return-preparation workflow, not a substitute for an individual invoice PDF.

8. Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server by Yorker Media. One GET request can return a screenshot or PDF. Its clean-shot flow accepts cookie and consent banners like a visitor, then removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server gives AI agents tools including take_screenshot, get_page_info, and capture_pdf.

Use only a public page you are authorized to capture. ScreenshotNeo’s documented URL capture does not imply access to your private GST account. Keep API keys server-side. See the ScreenshotNeo API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o invoice.pdf

For reference, the same request can be made from Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://example.com"}, timeout=90)
open("invoice.pdf", "wb").write(r.content)

Or Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
await import('node:fs/promises').then(fs => fs.writeFile('invoice.pdf', Buffer.from(await res.arrayBuffer())));

ScreenshotNeo has a free plan with 1,000 screenshots a month and no card; paid plans start at $5 for 3,000. The account page lists the available plans and signup.

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

9. Frequently asked questions

How do I save a GST invoice webpage as a PDF?

Use the portal’s download or print-to-PDF workflow when the invoice is available there. For a reachable public webpage, submit its fully qualified URL to a URL capture service with PDF output enabled, then download and inspect the generated file.

Can HTML/CSS to Image use my GST portal login?

The reviewed URL capture documentation does not establish support for your browser session or a private taxpayer login. Do not send your GST password to a capture service based on this guide.

Should I use a screenshot PDF as the official invoice?

Prefer the GST or IRP portal’s own downloadable or generated invoice PDF when available. A webpage capture reproduces a page and may not preserve the portal’s document semantics or validate the invoice.

Why does the IRIS IRP portal not show an older invoice?

IRIS IRP’s guide says the default invoice view covers acknowledgement dates in the prior two days and that older records can depend on a VAS or VAS Premium plan. Check its current instructions for your account.