PDF document generation library for Node.js and browsers, written in pure JavaScript.
Check out the playground and examples.
Install with npm:
npm install pdfmake
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.
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>
See the documentation for usage and API details.
Documentation improvements are welcome in the documentation repository.
git clone https://github.com/bpampuch/pdfmake.git
cd pdfmake
npm install
npm run build
MIT
pdfmake is based on PDFKit.
Thanks to all contributors.