API Documentation

Integrate Markdown to PDF conversion into your own applications

Client-Side Library

MarkdownPDF operates entirely in the browser. Below is documentation for integrating similar functionality into your own apps using JavaScript.

Getting Started

To integrate Markdown to PDF conversion, you'll need the following libraries:

<!-- Markdown Parser -->
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>

<!-- PDF Generator -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>

Basic Usage

const markdownText = '# Hello World\n\nThis is **bold** text.';
const html = marked.parse(markdownText);

const element = document.createElement('div');
element.innerHTML = html;

html2pdf()
    .set({
        margin: 10,
        filename: 'document.pdf',
        html2canvas: { scale: 2 },
        jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
    })
    .from(element)
    .save();

Configuration Options

OptionTypeDefaultDescription
marginnumber10Page margins in mm
filenamestring'doc.pdf'Output filename
jsPDF.formatstring'a4'Page format (a4, letter, etc)

Important Notes

  • All processing happens client-side in the browser.
  • Large documents may take longer to process.
  • Images must be CORS-enabled or base64 encoded.