create_pdf_from_markdown
Convert Markdown content to PDF documents with support for headers, lists, tables, code blocks, images, and Mermaid diagrams. Customize paper format, orientation, borders, page numbers, and optional watermarks.
Instructions
Convert markdown content to PDF. Supports basic markdown elements like headers, lists, tables, code blocks, blockquotes, images (both local and external URLs), and Mermaid diagrams. Note: Cannot handle LaTeX math equations. Mermaid syntax errors will be displayed directly in the PDF output.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| markdown | Yes | Markdown content to convert to PDF | |
| outputFilename | No | Create a filename for the PDF file to be saved (default: "final-output.pdf"). The environmental variable M2P_OUTPUT_DIR sets the output path directory. If directory is not provided, it will default to user's HOME directory. | |
| paperFormat | No | Paper format for the PDF (default: letter) | letter |
| paperOrientation | No | Paper orientation for the PDF (default: portrait) | portrait |
| paperBorder | No | Border margin for the PDF (default: 2cm). Use CSS units (cm, mm, in, px) | 20mm |
| watermark | No | Optional watermark text (max 15 characters, uppercase), e.g. "DRAFT", "PRELIMINARY", "CONFIDENTIAL", "FOR REVIEW", etc | |
| watermarkScope | No | Control watermark visibility: "all-pages" repeats on every page, "first-page" displays on the first page only (default: all-pages) | all-pages |
| showPageNumbers | No | Include page numbers in the PDF footer (default: false) |
Input Schema (JSON Schema)
{
"properties": {
"markdown": {
"description": "Markdown content to convert to PDF",
"type": "string"
},
"outputFilename": {
"description": "Create a filename for the PDF file to be saved (default: \"final-output.pdf\"). The environmental variable M2P_OUTPUT_DIR sets the output path directory. If directory is not provided, it will default to user's HOME directory.",
"type": "string"
},
"paperBorder": {
"default": "20mm",
"description": "Border margin for the PDF (default: 2cm). Use CSS units (cm, mm, in, px)",
"pattern": "^[0-9]+(.[0-9]+)?(cm|mm|in|px)$",
"type": "string"
},
"paperFormat": {
"default": "letter",
"description": "Paper format for the PDF (default: letter)",
"enum": [
"letter",
"a4",
"a3",
"a5",
"legal",
"tabloid"
],
"type": "string"
},
"paperOrientation": {
"default": "portrait",
"description": "Paper orientation for the PDF (default: portrait)",
"enum": [
"portrait",
"landscape"
],
"type": "string"
},
"showPageNumbers": {
"default": false,
"description": "Include page numbers in the PDF footer (default: false)",
"type": "boolean"
},
"watermark": {
"description": "Optional watermark text (max 15 characters, uppercase), e.g. \"DRAFT\", \"PRELIMINARY\", \"CONFIDENTIAL\", \"FOR REVIEW\", etc",
"maxLength": 15,
"pattern": "^[A-Z0-9\\s-]+$",
"type": "string"
},
"watermarkScope": {
"default": "all-pages",
"description": "Control watermark visibility: \"all-pages\" repeats on every page, \"first-page\" displays on the first page only (default: all-pages)",
"enum": [
"all-pages",
"first-page"
],
"type": "string"
}
},
"required": [
"markdown"
],
"type": "object"
}