Convert Markdown to PDF with Power Automate (Full Guide)
![]()
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:
- Compose the Markdown content
- Save it as a
.mdfile to SharePoint (for archiving) - Save it to OneDrive (required for conversion)
- Call ConvertFileByPath twice — once for PDF, once for HTML
- 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, orJPG
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:
| # | Category | What is tested |
|---|---|---|
| 1 | Headings | H1 through H6 |
| 2 | Text formatting | Bold, italic, bold+italic, strikethrough, inline code |
| 3 | Blockquotes | Single, multi-line, nested |
| 4 | Lists | Unordered, ordered, nested, task lists (GFM) |
| 5 | Tables | Feature checklist, column alignment |
| 6 | Code blocks | JavaScript, Python, JSON with syntax hint |
| 7 | Mermaid diagrams | Flowchart, sequence diagram |
| 8 | Links and horizontal rules | External links, --- separators |
| 9 | Images (public internet) | Absolute HTTPS URL |
| 10 | Images (SharePoint hosted) | Absolute encoded, absolute unencoded, relative URL |
| 11 | Special characters | HTML entities, emoji codes, escaped Markdown |
| 12 | Footnotes | Numbered 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
ConvertFileByPathHTML output is a third artefact — not covered in this test.
| Feature | SP Markdown viewer | Notes | |
|---|---|---|---|
| H1–H6 headings | ✅ | ✅ | All six levels in both outputs |
| Bold | ✅ | ✅ | |
| Italic | ✅ | ✅ | |
| Bold + italic | ✅ | ✅ | |
| Strikethrough | ❌ | ✅ | PDF renders ~~text~~ as literal tildes; SP viewer renders correctly |
| Inline code | ✅ | ✅ | Monospace in both |
| Blockquotes (all levels) | ❌ | ✅ | PDF breaks at level 3+; SP viewer renders all nesting with indent bars |
| Unordered lists | ✅ | ✅ | Including nested items |
| Ordered lists | ✅ | ✅ | Including sub-items |
| Task lists | ❌ | ✅ | PDF shows literal [x]; SP viewer renders actual checkboxes |
| Tables | ✅ | ✅ | SP viewer has full borders; PDF has columnar layout without gridlines |
| Code blocks | ✅ | ✅ | PDF: monospace only; SP viewer: syntax highlighting |
| Mermaid diagrams | ❌ | ✅ | PDF: raw code text; SP viewer: fully rendered flowcharts and sequence diagrams |
| Links | ✅ | ✅ | Clickable in both |
| Horizontal rules | ✅ | ✅ | --- renders as a visible line in both |
| HTML inline page-break | ❌ | ➖ | PDF: renders as literal text; SP viewer: silently removed |
| Images — public HTTPS URL | ❌ | ❌ | PDF: raw Markdown text; SP viewer: raw Markdown text (no external fetch) |
| Images — SharePoint absolute, percent-encoded | ❌ | ✅ | PDF: 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-encoded | ❌ | ✅ | PDF: 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 |
| Footnotes | ✅ | ✅ | Superscripts, 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:
- Write your
.mdcontent to OneDrive using the Create File action - Call ConvertFileByPath with
type: PDF - 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
mermaidhint 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