npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

jspdf-md-renderer

v3.0.0

Published

A jsPDF utility to render Markdown directly into formatted PDFs with custom designs.

Readme

jsPDF Markdown Renderer

A jsPDF utility to render Markdown directly into formatted PDFs with custom designs.

npm version License: MIT Downloads

Table of Contents

Installation

To install the library, you can use npm:

npm install jspdf-md-renderer

Usage

Basic Example

Here is a basic example of how to use the library to generate a PDF from Markdown content:

import { jsPDF } from 'jspdf';
import { MdTextRender } from 'jspdf-md-renderer';

const mdString = `
# Main Title

This is a brief introduction paragraph. It sets the tone for the document and introduces the main topic in a concise manner.

## Section 1: Overview

Here is a medium-length paragraph that goes into more detail about the first section. It explains the context, provides background information, and sets up the discussion for the subsections.

## Section 2: Lists and Examples

This section showcases how to create simple and nested lists.

### Simple List

- Item 1
- Item 2
- Item 3

### Nested List

1. First Level 1
   - First Level 2
     - First Level 3
2. Second Level 1
   - Second Level 2
   - Another Second Level 2
     - Nested deeper

### Mixed List Example

- Topic 1
  1. Subtopic 1.1
  2. Subtopic 1.2
- Topic 2
  - Subtopic 2.1
  - Subtopic 2.2
    1. Nested Subtopic 2.2.1
    2. Nested Subtopic 2.2.2

### Emphasis and Strong Emphasis
- *Italic* text using asterisks.
- _Italic_ text using underscores.
- **Bold** text using double asterisks.
- __Bold__ text using double underscores.
- ***Bold and Italic*** text using triple asterisks.
- ___Bold and Italic___ text using triple underscores.

`;

const generatePDF = async () => {
    const doc = new jsPDF({
        unit: 'mm',
        format: 'a4',
        orientation: 'portrait',
    });

    const options = {
        cursor: { x: 10, y: 10 },
        page: {
            format: 'a4',
            unit: 'mm',
            orientation: 'portrait',
            maxContentWidth: 190,
            maxContentHeight: 277,
            lineSpace: 1.5,
            defaultLineHeightFactor: 1.2,
            defaultFontSize: 12,
            defaultTitleFontSize: 14,
            topmargin: 10,
            xpading: 10,
            xmargin: 10,
            indent: 10,
        },
        font: {
            bold: { name: 'helvetica', style: 'bold' },
            regular: { name: 'helvetica', style: 'normal' },
            light: { name: 'helvetica', style: 'light' },
        },
        endCursorYHandler: (y) => {
            console.log('End cursor Y position:', y);
        },
    };

    await MdTextRender(doc, mdString, options);
    doc.save('example.pdf');
};

generatePDF();

API

MdTextRender

Renders parsed markdown text into a jsPDF document.

Parameters

  • doc: The jsPDF document instance.
  • text: The markdown content to render.
  • options: The render options (fonts, page margins, etc.).

MdTextParser

Parses markdown into tokens and converts to a custom parsed structure.

Parameters

  • text: The markdown content to parse.

Returns

  • Promise<ParsedElement[]>: Parsed markdown elements.

Supported Markdown Elements

The following Markdown elements are currently supported by jspdf-md-renderer:

  • Headings: #, ##, ###, etc.
  • Paragraphs
  • Lists:
    • Unordered lists: -, *, +
    • Ordered lists: 1., 2., 3., etc.
  • Horizontal Rules: ---, ***, ___
  • Text Styles:
    • Bold: **bold** or __bold__
    • Italic: *italic* or _italic_
    • Bold Italic: ***bold italic*** or ___bold italic___
  • Code Blocks (fenced and indented):
    ```js
    console.log('Hello, world!');
    ```
  • Links:
    [GitHub](https://github.com)
  • Blockquotes:
    > This is a blockquote.
  • Images:
    ![Alt text](https://example.com/image.png)
  • Inline Code:
    This is an `inline code` example.
  • Tables:
    | Header 1 | Header 2 | Header 3 |
    | -------- | -------- | -------- |
    | Row 1    | Data     | Value    |
    | Row 2    | Data     | Value    |

Examples

Output of above basic Example => Sample Generated PDF You can find more examples in the examples directory.

Contributing

Contributions are welcome! Please read the contributing guidelines first.

Support

If you find this library useful, please consider giving it a ⭐ on GitHub! It helps others find the project and motivates continued development.

License

This project is licensed under the MIT License. See the LICENSE file for details.