Invalid Date

Technical docs, meeting notes, READMEs — engineers write Markdown every day, and often need to export it as a polished PDF. But generating beautiful PDFs from Markdown requires HTML conversion, CSS styling, and a rendering engine — more work than it should be.

With FUNBREW PDF's Markdown → PDF API, you simply send Markdown text and get a professionally themed PDF back instantly. This guide covers the API usage, theme selection, and SDK examples for every supported language.

For a broader overview of HTML-to-PDF conversion, see our Complete HTML to PDF Guide. If you prefer to start with language-specific setup, check out the Quickstart by Language.

Why You Need a Markdown → PDF API

Markdown is lightweight and readable, but converting it to PDF comes with challenges:

  • Styling: Markdown has no style information, so raw conversion produces plain-looking output
  • Tables & code blocks: GFM extensions require a parser that supports them
  • Consistency: Applying different styles per project is cumbersome
  • Infrastructure: Managing headless Chromium or wkhtmltopdf is operational overhead

FUNBREW PDF's Markdown → PDF API solves all of these in a single API call.

Basic API Usage

Endpoint

POST /api/pdf/generate-from-markdown

Minimal Request

curl -X POST https://api.funbrew.dev/api/pdf/generate-from-markdown \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"markdown": "# Hello World\n\nThis is **bold** text."}'

Parameters

Parameter Type Required Description
markdown string o Markdown text (max 5MB)
theme string Theme name (default: business)
filename string Download filename
options.page-size string A3, A4, A5, Letter, Legal
options.engine string quality (Chromium) / fast (wkhtmltopdf)
email.to string Email recipient for PDF attachment

5 Built-in Themes

Changing the theme transforms the same Markdown into a completely different design.

Theme Characteristics Best For
business Muted colors, professional layout Reports, proposals
modern Refined typography, accent colors Presentations, specs
minimal Simple with generous whitespace Notes, minutes
academic Serif fonts, paper-style layout Academic papers, reports
creative Colorful, unique layout Portfolios, newsletters

If you need custom-designed PDFs from HTML templates instead, see our PDF Template Engine Guide.

You can also fetch available themes via API:

curl https://api.funbrew.dev/api/markdown/themes

Detailed Theme Comparison

Let's take a closer look at each theme's CSS characteristics and ideal use cases.

business features serif headings, a navy accent color, and 1.6 line height for a spacious, readable layout. It is best suited for client-facing documents like reports and proposals. The strong contrast between headings and body text makes long documents easy to scan.

modern uses sans-serif fonts throughout, with a #2563EB (blue) accent color and tight spacing optimized for information-dense content. It works well for internal technical specs and presentation handouts.

minimal relies on system fonts with no decorative colors and generous margins that let whitespace do the talking. This theme is ideal for quick notes and meeting minutes where you want to produce and share a PDF as fast as possible.

academic provides a Times New Roman-style serif typeface, double spacing, and footnote support -- everything you need for paper-style documents. Best for university reports and academic paper drafts.

creative stands out with gradient headers, card-style code blocks, and a colorful palette. Choose this theme when visual impact matters, such as for portfolios or newsletters.

To compare all themes at once, you can programmatically generate a PDF for each theme and review the results side by side:

const themes = ['business', 'modern', 'minimal', 'academic', 'creative'];
for (const theme of themes) {
  const result = await pdf.fromMarkdown(markdown, theme);
  console.log(`${theme}: ${result.data.download_url}`);
}

Using the SDKs

Python

from funbrew_pdf import FunbrewPdf

pdf = FunbrewPdf("sk-your-api-key")

# Simple conversion
result = pdf.from_markdown("# Monthly Report\n\nRevenue grew 120% MoM.")
print(result["data"]["download_url"])

# With theme
result = pdf.from_markdown("# Paper Title\n\n## Abstract\n\n...", theme="academic")

Node.js

const { FunbrewPdf } = require('@funbrew/pdf');
const pdf = new FunbrewPdf('sk-your-api-key');

// Convert with theme
const result = await pdf.fromMarkdown('# Meeting Notes\n\n- Item 1\n- Item 2', 'modern');
console.log(result.data.download_url);

PHP

$pdf = new Funbrew\Pdf\FunbrewPdf('sk-your-api-key');

// Read from file and convert
$markdown = file_get_contents('report.md');
$result = $pdf->fromMarkdown($markdown, 'business');
echo $result['data']['download_url'];

GFM (GitHub Flavored Markdown) Support

FUNBREW PDF's Markdown engine fully supports GitHub Flavored Markdown. All extended syntax renders correctly in PDFs.

Tables

| Feature | Free | Starter | Basic |
|---------|:---:|:---:|:---:|
| HTML → PDF | o | o | o |
| Markdown → PDF | o | o | o |
| Templates | 1 | 3 | 5 |

Code Blocks (Syntax Highlighting)

```python
def generate_pdf(markdown_text):
    pdf = FunbrewPdf("sk-key")
    return pdf.from_markdown(markdown_text)
```

Task Lists

- [x] API design
- [x] Backend implementation
- [ ] Frontend integration
- [ ] Documentation

HTML Preview API

Want to check the output before generating a PDF? Use the preview API.

curl -X POST https://api.funbrew.dev/api/markdown/preview \
  -H "Content-Type: application/json" \
  -d '{"markdown": "# Preview Test", "theme": "modern"}'

This endpoint requires no authentication, so you can call it directly from your frontend for real-time previews.

CI/CD Pipeline: Auto-Generate PDFs on Push

If you manage Markdown files in Git, you can use GitHub Actions to automatically generate PDFs on every push. Your documentation stays in sync with its PDF output without any manual effort.

GitHub Actions Workflow

# .github/workflows/generate-pdf.yml
name: Generate PDF from Markdown

on:
  push:
    paths:
      - 'docs/**/*.md'
    branches: [main]

jobs:
  generate-pdf:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Install SDK
        run: npm install @funbrew/pdf

      - name: Generate PDFs from Markdown
        env:
          FUNBREW_API_KEY: ${{ secrets.FUNBREW_API_KEY }}
        run: node scripts/generate-pdfs.js

      - name: Upload PDF artifacts
        uses: actions/upload-artifact@v4
        with:
          name: generated-pdfs
          path: output/*.pdf
          retention-days: 30

Conversion Script

// scripts/generate-pdfs.js
const { FunbrewPdf } = require('@funbrew/pdf');
const fs = require('fs');
const path = require('path');
const glob = require('glob');

const pdf = new FunbrewPdf(process.env.FUNBREW_API_KEY);

async function main() {
  const files = glob.sync('docs/**/*.md');
  fs.mkdirSync('output', { recursive: true });

  for (const file of files) {
    const markdown = fs.readFileSync(file, 'utf-8');
    const basename = path.basename(file, '.md');

    console.log(`Converting: ${file}`);
    const result = await pdf.fromMarkdown(markdown, 'business');

    const response = await fetch(result.data.download_url);
    const buffer = Buffer.from(await response.arrayBuffer());
    fs.writeFileSync(`output/${basename}.pdf`, buffer);

    console.log(`Generated: output/${basename}.pdf`);
  }
}

main().catch(console.error);

Auto-Select Themes by Path

You can automatically pick a theme based on the file's directory:

function getThemeForPath(filePath) {
  if (filePath.includes('reports/')) return 'business';
  if (filePath.includes('papers/')) return 'academic';
  if (filePath.includes('notes/')) return 'minimal';
  return 'modern';
}

const theme = getThemeForPath(file);
const result = await pdf.fromMarkdown(markdown, theme);

This automation pattern is especially useful for team documentation workflows. Push Markdown to GitHub, and up-to-date PDFs are generated automatically. See also the serverless deployment guide and production best practices.

Report Generation

When managing recurring reports in Markdown, combining templates with variable substitution creates a powerful report pipeline. See the Report PDF Generation Guide for full details.

const template = fs.readFileSync('templates/monthly-report.md', 'utf-8');

const markdown = template
  .replace('{{month}}', 'March 2026')
  .replace('{{revenue}}', '$125,000')
  .replace('{{growth}}', '+15%');

const result = await pdf.fromMarkdown(markdown, 'business');

Migrating from Puppeteer

If you've been using Puppeteer or Playwright to convert Markdown to HTML and then to PDF, switching to FUNBREW PDF eliminates the need for infrastructure management. No more headless browser memory issues or Chromium version headaches. See the Puppeteer Migration Guide for a detailed walkthrough.

Aspect Puppeteer FUNBREW PDF API
Infrastructure Requires Chromium None (API call only)
Themes Build CSS yourself 5 built-in themes
GFM support Needs plugins Built-in
CI/CD Heavy Docker + Chromium Just npm install

For feature and pricing comparisons with other PDF APIs, see the PDF API Comparison and Pricing Guide.

Error Handling & Security

When running the Markdown → PDF API in production, handling timeouts and rate limits is critical. See the Error Handling Guide for exponential backoff implementation. For secure API key management, refer to the Security Guide.

For bulk Markdown-to-PDF conversion, the Batch Processing Guide covers efficient parallel processing patterns.

Try It Free

You can try Markdown → PDF conversion for free on our Markdown → PDF page — no API key required. Drag & drop .md files is supported too.

For more advanced use, try the Playground to test API requests, or use the Dashboard Markdown tool for watermark-free output.

Japanese Markdown Considerations

When converting Markdown that contains Japanese text to PDF, there are several considerations that differ from English-only documents.

Full-Width Characters and Line Length

Japanese full-width characters occupy roughly twice the width of half-width (Latin) characters. Table cell content and headings tend to be wider, so be mindful of line length and insert line breaks where appropriate to prevent layout overflow in the generated PDF.

Font Selection

FUNBREW PDF comes with Noto Sans JP pre-installed, optimized for Japanese body text and headings alike. When specifying font-family in CSS, place the Japanese font before the Latin fonts:

font-family: "Noto Sans JP", "Helvetica Neue", Arial, sans-serif;

This priority order ensures Japanese characters render with Noto Sans JP while alphanumeric characters fall back to Helvetica or Arial.

Mixing Japanese and English Text

In bilingual technical documents, font-family priority order is especially important. If the Latin font is listed first, Japanese characters may not render correctly due to font fallback behavior.

Ruby Text (Furigana)

Standard Markdown syntax does not support ruby text (furigana). If you need furigana annotations, embed HTML <ruby> tags directly in your Markdown:

You can add ruby to <ruby>漢字<rp>(</rp><rt>かんじ</rt><rp>)</rp></ruby> inline.

Vertical Text

Vertical text layout (tategaki) is not supported by the Markdown to PDF API. If you need vertical text, consider using HTML templates for PDF generation instead. See the PDF Template Engine Guide for details.

Common Conversion Issues

Here are the most frequently encountered problems when converting Markdown to PDF, along with their solutions.

Table Columns Collapse

When table cell content is too wide, columns get compressed and become hard to read. The solution is to shorten the cell text or change options.page-size to A3 or Letter to increase the page width.

{
  "markdown": "...",
  "theme": "business",
  "options": {
    "page-size": "A3"
  }
}

Code Blocks Truncated

Very long lines in code blocks wrap by default. If you need to avoid wrapping, set options.engine to quality (Chromium), which handles overflow more gracefully.

{
  "markdown": "...",
  "options": {
    "engine": "quality"
  }
}

Images Not Rendering

Images referenced via Markdown's ![alt](url) syntax must be publicly accessible URLs. Local file paths will not work. Alternatively, Base64 data URIs are also supported.

![Chart](https://example.com/public-image.png)

Emoji Rendering

Emoji characters in Markdown (e.g., checkmarks, crosses) render correctly with the quality engine (Chromium). The fast engine (wkhtmltopdf) may display them as empty boxes (tofu). For documents containing emoji, use the quality engine for reliable rendering.

Summary

  • Send Markdown text, get a themed PDF back
  • 5 themes for different use cases
  • Full GFM support for tables, code blocks, and task lists
  • One-liner SDK support for Python, Node.js, and PHP
  • Preview API to check output before generating

See the API Reference for full details. Get your free API key from the Dashboard. For real-world PDF use cases, check out our Invoice PDF Automation Guide and Certificate PDF Automation Guide. For framework integration, see the Next.js & Nuxt PDF API Guide and Django/FastAPI Guide.

Powered by FUNBREW PDF