ScreenshotNeo

BlogHow-to

How to Use Html2Pdf.app to Archive Invoices and Receipts from a Website

Archive website invoices and receipts as PDFs with Html2Pdf.app. Learn when it works, how to call its API, and how to check the result.

By the ScreenshotNeo team4 October 202611 min read

Html2Pdf.app can convert a publicly reachable webpage or supplied HTML into a PDF. To archive an invoice or receipt, first check whether the merchant offers its own PDF download or print command; use that when available. If the record is available at a public URL and is appropriate to send to a conversion service, you can use Html2Pdf.app’s online converter or API, then inspect the resulting PDF before filing it.

A private invoice page that requires you to sign in is a different case. Html2Pdf.app’s documented input is a public URL or raw HTML; its documentation does not describe a way to sign in to a merchant account or access an authenticated browser session. For account-only invoices, use the merchant’s download, export, or print option, or another method allowed by that site. Html2Pdf.app is a PDF converter; ScreenshotNeo is a separate website screenshot API that can save a public page as an image or PDF.

Choose the right way to save the record

  1. Look for the merchant’s own PDF. An invoice or receipt download is usually the clearest source record. Save it with a useful filename.
  2. For a public page, try the online converter. Html2Pdf.app describes its free demo as an interactive converter that can be used without an API key. Enter the page URL, preview the result, and download the PDF.
  3. For repeated work, use the API. Automated conversions require an account API key. Submit the public URL or HTML from a trusted backend or job, check the response status, and save the successful response bytes.
  4. Review before filing. Confirm the merchant name, date, invoice or receipt number, line items, taxes, total, and any other details you need are visible and legible.

Do not assume that a URL copied from a signed-in merchant session is publicly accessible. A conversion service cannot be expected to see the same authenticated page you see in your browser unless its documented workflow supports that access.

Convert a public invoice URL with the online tool

  1. Open the invoice or receipt page and copy its URL. First check whether the page contains information you are permitted to send to a third party.
  2. Open the Html2Pdf.app online converter and provide the public URL.
  3. Generate and preview the PDF. Check the content and page breaks against the original page.
  4. Download the PDF and store it in your records system, for example as merchant-invoice-INV-12345-2026-10-04.pdf.

The online converter is useful for occasional manual conversions. Use the API when you need to create PDFs as part of a backend workflow. Do not put an API key in client-side browser JavaScript or public source code.

Call the Html2Pdf.app API

The documented endpoint is POST https://api.html2pdf.app/v1/generate. Authenticate with the X-API-Key header and send a JSON request containing html, which may be a publicly reachable URL or a raw HTML string. On success, the response body is PDF binary data. Check the HTTP status before writing it to a file: an error response is not a PDF.

cURL

curl --fail-with-body \
  -X POST "https://api.html2pdf.app/v1/generate" \
  -H "X-API-Key: $HTML2PDF_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{"html":"https://example.com/public-invoice"}' \
  --output invoice.pdf

Set HTML2PDF_API_KEY in the shell environment from a secure secret store before running the command. Replace the example URL with a publicly reachable invoice page. The API key remains in the request header rather than the JSON body.

Python

import os
import requests

api_key = os.environ["HTML2PDF_API_KEY"]
response = requests.post(
    "https://api.html2pdf.app/v1/generate",
    headers={
        "X-API-Key": api_key,
        "Content-Type": "application/json",
    },
    json={"html": "https://example.com/public-invoice"},
    timeout=90,
)
response.raise_for_status()

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

Install the dependency with python -m pip install requests. The binary write mode preserves the PDF bytes. For a production job, catch request and HTTP errors and record enough context to diagnose the failure without logging invoice contents or secrets.

Node.js

const apiKey = process.env.HTML2PDF_API_KEY;
if (!apiKey) throw new Error("Set HTML2PDF_API_KEY first");

const response = await fetch("https://api.html2pdf.app/v1/generate", {
  method: "POST",
  headers: {
    "X-API-Key": apiKey,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ html: "https://example.com/public-invoice" }),
  signal: AbortSignal.timeout(90_000),
});

if (!response.ok) {
  const detail = await response.text();
  throw new Error(`Html2Pdf.app returned ${response.status}: ${detail}`);
}

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

This example uses the built-in fetch available in current Node.js releases. Keep the key in the server environment or a secret manager. Avoid printing the full response body to logs if an error could contain submitted data.

Convert raw HTML instead of a URL

The API documentation also accepts raw HTML in the html field. This can be useful when your own authorized system already has the invoice markup. Include the document structure and any styles needed for the content. External fonts, images, stylesheets, and scripts may not load as expected if they are inaccessible to the renderer, so inspect the output. Do not submit HTML containing sensitive information until you have reviewed the service’s data handling terms and decided that the submission is appropriate.

Rendering options that affect invoice PDFs

Html2Pdf.app’s documentation describes options that control browser rendering and the PDF page. Set only the options your archive needs, then verify the output visually.

Setting What to consider
waitFor Waits for page rendering, from 0 to 10 seconds. Increase it if page content is added by JavaScript after initial load; longer waits add conversion time and cannot fix content that never loads.
Media mode Choose screen or print. A site can use different CSS for each, so check which preserves the invoice layout and required details.
Page size Choose a page size that keeps the invoice readable. A long web page may span multiple PDF pages.
Margins Adjust margins if the page content is clipped or too close to an edge. Confirm that changing margins does not obscure totals or footnotes.
Orientation Use portrait or landscape according to the layout, particularly for wide line-item tables.
Scale Adjust scale when content does not fit legibly. Shrinking everything to fit one page may make small print unreadable.
Headers and footers Use the documented header/footer controls if needed, and check that they do not overlap invoice content.
userPassword The docs describe optional PDF password protection using 128-bit AES encryption. This protects the generated file; it does not mean the source page is safe to send to the service.

Use the current API documentation for exact parameter names and request syntax. The supported options and terms may change.

Check the PDF before treating it as an archive

  • Verify the merchant name, invoice or receipt identifier, date, currency, totals, taxes, and line items.
  • Check all pages, including the last page, for cut-off content or awkward page breaks.
  • Confirm that logos, product images, fonts, and other required assets rendered.
  • Compare the chosen screen or print media mode if styling differs from the browser view.
  • Confirm that dynamically loaded content appeared; adjust waitFor when timing is the issue.
  • Open the downloaded file in a PDF reader and check that it is a valid PDF, not an error response saved with a .pdf extension.
  • Use a consistent filename, such as merchant-receipt-order-number-date.pdf, and store it in the records system you selected.

This checklist is practical quality control, not a claim that every page will render identically to its live version. The renderer uses headless Chromium, and CSS, available fonts and resources, and JavaScript timing can all affect the result.

Privacy and sensitive records

Invoices and receipts may contain personal, financial, or account-related information. Before submitting a URL or HTML, review the service’s current privacy policy and data processing terms and consider whether a third-party converter is suitable for that record.

Html2Pdf.app’s documentation says generated PDFs are processed temporarily and are not permanently stored on its servers. It also says raw HTML or text submitted in html is not stored in conversion logs, while selected request metadata and a source URL may be retained. Treat these as the vendor’s statements about its service, not as a broader guarantee about all data handling; consult its documentation, Privacy Policy, and Data Processing Agreement for current details.

If you use the API, keep the key on a trusted server, limit who can access it, and avoid putting it in a URL, browser code, or logs. PDF password protection is a property of the output file and does not prevent the source URL or content from being processed during conversion.

Cost, time, and reliability considerations

The manual converter is suitable for occasional records; API automation adds an account key and a recurring workflow to maintain. Html2Pdf.app’s pricing page lists a free tier and paid plans, with credit usage based on generated PDF size; plan prices, allowances, file limits, and parallel conversion limits are vendor terms that can change. Check the current pricing page before estimating a recurring archive job.

Conversion time depends on page loading and rendering. A page that loads slowly or waits on scripts can take longer, and setting a larger waitFor adds intentional delay. For reliability, use a finite client timeout, check status codes, and retry only transient server or network failures with a limit and backoff. Fix inaccessible URLs, invalid parameters, credentials, or plan limits rather than repeatedly retrying them. Save files atomically in your own storage workflow if partial writes would create confusing records.

For high-value records, preserve the merchant-provided PDF or export when available. A rendered webpage is a visual copy that can omit content hidden behind interaction, unavailable resources, or page-specific rendering behavior. Keep the original source or transaction reference according to your normal records policy.

Or skip the browser setup

If what you need is a screenshot or PDF of a public webpage, ScreenshotNeo is a website screenshot API with a single GET request. Its API can return PNG, JPEG, WebP, or PDF, and its API documentation lists capture options.

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

python -c 'import requests; r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90); open("shot.webp", "wb").write(r.content)'

node --input-type=module -e 'const q = new URLSearchParams({ access_key: "YOUR_API_KEY", url: "https://stripe.com" }); const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`); if (!res.ok) throw new Error(`HTTP ${res.status}`); await import("node:fs/promises").then(({writeFile}) => writeFile("shot.webp", Buffer.from(await res.arrayBuffer())));'

Replace the example URL with a public page you are authorized to capture. The examples save WebP output. ScreenshotNeo accepts cookie or consent banners and removes more than 60 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 the page verdict and billing status in headers. Its MCP server lets AI agents use take_screenshot, get_page_info, and capture_pdf. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots, and every feature is on every plan. A screenshot or rendered PDF is not a replacement for an authenticated merchant invoice or the merchant’s official record. Sign up for 1,000 free screenshots a month with no card.

Troubleshooting

Problem Likely cause What to do
The invoice page is inaccessible The URL is private, expired, requires login, or blocks the renderer. Use the merchant’s own download or print controls, or another authorized method. The documented API input does not establish authenticated account access.
The API returns HTTP 400 The URL cannot be accessed or a request parameter is invalid. Check the URL from outside your signed-in browser session and validate the request against the current docs.
The API returns HTTP 401 The API key is missing or invalid. Check the key in the X-API-Key header and confirm the server is reading the intended secret.
The API returns HTTP 403 The current plan limit prevents the conversion. Review the account and current plan limits; avoid retrying unchanged requests until the limit issue is resolved.
The API returns HTTP 500 A server-side error occurred. Check whether the issue persists, then retry cautiously with a finite retry policy. Preserve the status and safe diagnostic details for support.
The PDF is blank or missing details Page content may be JavaScript-rendered, blocked, or not ready when capture begins. Try an appropriate waitFor delay, check media mode, and verify the URL and external resources are reachable.
Fonts or images are missing External resources may be unavailable to the renderer or load differently in headless Chromium. Check resource accessibility and inspect the output. For supplied HTML, include or reference resources that the renderer can reach.
Content is clipped or split badly Page size, margins, scale, orientation, or print CSS do not suit the invoice. Adjust those settings and inspect every page. Keep the text readable rather than forcing a long invoice onto one page.
The saved file is not a PDF An error body may have been written despite a failed HTTP response. Check the status before saving; use a client option such as cURL’s --fail-with-body and inspect the response when debugging.

Frequently asked questions

Can Html2Pdf.app download an invoice from a page after I sign in?

The reviewed documentation describes a public URL or raw HTML as input, not a logged-in merchant session. Use the merchant’s own account download, export, or print function for private records.

Can I convert a receipt I already have as HTML?

The API accepts raw HTML in its html field. Include the markup and styles you need, and check that external resources render in the generated file.

Does a password-protected PDF keep the invoice private from the converter?

No. The documented password option protects the resulting PDF. It does not establish that the source content avoids processing by the conversion service.

Should I keep the PDF or the merchant’s original invoice?

When available, retain the merchant-provided PDF or export as the source record. A webpage conversion is useful for preserving a view of a public page, but rendering can omit or alter content.