Image outputNew example

Invoice / Receipt Snapshot

Generate a simple, branded invoice or receipt image.

This example shows how to turn a clean HTML layout into a polished invoice. It includes a header with a company name, customer details, a table of items, and a clear total. Great for receipts, confirmations, or sharing invoices as images.
Preview of Invoice / Receipt Snapshot

Interactive example

Edit and render this image

Change the HTML, CSS, or API options. The browser preview updates as you edit; select Image to render the final output through the API.

Example code

Use this request in your app

Choose a language and copy a complete request using this example's HTML, CSS, and API options.

import { HtmlCssToImageClient, CreateHtmlCssImageRequest } from "@html-css-to-image/client";

const client = HtmlCssToImageClient.fromEnv();

const request = new CreateHtmlCssImageRequest({
    html: `<div class='wrapper'>
<div class='invoice'>
  <header>
    <h1>Acme Corp</h1>
    <p>Invoice #12345</p>
  </header>

  <section class='details'>
    <p><strong>Billed To:</strong> John Doe<br>
    123 Main St<br>
    Springfield, USA</p>

    <p><strong>Date:</strong> Sept 18, 2025</p>
  </section>

  <table class='items'>
    <thead>
      <tr>
        <th>Description</th>
        <th>Qty</th>
        <th>Unit Price</th>
        <th>Total</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Website Design</td>
        <td>1</td>
        <td>$500.00</td>
        <td>$500.00</td>
      </tr>
      <tr>
        <td>Hosting (12 months)</td>
        <td>1</td>
        <td>$120.00</td>
        <td>$120.00</td>
      </tr>
      <tr>
        <td>Domain Name (1 year)</td>
        <td>1</td>
        <td>$12.00</td>
        <td>$12.00</td>
      </tr>
    </tbody>
  </table>

  <section class='summary'>
    <p><strong>Subtotal:</strong> $632.00</p>
    <p><strong>Tax (10%):</strong> $63.20</p>
    <p class='total'><strong>Total Due:</strong> $695.20</p>
  </section>

  <footer>
    <p>Thank you for your business!</p>
  </footer>
</div>
</div>`,
    css: `.wrapper{
  font-family: 'Roboto', sans-serif;
  background: #f7f7f7;
  padding: 20px;
}

.invoice {
  min-width: 500px;
  max-width: 600px;
  margin: auto;
  background: #fff;
  padding: 24px;
  border: 1px solid #ddd;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

header {
  border-bottom: 2px solid #333;
  margin-bottom: 20px;
}

header h1 {
  margin: 0;
  font-size: 24px;
}

.details {
  margin-bottom: 20px;
}

.items {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

.items th, .items td {
  border: 1px solid #ddd;
  padding: 8px;
  text-align: left;
}

.items th {
  background: #f0f0f0;
}

.summary {
  text-align: right;
}

.summary p {
  margin: 0.6em 0;
}

.summary .total {
  border-top: 1px solid #ddd;
  padding-top:8px;    
  font-size: 18px;
  font-weight: bold;
  width: fit-content;
  margin-left: auto
}

footer {
  border-top: 1px solid #ddd;
  text-align: center;
  padding-top: 10px;
  color: #555;
  font-size: 14px;
}`,
    google_fonts: [
        "Roboto",
    ],
    render_when_ready: false,
    selector: ".wrapper",
    timezone: "UTC",
});

const result = await client.createImage(request);
if (result.success) {
    console.log(result.url);
} else {
    console.error(result.error);
}

Request configuration

Options used in this example

These values are sent with the HTML and CSS to control how HCTI loads the page and captures the final screenshot. You can change each one in the editor above.

Google Fonts

google_fonts
Roboto
Google fonts to load. Separate multiple fonts with a pipe, such as 'Roboto|OpenSans', and set font-family in the CSS to use them.
Learn about this option

Selector

selector
.wrapper
A CSS selector for an element in the HTML. We’ll crop the image to this specific element.
Learn about this option

From code to screenshot

How HCTI examples work

HTML/CSS to Image renders HTML and CSS in hosted Chrome, then captures the result as an image or PDF. Each example combines real source code with the API options used for the render, so it is both a working demo and a starting point for your own request.

Edit the source and options above to test changes in the browser, then render through the API to see the production result.

Common questions

Can I use the HTML and CSS from these examples?

Yes. Open an example to inspect and edit its complete HTML, CSS, and render options. Use it as a starting point, then send the resulting request from your application.

What is the difference between an example and a template?

Examples are complete API requests built from HTML and CSS. Templates are saved, reusable designs created in the visual editor and rendered repeatedly with different variable values.

Does HCTI create screenshots and PDFs?

Yes. HCTI can render HTML and CSS or capture a public webpage as an image, and it can generate PDFs when you need document output instead of a screenshot.

Keep exploring

Related examples

View all examples