A GitHub Action that converts Markdown or Word (.docx/.doc) files
to PDF. Markdown files are first converted to .docx via
Pandoc, then the Word document is converted to PDF using
LibreOffice in headless mode.
The PDF preserves the document's layout, fonts, and template styling, which is not possible with a separate Pandoc/LaTeX render.
- name: Convert Markdown to PDF
uses: bryanpaget/markdown-to-pdf@main
with:
markdown_file: "docs/readme.md"
pdf_file: "output/readme.pdf"- name: Convert Word to PDF
uses: bryanpaget/markdown-to-pdf@main
with:
docx_file: "output/document.docx"
pdf_file: "output/document.pdf"| Input | Required | Description |
|---|---|---|
docx_file |
no | Path to the source Word document (.docx/.doc). |
markdown_file |
no | Path to a Markdown file (auto-converted to .docx first). |
pdf_file |
yes | Path where the resulting PDF should be written. |
code_block_style |
no | When "true", code blocks render with a light background and smaller font. Default "false". |
page_breaks |
no | When "sections", each H1 heading starts on a new page. Default "none". |
font |
no | When "arial", switches the document font to Arial. Default "default". |
Provide either docx_file or markdown_file (not both).
| Output | Description |
|---|---|
pdf_file |
Resolved path to the generated PDF. |
Pre-built sample PDFs are attached to each
release. They are
generated from samples/complex-document.md —
a document with tables, code blocks, lists, blockquotes, embedded financial
charts, and extensive formatting. Both the Markdown→PDF and DOCX→PDF
paths are included.
To generate them locally:
pandoc samples/complex-document.md --resource-path=samples -o complex-document.docx
python3 lib/fix-docx.py complex-document.docx
soffice --headless --convert-to pdf complex-document.docxlibreoffice-writer(auto-installed if missing)pandoc(auto-installed if usingmarkdown_file)
GPL or similar
