> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chromiumly.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Markdown conversion and screenshots

> Convert HTML plus Markdown to PDF or capture a screenshot with MarkdownConverter and MarkdownScreenshot.

The Markdown route needs an **`index.html`** (template/layout) and a **Markdown file**. Gotenberg supports [MathJax](https://www.mathjax.org/) for math in Markdown. Your `index.html` must include the Go template action where the content should appear: `{{ toHTML "file.md" }}` (use the actual Markdown filename). See [Gotenberg’s Markdown conversion](https://gotenberg.dev/docs/8.x/convert-with-chromium/convert-markdown-to-pdf) for template details. Gotenberg renders the Markdown into the HTML and then converts or captures.

## Convert Markdown to PDF

```typescript theme={null}
import { MarkdownConverter } from "chromiumly";

const markdownConverter = new MarkdownConverter();
const buffer = await markdownConverter.convert({
  html: "path/to/index.html",
  markdown: "path/to/document.md",
});
```

Both `html` and `markdown` can be a file path string, `Buffer`, or `ReadStream`. Add [conversion options](https://docs.chromiumly.dev/v6/chromium/options.md) (e.g. `properties`, `header`, `footer`) to the same object.

`markdown` also accepts an array of distinctly-named files, all referenced from the same `index.html` template:

```typescript theme={null}
const buffer = await markdownConverter.convert({
  html: "path/to/index.html",
  markdown: [
    { file: "path/to/chapter1.md", name: "chapter1.md" },
    { file: "path/to/chapter2.md", name: "chapter2.md" },
  ],
});
```

Both the convert and screenshot routes also accept an optional `assets` field for images, stylesheets, or other files referenced from the HTML/Markdown content:

```typescript theme={null}
const buffer = await markdownConverter.convert({
  html: "path/to/index.html",
  markdown: "path/to/document.md",
  assets: [{ file: "path/to/style.css", name: "style.css" }],
});
```

## Capture Markdown as screenshot

```typescript theme={null}
import { MarkdownScreenshot } from "chromiumly";

const screenshot = new MarkdownScreenshot();
const buffer = await screenshot.capture({
  html: "path/to/index.html",
  markdown: "path/to/document.md",
});
```

Use `properties` for image format and dimensions. See [Options](https://docs.chromiumly.dev/v6/chromium/options.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.