Getting started
Pardown converts a Markdown string into PDF bytes. This guide shows you how to install the library, create a PDF in Node.js, and resolve images relative to a Markdown file.
Prerequisites
You need a JavaScript project that uses ECMAScript modules. Pardown doesn't publish a CommonJS entry point, and the package metadata doesn't declare a minimum Node.js version.
Install the library
Install @pardown/core with your package manager. Its dependencies include the Markdown parser and PDF renderer, so you don't need to install them separately.
npm install @pardown/corepnpm add @pardown/coreyarn add @pardown/coreConvert Markdown
Pass a Markdown string to markdownToPdf. The function returns a promise that resolves to a Uint8Array containing the complete PDF.
import { writeFile } from 'node:fs/promises';
import { markdownToPdf } from '@pardown/core';
const markdown = `
# Site inspection
The inspection found **no blocking issues**.
`;
const pdf = await markdownToPdf(markdown);
await writeFile('site-inspection.pdf', pdf);Pardown returns bytes rather than writing a file, so you can also send the result in an HTTP response, store it in object storage, or create a browser Blob.
Resolve local images
Set cwd to the directory that contains your Markdown file. Pardown resolves relative image sources from this directory.
import { readFile, writeFile } from 'node:fs/promises';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { markdownToPdf } from '@pardown/core';
const markdownUrl = new URL('./reports/site-inspection.md', import.meta.url);
const markdownPath = fileURLToPath(markdownUrl);
const markdown = await readFile(markdownPath, 'utf8');
const pdf = await markdownToPdf(markdown, {
cwd: dirname(markdownPath),
});
await writeFile(new URL('./reports/site-inspection.pdf', import.meta.url), pdf);A source such as  now resolves from the reports/images directory. HTTP and HTTPS image URLs are fetched automatically.
NOTE
Local image loading uses Node.js file-system APIs. In a browser, provide a custom image loader as described in Load images in a browser.
Use the CLI instead
Install @pardown/cli globally when you want to convert Markdown without writing JavaScript.
npm install --global @pardown/cli
pardown site-inspection.mdThe command writes site-inspection.pdf beside the input file. Read the CLI reference for output paths, standard input, warnings, and exit statuses.
Next steps
Continue with the guide that matches your task:
- Save, return, or download the result in Work with PDF bytes.
- Configure image loading and cancellation in Image loading and cancellation.
- Collect recoverable warnings in Diagnostics.
- Review the exact exports in the
@pardown/coreAPI reference. - Check the formatting available in Markdown support.
- Try a document in the browser playground.