Skip to main content
The Markdown route needs an index.html (template/layout) and a Markdown file. Gotenberg supports MathJax 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 for template details. Gotenberg renders the Markdown into the HTML and then converts or captures.

Convert Markdown to PDF

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 (e.g. properties, header, footer) to the same object.

Capture Markdown as screenshot

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.