This repository demonstrates the markdown-to-pdf-action with real-world examples, workflow configurations, and custom themes. Fork this repository to get started quickly or use it as a reference for your own implementation.
Click the "Fork" button at the top of this page to create your own copy.
Go to the "Actions" tab in your fork and enable workflows.
Choose any workflow from the examples:
- Go to Actions tab
- Select a workflow from the left sidebar
- Click Run workflow
- Download the generated PDFs from the workflow artifacts
Located in .github/workflows/, these demonstrate different use cases:
| Workflow | Description | Key Features |
|---|---|---|
| basic.yml | Simple single-file conversion | Default settings, minimal configuration |
| advanced.yml | Full-featured example | Custom CSS, metadata, multiple files |
| multi-format.yml | Different paper sizes and themes | A4/Letter, Portrait/Landscape, themes |
| conditional.yml | Process only changed files | Efficient CI/CD integration |
| scheduled.yml | Weekly documentation export | Cron scheduling, organized artifacts |
| pr-preview.yml | Preview docs in pull requests | PR integration, automatic comments |
Located in docs/ and examples/, these showcase various Markdown features:
- Basic Markdown: Headers, lists, links, emphasis
- Code Blocks: Syntax highlighting across languages
- Tables: Professional table formatting
- Images: Embedded images and diagrams
- Task Lists: Interactive checkboxes
- Emojis: GitHub-style emoji rendering
- Table of Contents: Auto-generated navigation
Located in assets/css/, ready-to-use professional themes:
- professional-theme.css: Business documents with modern styling
- technical-theme.css: API docs and technical specifications
- minimal-theme.css: Clean, distraction-free reading
- executive-theme.css: Executive summaries and reports
Convert a single Markdown file to PDF:
- name: Convert README to PDF
uses: MystaMax/markdown-to-pdf@v1
with:
include-patterns: 'README.md'
artifact-name: 'readme-pdf'Try it: See .github/workflows/basic.yml
Apply custom CSS for branded PDFs:
- name: Convert with custom theme
uses: MystaMax/markdown-to-pdf@v1
with:
include-patterns: 'docs/**/*.md'
css-file: 'assets/css/professional-theme.css'
paper-size: 'A4'
orientation: 'portrait'Try it: See .github/workflows/advanced.yml
Generate different PDF formats from the same content:
strategy:
matrix:
include:
- paper: 'A4'
orientation: 'portrait'
theme: 'professional'
- paper: 'Letter'
orientation: 'landscape'
theme: 'technical'Try it: See .github/workflows/multi-format.yml
Process only changed files on pull requests:
- name: Get changed Markdown files
uses: tj-actions/changed-files@v44
with:
files: '**/*.md'
- name: Convert changed files
if: steps.changed-files.outputs.any_changed == 'true'
uses: MystaMax/markdown-to-pdf@v1
with:
include-patterns: ${{ steps.changed-files.outputs.all_changed_files }}Try it: See .github/workflows/conditional.yml
Automate weekly documentation exports:
on:
schedule:
- cron: '0 9 * * 1' # Every Monday at 9 AM
jobs:
weekly-export:
# ... generate PDFs with date-stamped artifactsTry it: See .github/workflows/scheduled.yml
- Create a CSS file in
assets/css/ - Reference it in your workflow:
with:
css-file: 'assets/css/my-custom-theme.css'- See assets/css/README.md for CSS examples and tips
Add metadata to individual Markdown files:
---
title: "My Document Title"
author: "Your Name"
subject: "Document Category"
date: "2024-01-15"
---
# Your Content HereOrganize PDFs in artifacts:
with:
artifact-path-mode: 'preserve' # Keep folder structure
artifact-subdir: 'reports/2024' # Organize by dateWhile the action runs in GitHub Actions, you can test your Markdown rendering:
- Preview Markdown: Use VS Code, GitHub, or any Markdown viewer
- Validate CSS: Use browser dev tools to test styles
- Check Images: Ensure all image paths are relative and files exist
markdown-to-pdf-action-examples/
βββ README.md # This file
βββ .github/
β βββ workflows/
β βββ basic.yml # Simple example
β βββ advanced.yml # Full-featured example
β βββ multi-format.yml # Multiple outputs
β βββ conditional.yml # Changed files only
β βββ scheduled.yml # Weekly automation
β βββ pr-preview.yml # PR integration
βββ docs/
β βββ getting-started.md # Beginner's guide
β βββ advanced-features.md # Advanced usage
β βββ api-reference.md # API documentation style
β βββ troubleshooting.md # Common issues
β βββ images/
β βββ architecture-diagram.png # Sample image
βββ examples/
β βββ basic/
β β βββ README.md # Basic example overview
β β βββ simple-document.md # Minimal Markdown
β βββ code-heavy/
β β βββ README.md # Code-heavy docs overview
β β βββ api-guide.md # With code blocks
β βββ with-images/
β β βββ README.md # Image example overview
β β βββ visual-guide.md # Document with images
β β βββ images/
β β βββ sample.png # Sample image
β βββ technical-spec/
β βββ README.md # Technical doc overview
β βββ specification.md # Technical specification
βββ assets/
βββ css/
β βββ README.md # CSS guide
β βββ professional-theme.css # Business theme
β βββ technical-theme.css # Technical docs theme
β βββ minimal-theme.css # Minimal clean theme
β βββ executive-theme.css # Executive reports theme
βββ images/
βββ logo.png # Example logo
βββ banner.png # Example banner
- uses: MystaMax/markdown-to-pdf@v1
with:
source-dir: 'docs'
include-patterns: '**/*.md'
exclude-patterns: '**/README.md'
css-file: 'assets/css/professional-theme.css'
include-toc: true- uses: MystaMax/markdown-to-pdf@v1
with:
include-patterns: 'api-docs/**/*.md'
css-file: 'assets/css/technical-theme.css'
paper-size: 'Letter'
orientation: 'landscape'on:
release:
types: [published]
- uses: MystaMax/markdown-to-pdf@v1
with:
include-patterns: 'CHANGELOG.md'
title: 'Release ${{ github.event.release.tag_name }}'
artifact-name: 'release-notes-${{ github.event.release.tag_name }}'- Check the workflow logs for errors
- Verify your file patterns match existing files
- Ensure the action has proper permissions
- Verify CSS file path is correct (relative to repository root)
- Check CSS syntax with a validator
- Use browser dev tools to test styles
- Consider splitting large documents
- Optimize images (compress, resize)
- Process files in batches
- See docs/troubleshooting.md for detailed solutions
- Check the main action repository for documentation
- Review workflow logs in the Actions tab
Have a great use case? Contributions are welcome!
- Fork this repository
- Add your example workflow and/or sample documents
- Update this README with your example
- Submit a pull request
This example repository is provided as-is for demonstration purposes. The markdown-to-pdf-action itself is licensed under MIT.
- Main Action: MystaMax/markdown-to-pdf
- Documentation: See the main repository README
- Issues: Report issues in the main repository
- Discussions: GitHub Discussions
Happy PDF generation! πβ¨