Image output

Simple job ad

Advertise a job description with an image.

This example shows a simple layout that could be used for sharing a job advertisement. It uses a Google Font plus Bootstrap CSS.
Preview of Simple job ad

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.

Loading playground…

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.

require "json"
require "net/http"
require "uri"

request = {
    html: <<~'HCTI_HTML',
          <div class="Box m-4">
            <div class="Box-row Box-row--unread">
              <div class="CircleBadge CircleBadge--small bg-green float-left d-block mr-3 text-center">
                <h1 class="text-white text-center text-shadow-dark d-flex flex-justify-center height-full mt-1">S</h1>
          </div>
              <h4>Senior iOS Engineer</h4>
              <span>SuperAppCo</span><br/>
              <span>
              <label class="Label Label--gray mr-1">IOS</label> <label class="Label Label--gray mr-1">SENIOR</label> <label class="Label Label--gray mr-1">ENGINEER</label>
             </span>
            </div>
            <div class="Box-row">
          <ul class="lead ml-4 mb-0">
            <li><b>
              $150-$200k</b> salary</li>
          <li>
            Flexible hours</li>
          <li>
            Up to <b>20</b> weeks parental leave</li>
          <li>
            <b>$3,000</b> learning budget per year</li>
          <li>
          New laptop every 2 years
            </li></ul>
            </div>
          </div>
          <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Primer/10.8.1/build.css" />
          HCTI_HTML
    css: <<~'HCTI_CSS',
         .Box {
           width: 400px;
         }
         body {
           font-family: Roboto !important;
         }
         HCTI_CSS
    google_fonts: "Roboto",
}

uri = URI("https://hcti.io/v1/image")
http_request = Net::HTTP::Post.new(uri)
http_request.basic_auth(ENV.fetch("HCTI_API_ID"), ENV.fetch("HCTI_API_KEY"))
http_request["Content-Type"] = "application/json"
http_request.body = JSON.generate(request)

response = Net::HTTP.start(
    uri.hostname,
    uri.port,
    use_ssl: true,
    open_timeout: 10,
    read_timeout: 30
) { |http| http.request(http_request) }

unless response.is_a?(Net::HTTPSuccess)
    raise format("HCTI request failed (%s): %s", response.code, response.body)
end

result = JSON.parse(response.body)
puts result.fetch("url")

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

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