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

react-native-md-to-pdf

v0.1.0

Published

A powerful React Native library to convert Markdown to PDF using Expo Print. Supports custom CSS themes, Google Fonts, and HTML generation.

Readme

react-native-md-to-pdf

A powerful, customizable library to convert Markdown to PDF in React Native.

🚀 Zero-dependency markdown parser 🎨 Granular Theming (CSS-like) 🔤 Custom Fonts Support 📱 iOS & Android (with Expo Go & Bare workflow support) ⚛️ Works with Expo

Installation

npm install react-native-md-to-pdf expo-print expo-file-system
# or
yarn add react-native-md-to-pdf expo-print expo-file-system

Note: This library depends on expo-print (for PDF generation) and expo-file-system (for saving files). If you are in a bare React Native project, ensure you install these modules correctly.

Usage

Simple Example

import { useMdToPdf } from 'react-native-md-to-pdf';

export default function App() {
  const { convertToPdf } = useMdToPdf();

  const handleGenerate = async () => {
    const result = await convertToPdf('# Hello World', {
      fileName: 'my-doc',
      pageSize: 'A4',
    });
    console.log('PDF saved to:', result.filePath);
  };

  return <Button title="Generate PDF" onPress={handleGenerate} />;
}

Advanced Customization (Themes & Fonts)

The library supports rich customization using ThemeConfig and custom fonts.

const result = await convertToPdf(markdown, {
  pageSize: 'A4',
  theme: {
    // Global overrides
    fontFamily: 'Open Sans',
    background: '#ffffff',
    colors: {
      text: '#111827',
      heading: '#dc2626', // Red headings
    },

    // 🎨 Granular Element Styles (CSS-like)
    h1: { fontSize: '32px', borderBottom: '2px solid #dc2626', paddingBottom: '10px' },
    h2: { color: '#4b5563', borderBottom: '1px solid #e5e7eb' },
    code: { backgroundColor: '#1f2937', color: '#38bdf8', borderRadius: '6px' },
    img: { borderRadius: '8px', boxShadow: '0 4px 6px rgba(0,0,0,0.1)' }
  },
  // 🔤 Custom Fonts (base64)
  fonts: {
    'Open Sans': 'BASE64_FONT_DATA...', 
    'Fira Code': 'BASE64_FONT_DATA...'
  }
});

API Reference

useMdToPdf()

Hook that exposes the core functions.

  • convertToPdf(markdown, options?): Generates a PDF. Returns Promise<PdfResult>.
  • convertToHtml(markdown, theme?): Returns the generated HTML string (useful for previews).
  • isConverting: Boolean indicating if a conversion is in progress.

PdfOptions

| Property | Type | Default | Description | | :--- | :--- | :--- | :--- | | fileName | string | timestamp | Name of the output file (no extension). | | pageSize | 'A4', 'Letter', etc. | 'A4' | Standard page sizes. | | orientation | 'portrait' | 'landscape' | 'portrait' | Page orientation. | | directory | string | cache/doc | Directory to save the PDF to. | | base64 | boolean | false | If true, returns base64 data in result. | | theme | ThemeConfig | DEFAULT | Styling configuration. | | fonts | Record<string, string> | undefined | Map of font-family names to base64 font data. |

ThemeConfig

Allows overriding colors and specific element styles.

  • colors: Object with keys like text, background, heading, link, code, codeBackground, etc.
  • h1...h6: TextStyle objects for headings.
  • p, a, img, table, blockquote, code, pre: TextStyle objects for respective elements.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT