Skip to main content
The Chromium HTML route expects the main HTML file to be named index.html. You can send additional assets (CSS, images, fonts) via the assets option or by passing multiple files; reference them in your HTML by filename only — do not use absolute paths (/img.png) or subdirectories (./assets/img.png), because Gotenberg stores all uploaded files in a single temporary directory.

Convert HTML to PDF

import { HtmlConverter } from "chromiumly";

const htmlConverter = new HtmlConverter();
const buffer = await htmlConverter.convert({
  html: "path/to/index.html",
});
You can pass a file path string, a Buffer, or a ReadStream. Optional conversion options (e.g. properties, header, footer) go in the same options object.

Capture HTML as screenshot

import { HtmlScreenshot } from "chromiumly";

const screenshot = new HtmlScreenshot();
const buffer = await screenshot.capture({
  html: "path/to/index.html",
});
Use properties to set image format, quality, and dimensions. See Options.