Client-side

To begin in browser with the default configuration, you should include two files:

<!doctype html>
<html lang='en'>
<head>
  <meta charset='utf-8'>
  <title>my first pdfmake example</title>
  <script src='build/pdfmake.min.js'></script>
  <script src='build/vfs_fonts.js'></script>
</head>
<body>
...

Library sources

cdnjs

https://cdnjs.com/libraries/pdfmake

bower (deprecated)

bower install pdfmake

npm

npm install pdfmake

Files for client-side is available here:

Using javascript frameworks:

var pdfMake = require('pdfmake/build/pdfmake.js');
var pdfFonts = require('pdfmake/build/vfs_fonts.js');
pdfMake.vfs = pdfFonts.pdfMake.vfs;

or

import pdfMake from "pdfmake/build/pdfmake";
import pdfFonts from "pdfmake/build/vfs_fonts";
pdfMake.vfs = pdfFonts.pdfMake.vfs;

TypeScript:

import * as pdfMake from "pdfmake/build/pdfmake";
import * as pdfFonts from 'pdfmake/build/vfs_fonts';

(<any>pdfMake).vfs = pdfFonts.pdfMake.vfs;

For Ionic and Angular see issue.

If a Cannot read property ‘TYPED_ARRAY_SUPPORT’ of undefined error is thrown, add this to webpack config:

exclude: [ /node_modules/, /pdfmake.js$/ ]

(see issue)

If you are using rollup, and a Cannot read property ‘pdfMake’ of undefined at vfs_fonts.js error is thrown, add this to rollup config:

moduleContext: {
  './node_modules/pdfmake/build/vfs_fonts.js': 'window',
},

Then, if console outputs a Illegal reassignment to import ‘pdfMake’, do not assign vfs manually, just import fonts like this:

import 'pdfmake/build/vfs_fonts';

Repository

Copy them directly from the build directory from the repository. Otherwise you can always build it from sources: