Image output

Shareable Quote

A fancy blockquote for sharing.

Swap out the text and name in this example to create shareable images of quotes. Adjust the background color by changing out #4adfcc in the CSS with another color.
Preview of Shareable Quote

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.

package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
    "os"
    "time"
)

func main() {
    request := map[string]any{
        "html": `
                <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
                
                <blockquote class="quote-box p-2 m-2">
                  <p class="quotation-mark">
                    “
                  </p>
                  <p class="quote-text">
                    Don't believe anything that you read on the internet, it may be fake.
                  </p>
                  <hr>
                  <div class="blog-post-actions">
                    <p class="blog-post-bottom pull-left">
                      Benjamin Franklin
                    </p>
                    <p class="blog-post-bottom pull-right">
                      <span class="badge quote-badge">567</span>  ❤
                    </p>
                  </div>
                </blockquote>
                `,
        "css": `
               blockquote {
                 border-left: none;
               }
               
               body {
                 background-color: transparent;
               }
               
               .quote-badge {
                 background-color: rgba(1, 0, 0, 0.5);
               }
               
               .quote-box {
                 overflow: hidden;
                 margin-top: -50px;
                 padding-top: -100px;
                 border-radius: 17px;
                 background-color: #4adfcc;
                 margin-top: 25px;
                 color: white;
                 width: 325px;
                 box-shadow: 2px 2px 2px 2px #e0e0e0;
               }
               
               .quotation-mark {
                 margin-top: -10px;
                 font-weight: bold;
                 font-size: 100px;
                 color: white;
                 font-family: "Times New Roman", Georgia, Serif;
               }
               
               .quote-text {
                 font-size: 19px;
                 font-weight: bold;
                 margin-top: -65px;
               }
               
               `,
        "render_when_ready": false,
    }

    body, err := json.Marshal(request)
    if err != nil {
        panic(err)
    }
    httpRequest, err := http.NewRequest(http.MethodPost, "https://hcti.io/v1/image", bytes.NewReader(body))
    if err != nil {
        panic(err)
    }
    httpRequest.SetBasicAuth(os.Getenv("HCTI_API_ID"), os.Getenv("HCTI_API_KEY"))
    httpRequest.Header.Set("Content-Type", "application/json")

    client := &http.Client{Timeout: 30 * time.Second}
    response, err := client.Do(httpRequest)
    if err != nil {
        panic(err)
    }
    defer response.Body.Close()
    responseBody, err := io.ReadAll(response.Body)
    if err != nil {
        panic(err)
    }
    if response.StatusCode >= http.StatusBadRequest {
        panic(fmt.Sprintf("HCTI request failed (%d): %s", response.StatusCode, responseBody))
    }

    var result struct {
        URL string `json:"url"`
    }
    if err := json.Unmarshal(responseBody, &result); err != nil {
        panic(err)
    }
    fmt.Println(result.URL)
}

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