Skip to main content
Glama

convert_to_pdf

Idempotent

Convert Markdown to print-ready PDF documents while preserving tables and mathematical expressions. Renders content through headless browser for high-fidelity output.

Instructions

Convert Markdown to a PDF document. Renders the Markdown as styled HTML (GFM tables, KaTeX math) and then prints it to PDF via a headless Chromium browser (Puppeteer). Requires a locally installed Chrome, Edge, or Chromium — set PUPPETEER_EXECUTABLE_PATH env var to override auto-detection. This is a binary format — output_path should almost always be provided. Side effects: launches a transient headless browser process for rendering (no network requests are made for the conversion itself, though the HTML references a CDN KaTeX stylesheet which may be fetched). When output_path is provided, writes the PDF to disk (creates parent directories, overwrites existing files). When output_path is omitted, returns JSON { format: 'pdf', file_size_bytes, hint, base64_preview }. Returns: JSON write-confirmation (if output_path set), or JSON binary-guidance object (if omitted). Use this for high-fidelity, print-ready document output. Prefer convert_to_html for web-viewable output, convert_to_docx for editable documents, or convert_to_latex for LaTeX toolchains.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
markdownYesThe raw Markdown source text to convert. Supports GitHub-Flavored Markdown (tables, task lists, strikethrough) and KaTeX math expressions. Pass the full document content as a string, not a file path.
output_pathNoOptional. Absolute or relative file path (e.g. './output.pdf') where the binary file will be saved. Parent directories are created automatically. If provided, the file is written to disk and a JSON summary with { success, file_path, file_size_bytes, format } is returned. If omitted, a JSON object with { format, file_size_bytes, hint, base64_preview } is returned — the hint will instruct you to call the tool again with output_path to save the file. Binary formats (PDF) should almost always specify output_path.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/XJTLUmedia/MCP_Markdown_Formatter'

If you have feedback or need assistance with the MCP directory API, please join our Discord server