Forum Discussion
How can I convert markdown to pdf on Windows 11?
Using PowerShell with OfficeIMO is a viable, completely free, and non-GUI method to convert Markdown to PDF on Windows 11. It relies on a PowerShell module that wraps .NET libraries, giving you fine-grained control over the conversion process.
How to Use PowerShell with OfficeIMO
Step 1: Install the PSWriteOffice Module
Open PowerShell as Administrator and run the following command to install the module from the PowerShell Gallery:
powershell
Install-Module -Name PSWriteOffice -Scope CurrentUser
Step 2: Run the Conversion Command
Navigate to the folder containing your Markdown file and run the export command. The Export-OfficeDocumentPdf cmdlet is the core function that handles the conversion.
powershell
Export-OfficeDocumentPdf -InputPath .\yourfile.md -Path .\yourfile.pdf
Step 3: Customize with Options
For more control, you can create an options object using New-Office MarkdownPdfOptions. This lets you set metadata like the document title, include local images, and specify a base directory for assets:
powershell
$options = New-OfficeMarkdownPdfOptions -Title 'Service report' -IncludeLocalImages -BaseDirectory .\Assets
Export-OfficeDocumentPdf -InputPath .\Report.md -Path .\Report.pdf -MarkdownOptions $options
This method uses PowerShell, which is built into Windows 11, and the OfficeIMO module is a free, MIT-licensed project. It avoids paid tools and dedicated third-party GUI applications. The Export- Office DocumentPdf cmdlet is specifically designed to convert markdown to pdf files without requiring Microsoft Office or COM automation.