pdfmake README

The project's README from github.com/bpampuch/pdfmake. As one markdown file: README.md.

pdfmake Node.js CI GitHub npm

PDF document generation library for Node.js and browsers, written in pure JavaScript.

Check out the playground and examples.

Features

Installation

Install with npm:

npm install pdfmake

Quick start

Node.js

Save the following as example.js:

const pdfmake = require('pdfmake');
const Roboto = require('pdfmake/fonts/Roboto');

pdfmake.addFonts(Roboto);

const docDefinition = {
	content: ['Hello from pdfmake!']
};

pdfmake.createPdf(docDefinition).write('document.pdf').catch(console.error);

Run node example.js to create document.pdf in the current directory.

Browser

Save the following as index.html next to your node_modules directory and open it in a browser.

<!doctype html>
<meta charset="utf-8">
<script src="node_modules/pdfmake/build/pdfmake.min.js"></script>
<script src="node_modules/pdfmake/build/vfs_fonts.js"></script>

<button onclick="pdfMake.createPdf(docDefinition).download('document.pdf').catch(console.error)">Download PDF</button>
<script>
	const docDefinition = {
		content: ['Hello from pdfmake!']
	};
</script>

Documentation

See the documentation for usage and API details.

Documentation improvements are welcome in the documentation repository.

Building from source

git clone https://github.com/bpampuch/pdfmake.git
cd pdfmake
npm install
npm run build

License

MIT

Authors

pdfmake is based on PDFKit.

Thanks to all contributors.

pdfmake (bpampuch/pdfmake)

Searching Database…

What is this?pdfmake is a PDF document generation library written in pure JavaScript that works both server-side (Node.js) and client-side (browser).
Is it a framework or a library?It is a library you import into your own Node.js or browser project to generate PDFs programmatically, not a standalone app.
How do I add it to a project?Install via npm or yarn, then build from source with the provided scripts; there's also a playground to try it without installing anything.
Does it rely on other libraries internally?It depends on pdfkit for low-level PDF rendering, plus linebreak and xmldoc internally; it requires Node.js 20 or newer to build.
Where does it run?It runs on Node.js servers and directly in web browsers since it is pure JavaScript.
What layout features does it support out of the box?It supports line-wrapping, text alignment, numbered and bulleted lists, tables with column/row spans and auto/fixed/star-sized widths, multi-column newspaper-style layouts, images, vector graphics, headers/footers, page numbers, margins, custom page breaks, embedded fonts, and table of contents.
Can I set PDF metadata like author or subject?Yes, pdfmake provides helper methods for setting document metadata such as author and subject, plus methods for opening, printing, or downloading the generated PDF.
Creator
bpampuch
Size
152.6 MB
Stars
12.4K
Age
12y
Commits · 90 Days