Skip to main content
Glama

pdf_create_from_markdown

Convert Markdown content to formatted PDF documents with support for headings, tables, lists, and code blocks using Roboto font.

Instructions

Create a rich PDF from Markdown content. Supports headings, bold, italic, tables, lists, and code blocks. Uses Roboto font.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
markdownYesMarkdown content to render as PDF
outputPathYesAbsolute path for the output PDF file
pageSizeNoPage size. Defaults to A4.
titleNoPDF document title metadata
authorNoPDF document author metadata
pageNumbersNoAdd page numbers to footer. Defaults to false.
headerTextNoText to display in the page header
footerTextNoText to display in the page footer (above page numbers if both enabled)

Implementation Reference

  • The handler function for 'pdf_create_from_markdown' tool which calls the 'createFromMarkdown' service.
    async ({ markdown, outputPath, pageSize, title, author, pageNumbers, headerText, footerText }) => {
      try {
        const resolvedOutput = await validateOutputPath(outputPath);
    
        const result = await createFromMarkdown({
          markdown,
          outputPath: resolvedOutput,
          pageSize: pageSize as "A4" | "LETTER" | "LEGAL" | undefined,
          title,
          author,
          pageNumbers,
          headerText,
          footerText,
        });
    
        return toolSuccess({
          outputPath: result.outputPath,
          pageCount: result.pageCount,
          pageSize: pageSize ?? "A4",
          fileSize: result.fileSize,
        });
      } catch (error) {
        return toolError(
          error instanceof Error ? error.message : String(error)
        );
      }
    }
  • Registration of the 'pdf_create_from_markdown' tool including schema definition.
    server.registerTool(
      "pdf_create_from_markdown",
      {
        description:
          "Create a rich PDF from Markdown content. Supports headings, bold, italic, tables, lists, and code blocks. Uses Roboto font.",
        inputSchema: z
          .object({
            markdown: z
              .string()
              .min(1)
              .max(10_000_000)
              .describe("Markdown content to render as PDF"),
            outputPath: z
              .string()
              .max(4096)
              .describe("Absolute path for the output PDF file"),
            pageSize: z
              .enum(["A4", "LETTER", "LEGAL"])
              .optional()
              .describe("Page size. Defaults to A4."),
            title: z.string().max(1000).optional().describe("PDF document title metadata"),
            author: z
              .string()
              .max(1000)
              .optional()
              .describe("PDF document author metadata"),
            pageNumbers: z
              .boolean()
              .optional()
              .describe("Add page numbers to footer. Defaults to false."),
            headerText: z
              .string()
              .max(500)
              .optional()
              .describe("Text to display in the page header"),
            footerText: z
              .string()
              .max(500)
              .optional()
              .describe("Text to display in the page footer (above page numbers if both enabled)"),
          })
          .strict(),
        annotations: {
          readOnlyHint: false,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: false,
        },
      },

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/AryanBV/pdf-toolkit-mcp'

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