Markdown to PDF
markdown_to_pdfConverts Markdown text or a Markdown file into a PDF with formatted tables, math, diagrams, images and code, then reports the PDF page count and rendering warnings.
Instructions
Converts Markdown (text or a file) to a PDF with RayoMD and returns the PDF's page count and warnings. Renders: GitHub Markdown (tables, task lists, footnotes, alerts > [!NOTE]), PNG/JPEG/SVG images with alt text (relative paths inside the Markdown file's folder), TeX math ($...$, $$...$$ on own lines, math), mermaid flowchart/graph, sequenceDiagram and pie, code colouring in 29 languages, page breaks (\pagebreak, ), [TOC], YAML front matter (title, author, lang) as PDF metadata. Degrades: CSS/HTML layout (text kept), LaTeX packages and macros, other Mermaid types (printed as code), SVGs needing scripts. Full list: resource rayomd://syntax.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| toc | No | A table of contents first, or at a [TOC] paragraph | |
| path | No | A Markdown file to convert (give this or markdown) | |
| pdfa | No | PDF/A-3b: every font embedded | |
| pdfua | No | PDF/UA-1, tagged for screen readers (formulas as TeX source) | |
| style | No | Look of the document (default elegant) | |
| margin | No | compact, normal (default), wide, or margin=N in inches or margin=Npt: margin=0.75in, margin=54pt | |
| output | Yes | The PDF to write, ending in .pdf; an existing file is replaced | |
| dialect | No | github (default), or obsidian: callouts, ==highlights==, %%comments%%, [[wiki links]], ![[embeds]] | |
| diagrams | No | Draw ```mermaid flowcharts, sequence diagrams and pie charts (default true) | |
| markdown | No | The Markdown text (give this or path) | |
| footnotes | No | end (default): after the text; page: at the foot of the page of the first reference | |
| page_size | No | a4 (default), a3, a5, letter or legal, each also with -landscape; WIDTHxHEIGHT in mm, cm, in or pt (210x297mm); or WIDTHxauto (210mmxauto: one long page) | |
| toc_depth | No | Heading levels the table of contents lists (default 3) | |
| black_text | No | For black-and-white printers: text, links and code black, fills light grey | |
| source_path | No | With markdown: the .md file the text stands for; relative images resolve from its folder. Default: output with .md | |
| page_numbers | No | "N / M" at the foot of every page | |
| highlight_code | No | Colour fenced code by language (default true) | |
| number_headings | No | Number the headings of this many levels: 1, 1.1, 1.1.1 | |
| page_break_before | No | A new page before each heading of level 1 to N (h1: chapters) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ms | Yes | Build time in milliseconds | |
| code | Yes | rayomd exit code: 0 ok, 2 bad request, 3 input not readable, 10+N build error, 12 output not writable | |
| bytes | Yes | ||
| error | No | ||
| input | Yes | The input path, or the source_path of Markdown text | |
| pages | Yes | ||
| output | Yes | The PDF written | |
| status | Yes | ||
| failed_images | Yes | Images that could not be loaded (their alt text is printed) | |
| missing_characters | Yes | Characters without a glyph in the fonts found (drawn as a base letter or ?) |