ScreenshotNeo

BlogHow-to

How to Capture GST Invoice Webpages as PDFs with a Screenshot API

Turn an accessible GST invoice webpage into a PDF with a screenshot API. Configure rendering, check the output, and understand what capture does—and does not—prove.

By the ScreenshotNeo team4 October 20268 min read

A screenshot API can render an accessible GST invoice webpage and return a PDF. Send the invoice URL, select PDF output, choose screen or print styling, wait for invoice data and assets to load, then inspect every page for missing content and legibility. This captures an existing page; it does not create, validate, or authenticate a GST invoice, and it does not obtain an Invoice Reference Number (IRN).

1. Know what the PDF capture does

The API renders the page as it appears in a browser and saves that rendered result. It preserves visible content, but a PDF alone does not establish that the invoice is complete, correct, or legally valid.

CBIC Rule 46 lists tax invoice particulars, including the supplier’s name, address and GSTIN, a financial-year-unique serial number, issue date, applicable recipient details, description and value of goods or services, and tax particulars. Use those particulars as a visual review checklist; the capture service does not validate them. CBIC, Central Goods and Services Tax Rules, 2017, Rule 46.

For notified classes of registered persons, Rule 48(4) describes preparing invoices using particulars in FORM GST INV-01 and obtaining an IRN through the common portal. Rule 48(5) says an invoice issued outside the specified manner by a person subject to that rule is not treated as an invoice. A screenshot API does not carry out this process or issue an IRN. CBIC, Rule 48. IRIS IRP’s guidance likewise places reporting invoice details and receiving an IRN before generating, printing, or forwarding the PDF: IRIS IRP portal guidance.

2. Prepare the page and access

  1. Use the invoice URL that displays the complete invoice. Open it in the same authorized account or access context needed to view it. Do not send credentials or invoice URLs to a service unless your organization permits that handling.
  2. Check whether the invoice is rendered immediately or populated after scripts or API calls. Note any sign-in, consent, or navigation steps. URL-based capture documentation does not guarantee support for every login flow.
  3. Decide whether the target should look like the screen or a printed page. Screen styling is often closer to the browser view; print styling may apply a site’s print-specific CSS. Confirm the provider’s option names and defaults.
  4. Choose a paper size and page layout suited to the invoice. A dense invoice forced onto one page can become too small to read.

3. Request a PDF with ScreenshotOne

ScreenshotOne documents URL-based PDF output with format=pdf. Its PDF options include media_type=screen for screen styling, pdf_print_background=true to include background graphics, and pdf_fit_one_page=true to try to fit a website onto one page. It also documents full_page=true for full-page capture. Confirm current parameter details in the ScreenshotOne options documentation. The examples below assume an authorized API key stored in SCREENSHOTONE_ACCESS_KEY.

cURL

curl -G 'https://api.screenshotone.com/take' \
  --data-urlencode 'access_key=YOUR_ACCESS_KEY' \
  --data-urlencode 'url=https://example.com/invoices/123' \
  --data-urlencode 'format=pdf' \
  --data-urlencode 'media_type=screen' \
  --data-urlencode 'pdf_print_background=true' \
  --output invoice.pdf

Python

import os
import requests

response = requests.get(
    "https://api.screenshotone.com/take",
    params={
        "access_key": os.environ["SCREENSHOTONE_ACCESS_KEY"],
        "url": "https://example.com/invoices/123",
        "format": "pdf",
        "media_type": "screen",
        "pdf_print_background": "true",
    },
    timeout=90,
)
response.raise_for_status()

content_type = response.headers.get("content-type", "")
if "pdf" not in content_type.lower():
    raise RuntimeError(f"Expected PDF response, received {content_type!r}")

with open("invoice.pdf", "wb") as output:
    output.write(response.content)

Node.js

const params = new URLSearchParams({
  access_key: process.env.SCREENSHOTONE_ACCESS_KEY,
  url: 'https://example.com/invoices/123',
  format: 'pdf',
  media_type: 'screen',
  pdf_print_background: 'true',
});

const response = await fetch(
  `https://api.screenshotone.com/take?${params}`,
  { signal: AbortSignal.timeout(90_000) }
);

if (!response.ok) {
  throw new Error(`Capture failed: HTTP ${response.status}`);
}
const contentType = response.headers.get('content-type') || '';
if (!contentType.toLowerCase().includes('pdf')) {
  throw new Error(`Expected PDF response, received ${contentType}`);
}

const { writeFile } = await import('node:fs/promises');
await writeFile('invoice.pdf', Buffer.from(await response.arrayBuffer()));

4. Tune layout, loading, and page capture

Need Setting to consider Trade-off or check
Screen appearance media_type=screen Uses screen-oriented styling where supported.
Printed appearance Print media type May trigger different CSS, page breaks, or hidden elements; inspect the result.
Colored headers or backgrounds pdf_print_background=true Background graphics can affect file size and appearance.
One-page output pdf_fit_one_page=true Can shrink dense invoices; prefer readable multi-page output when needed.
Long invoice page full_page=true Check that lower sections and any lazy-loaded content appear.
Delayed invoice content Documented delay, timeout, or wait options Wait long enough for invoice data and assets, without making every request unnecessarily slow.

Use provider documentation for exact option values, paper dimensions, margins, headers, footers, and wait behavior. The referenced material documents delay, timeout, and wait-related options, but does not establish a universally correct wait duration. For a dynamic invoice, tune against the actual page and verify the PDF. Full-page scrolling can help trigger lazy-loaded content, but does not guarantee every page script or asset will finish correctly.

5. Inspect and handle the resulting PDF

  1. Confirm the response is a PDF and opens successfully. Reject an HTML error page saved with a .pdf filename.
  2. Check the invoice number and date, supplier and recipient details, line items, tax amounts, and totals against the displayed invoice.
  3. Check all pages for clipped columns, repeated or missing sections, unexpected blank pages, and page breaks through line items.
  4. Check any QR code or IRN that the webpage displays. A visible code in the PDF is not proof that the capture service validated it.
  5. Zoom in on small text and confirm the PDF remains legible, especially if using one-page fit.
  6. Store the file under your organization’s access, retention, and privacy policies. The sources here do not establish a universal retention period or storage method.

6. Other documented API routes

When choosing a provider, compare URL versus HTML input, direct PDF response, page sizing and page breaks, full-page behavior, loading controls, authentication for your specific workflow, timeout handling, request security, storage and retention defaults, and operational requirements. The reviewed material does not establish comparative pricing, capture accuracy, uptime, or retention across providers, so evaluate those for your own requirements.

  • ScreenshotNeo: a website screenshot API that also returns PDFs; it is a useful first option when clean captures and billing only for clean shots matter. Details and options are in the ScreenshotNeo documentation.
  • ScreenshotOne: documents URL input and PDF output from its screenshot API, plus PDF styling and full-page options, as shown above.
  • Browserless: documents an image screenshot API and a separate PDF API that can navigate to a URL or render raw HTML. Treat these as distinct endpoints; its screenshot endpoint is not the documented PDF endpoint. See the screenshot API and PDF API.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. One GET request can return a PDF from an invoice URL. Its clean-capture steps accept the cookie or consent banner like a visitor and remove 60+ known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and billing status. AI agents can use its MCP server tools, including take_screenshot, get_page_info, and capture_pdf. Every plan includes every feature: 1,000 screenshots a month are free with no card; paid plans start at $5 for 3,000.

See the ScreenshotNeo API documentation. Use an API key you are authorized to use and keep it out of source control.

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

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={
        "access_key": "YOUR_API_KEY",
        "url": "https://example.com/invoices/123",
        "format": "pdf",
    },
    timeout=90,
)
r.raise_for_status()
open("invoice.pdf", "wb").write(r.content)
const q = new URLSearchParams({
  access_key: 'YOUR_API_KEY',
  url: 'https://example.com/invoices/123',
  format: 'pdf',
});
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Capture failed: HTTP ${res.status}`);
const { writeFile } = await import('node:fs/promises');
await writeFile('invoice.pdf', Buffer.from(await res.arrayBuffer()));

Sign up free for 1,000 screenshots a month, with no card required.

Troubleshooting

Symptom Likely cause What to do
PDF is a sign-in page or access-denied page The capture request cannot see the authorized invoice session. Confirm the URL is accessible in the capture context. Use only an authentication method supported by the provider and approved for the account; do not assume browser login state transfers to an API.
Invoice fields are blank or missing The page fills them after initial navigation. Use the provider’s documented wait controls, then check that the source page itself displays the fields before capture.
Bottom of invoice is missing Capture was not full-page, or content loads on scroll. Enable documented full-page behavior and inspect the lower sections and final PDF page.
Text is tiny One-page fit scaled a dense invoice down. Disable fit-to-one-page and use multiple pages, or adjust documented page dimensions and margins.
Background color or logo is absent Print styling omits backgrounds, or the page uses print-specific CSS. Try screen media and enable PDF background graphics where supported. Compare the result with the invoice page.
PDF has unexpected breaks or blank pages Print CSS, fixed-height layout, or content size affects pagination. Compare screen and print media, review page size and margins, and inspect each page rather than assuming browser layout maps directly to paper.
Request times out Slow navigation, scripts, or assets exceed the request’s wait window. Use an appropriate documented timeout and wait condition. Avoid retrying immediately at high volume; determine whether the page is consistently slow.
Downloaded file is not a PDF The service returned an error or status document. Check HTTP status and content type before saving; inspect the error response and correct the URL, access, or option.

Performance, reliability, and cost

PDF rendering waits for browser navigation, page scripts, and assets, so dynamic pages can take longer than static ones. Full-page capture and generous wait conditions can add work; use only what the invoice needs. A timeout or failed render is not a reason to treat an incomplete file as an archive copy. Check status, content type, and document contents before downstream storage or processing.

For recurring workflows, set a bounded timeout, record the invoice URL and capture outcome according to your data policies, and retry transient failures with a limit and backoff. Avoid parallel bursts that exceed the provider’s documented capacity or your own system’s limits. The research sources do not provide comparative speed, accuracy, uptime, or cost figures for the named services.

Budget based on the provider’s current pricing and the number of successful captures you need; do not infer a cost from a screenshot option or from another provider’s endpoint. For sensitive invoice data, review how URL parameters, request logs, rendered content, and resulting files are handled by the chosen service and your organization.

FAQ

Does a screenshot API generate an IRN?

No. It renders an existing page. The IRN process for notified taxpayers is a separate e-invoicing workflow under Rule 48.

Does a PDF copy prove an invoice is valid?

No. It is a visual capture. Review invoice particulars and use the applicable official e-invoice process for validation.

Should I choose print styling or screen styling?

Choose based on the intended appearance, then inspect the output. Print CSS can change visibility and page breaks; screen styling may more closely match the browser page.

Can I always fit an invoice onto one page?

Some APIs offer a one-page fit option, but readability can suffer. Use multiple pages when fitting would make details hard to read.