pdfkit 0.20.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +35 -0
  2. package/js/pdfkit.browser.mjs +2418 -436
  3. package/js/pdfkit.browser.mjs.map +1 -1
  4. package/js/pdfkit.js +2460 -456
  5. package/js/pdfkit.js.map +1 -1
  6. package/js/pdfkit.node.mjs +2452 -452
  7. package/js/pdfkit.node.mjs.map +1 -1
  8. package/js/pdfkit.standalone.js +21578 -32704
  9. package/js/standard-fonts/Symbol.cjs +4 -3
  10. package/js/standard-fonts/Symbol.mjs +4 -3
  11. package/js/standard-fonts/ZapfDingbats.cjs +4 -3
  12. package/js/standard-fonts/ZapfDingbats.mjs +4 -3
  13. package/package.json +23 -23
  14. package/.yarn/install-state.gz +0 -0
  15. package/.yarn/releases/yarn-4.16.0.cjs +0 -944
  16. package/.yarnrc.yml +0 -10
  17. package/CHANGELOG.md +0 -192
  18. package/js/data/Courier-Bold.afm +0 -342
  19. package/js/data/Courier-BoldOblique.afm +0 -342
  20. package/js/data/Courier-Oblique.afm +0 -342
  21. package/js/data/Courier.afm +0 -342
  22. package/js/data/Helvetica-Bold.afm +0 -2827
  23. package/js/data/Helvetica-BoldOblique.afm +0 -2827
  24. package/js/data/Helvetica-Oblique.afm +0 -3051
  25. package/js/data/Helvetica.afm +0 -3051
  26. package/js/data/Symbol.afm +0 -213
  27. package/js/data/Times-Bold.afm +0 -2588
  28. package/js/data/Times-BoldItalic.afm +0 -2384
  29. package/js/data/Times-Italic.afm +0 -2667
  30. package/js/data/Times-Roman.afm +0 -2419
  31. package/js/data/ZapfDingbats.afm +0 -225
  32. package/js/pdfkit.browser.js +0 -7524
  33. package/js/pdfkit.browser.js.map +0 -1
  34. package/js/pdfkit.browser.old.js +0 -7517
  35. package/js/pdfkit.browser.old.mjs +0 -7342
  36. package/js/pdfkit.old.js +0 -7276
  37. package/jsconfig.json +0 -13
  38. package/rollup.config.mjs +0 -193
  39. package/tools/README.md +0 -124
  40. package/tools/afm-converter.js +0 -317
  41. package/tools/asset-plugin.mjs +0 -17
  42. package/tools/binary-plugin.mjs +0 -18
  43. package/tools/convert-afm-parsed.js +0 -8
  44. package/tools/convert-afm-runtime.js +0 -8
  45. package/types/jest.custom-matchers.d.ts +0 -28
  46. package/vitest.config.js +0 -13
package/README.md CHANGED
@@ -136,6 +136,41 @@ doc.end();
136
136
  complex documents with a very small amount of code. For more, see the `demo` folder and the
137
137
  [PDFKit programming guide](http://pdfkit.org/docs/getting_started.html).
138
138
 
139
+ ## Bundling for Node
140
+
141
+ The Node build loads the metrics of the 14 standard fonts on first use from
142
+ `standard-fonts/` next to the built file, and PDF/A output reads the sRGB ICC
143
+ profile from `data/` next to it. Both are resolved relative to the built file
144
+ inside pdfkit's package directory, which a bundle that inlines pdfkit (esbuild,
145
+ rollup, webpack, the AWS CDK's `NodejsFunction`, ...) does not sit in. Pick one
146
+ of:
147
+
148
+ - Mark `pdfkit` as external in the bundler and ship `node_modules/pdfkit` next
149
+ to the bundle. File tracers such as `@vercel/nft` pick up every file pdfkit
150
+ needs.
151
+ - Copy pdfkit's `js/standard-fonts` directory next to an ESM bundle, which then
152
+ loads the fonts from there. A CommonJS bundle has no `import.meta.url` to
153
+ resolve against, so this route is not open to it.
154
+ - Register the standard fonts the document uses before creating it, the same
155
+ way as in the browser:
156
+
157
+ ```javascript
158
+ import { PDFDocument, registerStdFonts } from 'pdfkit';
159
+ import Helvetica from 'pdfkit/standard-fonts/Helvetica';
160
+
161
+ registerStdFonts(Helvetica);
162
+ const doc = new PDFDocument();
163
+ ```
164
+
165
+ Using a standard font that is neither registered nor loadable throws an
166
+ error naming the font. Fonts read from the file system or passed as data are
167
+ not affected.
168
+
169
+ PDF/A output additionally reads `data/sRGB_IEC61966_2_1.icc` relative to the
170
+ bundle's `import.meta.url`: copy pdfkit's `js/data` directory next to an ESM
171
+ bundle, or register the profile under that URL with `registerFile`. A CommonJS
172
+ bundle has no `import.meta.url` and says so when PDF/A output is requested.
173
+
139
174
  ## Browser Usage
140
175
 
141
176
  There are three ways to use PDFKit in the browser: