Convert Markdown to PDF with Power Automate (Full Guide)

Markdown document converting to a PDF through an automation flow

Power Automate can convert a Markdown file to PDF - we write a .md file to OneDrive and use the ConvertFileByPath connector action to convert it to PDF. The conversion happens server-side via the Microsoft Graph API.

This guide walks through the full setup, including what Markdown features work and what doesn’t work (as of 2026-05).

The Flow Architecture

The flow does five things in sequence:

  1. Compose the Markdown content
  2. Save it as a .md file to SharePoint (for archiving)
  3. Save it to OneDrive (required for conversion)
  4. Call ConvertFileByPath twice — once for PDF, once for HTML
  5. Save the output files back to SharePoint

Why OneDrive, Not SharePoint?

It is possible to use SharePoint HTTP Request connector with ?format=pdf appended to the file URL. This returns HTTP 302 Found — a redirect to the actual file download. You’ll need to ignore the 302 and follow the redirect location header to read the file. Since it may not be ready right away, you may have to loop to wait for it to become ready. The OneDrive action is a bit easier to use.

The OneDrive ConvertFileByPath connector handles the redirect internally and returns the converted binary directly. No workaround needed.

The ConvertFileByPath Action

Under the OneDrive for Business connector:

  • Operation: ConvertFileByPath
  • path: The file path in OneDrive, e.g. /md-pdf-test-20260526.md
  • type: One of PDF, HTML, GLB, or JPG

Testing All 12 Markdown Feature Categories

I built a test flow that generates a comprehensive Markdown document covering 12 feature categories, then converts it to both PDF and HTML. Here is what the test covers:

#CategoryWhat is tested
1HeadingsH1 through H6
2Text formattingBold, italic, bold+italic, strikethrough, inline code
3BlockquotesSingle, multi-line, nested
4ListsUnordered, ordered, nested, task lists (GFM)
5TablesFeature checklist, column alignment
6Code blocksJavaScript, Python, JSON with syntax hint
7Mermaid diagramsFlowchart, sequence diagram
8Links and horizontal rulesExternal links, --- separators
9Images (public internet)Absolute HTTPS URL
10Images (SharePoint hosted)Absolute encoded, absolute unencoded, relative URL
11Special charactersHTML entities, emoji codes, escaped Markdown
12FootnotesNumbered and named footnotes

What Actually Survived?

I tested two things: the PDF produced by ConvertFileByPath, and the source .md file opened in SharePoint’s built-in Markdown viewer. These are separate render pipelines and the results differ substantially.

The ConvertFileByPath HTML output is a third artefact — not covered in this test.

FeaturePDFSP Markdown viewerNotes
H1–H6 headingsAll six levels in both outputs
Bold
Italic
Bold + italic
StrikethroughPDF renders ~~text~~ as literal tildes; SP viewer renders correctly
Inline codeMonospace in both
Blockquotes (all levels)PDF breaks at level 3+; SP viewer renders all nesting with indent bars
Unordered listsIncluding nested items
Ordered listsIncluding sub-items
Task listsPDF shows literal [x]; SP viewer renders actual checkboxes
TablesSP viewer has full borders; PDF has columnar layout without gridlines
Code blocksPDF: monospace only; SP viewer: syntax highlighting
Mermaid diagramsPDF: raw code text; SP viewer: fully rendered flowcharts and sequence diagrams
LinksClickable in both
Horizontal rules--- renders as a visible line in both
HTML inline page-breakPDF: renders as literal text; SP viewer: silently removed
Images — public HTTPS URLPDF: raw Markdown text; SP viewer: raw Markdown text (no external fetch)
Images — SharePoint absolute, percent-encodedPDF: broken image; SP viewer: renders correctly
Images — SharePoint absolute, unencoded (space in URL)Both: raw Markdown syntax — space in URL breaks the parser in both
Images — SharePoint relative, percent-encodedPDF: broken image; SP viewer: renders correctly
HTML entities (&, © etc.)Both render correctly
Emoji shortcodes (:rocket: etc.)Literal text in both outputs
Escaped Markdown (\*, ```)Both render as literal characters
FootnotesSuperscripts, footnote list, and back-links work in both

Key takeaways

SharePoint’s built-in Markdown viewer is excellent — it renders Mermaid diagrams, task list checkboxes, strikethrough, nested blockquotes, and syntax-highlighted code blocks. None of that survives into the PDF.

Tables came out good, could do with a bit more formatting.

For images, they just didn’t work very well - percent-encoded SharePoint URLs work in the SP viewer but not in the PDF — the ConvertFileByPath converter runs without user auth and cannot read SharePoint files. Public internet images fail in both — neither pipeline fetches external URLs. Always percent-encode your image URLs; unencoded spaces in paths break the Markdown parser in both renderers.

Page Breaks

In the PDF, the <div style="page-break-after: always;"> tag renders as literal text — HTML is not processed by the converter. In SharePoint’s Markdown viewer, the tag is silently removed. There is no supported way to force a page break.

The Full Flow test was conducted automatically via Flow Studio MCP

The flow is available in the Flow Studio Demo environment as MCP Demo - Markdown to PDF Full Feature Test. It was built entirely using the Flow Studio MCP server from within VS Code — no manual portal editing.

Key action structure:

Compose_File_Name
Compose_S01_Headings ... Compose_S12_Footnotes  (parallel)
  → Compose_Markdown
    → Create_Markdown_File (SharePoint)
      → Create_OneDrive_File
        → Convert_PDF_OneDrive   → Save_PDF_Result
        → Convert_HTML_OneDrive  → Save_HTML_Result
          → Response

Summary

To convert Markdown to PDF in Power Automate:

  1. Write your .md content to OneDrive using the Create File action
  2. Call ConvertFileByPath with type: PDF
  3. Save the binary output wherever you need it — SharePoint, email attachment, etc.

The converter handles most core Markdown well. The main gotchas:

  • No images — the converter runs without user auth; it cannot fetch external URLs or read SharePoint files
  • No strikethrough~~text~~ renders as literal tildes
  • No task lists[x] renders as literal text
  • No Mermaid — code blocks with the mermaid hint render as plain text
  • No HTML passthrough — inline HTML renders as raw text
  • Footnotes work — a pleasant surprise; superscripts, footnote list, and back-links all render

Discussions