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
..
2021-08-01 14:07:13 -03:00
2021-07-11 23:35:02 -03:00

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

  • add alias to map fs calls to pdfkit virtual file system implementation
  • 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