pdfkit/examples/webpack/README.md
Devon Govett f238d1b107
Bump fontkit and linebreak deps (#1367)
* Bump fontkit and linebreak deps

* Bump fontkit to 2.0.0

* Bump

* Drop old node versions

* Bump testing dependencies

* Update pdfjs

* fix jest to compatibility with restructure, update fontkit, refresh snapshots

* Update CHANGELOG.md

---------

Co-authored-by: Libor M. <liborm85@gmail.com>
2024-12-16 08:36:25 +01:00

27 lines
963 B
Markdown

# pdfkit-webpack-example
Simple example of using PdfKit with webpack
### Features
- Minimal webpack 5 setup
- Automatically register binary files added to static-assets folder
- Register AFM fonts provided by pdfkit
- Shows how to load and register files lazily
### Technical details
[`webpack.config.js`](webpack.config.js)
- add alias to map `fs` calls to pdfkit virtual file system [implementation](../../lib/virtual-fs.js)
- ignore crypto package to save bundle file size
- add aliases to native node packages (buffer, stream, zlib, util, assert)
- configure `*.afm` files to be imported as text
- configure all files in `src/static-assets` folder to be imported encoded as base64
- configure all files in `src/lazy-assets` folder to be imported as URLs
- convert binary files used by linebreak and fontkit to base64
### Caveats
The strategy to register binary files and AFM fonts inlines them in source code, increasing the bundle size significantly