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.
- package/README.md +35 -0
- package/js/pdfkit.browser.mjs +2418 -436
- package/js/pdfkit.browser.mjs.map +1 -1
- package/js/pdfkit.js +2460 -456
- package/js/pdfkit.js.map +1 -1
- package/js/pdfkit.node.mjs +2452 -452
- package/js/pdfkit.node.mjs.map +1 -1
- package/js/pdfkit.standalone.js +21578 -32704
- package/js/standard-fonts/Symbol.cjs +4 -3
- package/js/standard-fonts/Symbol.mjs +4 -3
- package/js/standard-fonts/ZapfDingbats.cjs +4 -3
- package/js/standard-fonts/ZapfDingbats.mjs +4 -3
- package/package.json +23 -23
- package/.yarn/install-state.gz +0 -0
- package/.yarn/releases/yarn-4.16.0.cjs +0 -944
- package/.yarnrc.yml +0 -10
- package/CHANGELOG.md +0 -192
- package/js/data/Courier-Bold.afm +0 -342
- package/js/data/Courier-BoldOblique.afm +0 -342
- package/js/data/Courier-Oblique.afm +0 -342
- package/js/data/Courier.afm +0 -342
- package/js/data/Helvetica-Bold.afm +0 -2827
- package/js/data/Helvetica-BoldOblique.afm +0 -2827
- package/js/data/Helvetica-Oblique.afm +0 -3051
- package/js/data/Helvetica.afm +0 -3051
- package/js/data/Symbol.afm +0 -213
- package/js/data/Times-Bold.afm +0 -2588
- package/js/data/Times-BoldItalic.afm +0 -2384
- package/js/data/Times-Italic.afm +0 -2667
- package/js/data/Times-Roman.afm +0 -2419
- package/js/data/ZapfDingbats.afm +0 -225
- package/js/pdfkit.browser.js +0 -7524
- package/js/pdfkit.browser.js.map +0 -1
- package/js/pdfkit.browser.old.js +0 -7517
- package/js/pdfkit.browser.old.mjs +0 -7342
- package/js/pdfkit.old.js +0 -7276
- package/jsconfig.json +0 -13
- package/rollup.config.mjs +0 -193
- package/tools/README.md +0 -124
- package/tools/afm-converter.js +0 -317
- package/tools/asset-plugin.mjs +0 -17
- package/tools/binary-plugin.mjs +0 -18
- package/tools/convert-afm-parsed.js +0 -8
- package/tools/convert-afm-runtime.js +0 -8
- package/types/jest.custom-matchers.d.ts +0 -28
- 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:
|