@imgly/pdf-importer 0.1.0-rc.2 → 0.2.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/CHANGELOG.md +55 -0
- package/LICENSE.md +137 -650
- package/README.md +23 -4
- package/dist/browser.d.cts +854 -0
- package/dist/browser.d.ts +580 -26
- package/dist/browser.js +13 -12
- package/dist/node.cjs +16 -0
- package/dist/node.d.cts +854 -0
- package/dist/node.d.ts +580 -26
- package/dist/node.js +13 -12
- package/package.json +25 -24
package/README.md
CHANGED
|
@@ -110,6 +110,25 @@ const sceneString = await engine.scene.saveToString();
|
|
|
110
110
|
|
|
111
111
|
When using `addGfontsAssetLibrary()` (the default font resolver), the resulting scene string will contain Google CDN URLs for fonts. If you need fonts hosted on your own infrastructure, configure a custom font resolver instead of using the default Google Fonts integration.
|
|
112
112
|
|
|
113
|
+
## Font Strategies
|
|
114
|
+
|
|
115
|
+
The importer ships with three font-handling presets that trade editability against visual fidelity. Pick one via `PDFParser.fromFile(engine, blob, { fontStrategy })`, or compose your own with `createFontStrategy` / `createFontCascade`.
|
|
116
|
+
|
|
117
|
+
| Preset | Behavior | When to use |
|
|
118
|
+
|---|---|---|
|
|
119
|
+
| `editableFirstStrategy` *(default)* | perfect-match → PDF-embedded subset bytes → any-match substitution | General-purpose import. Prefers asset-library typefaces for editability, falls back to the PDF's embedded subset for fidelity, substitutes when neither is available. |
|
|
120
|
+
| `exactFidelityStrategy` | perfect-match → PDF-embedded subset bytes | Print finalization. Never substitutes; falls through to vector outline when no matching typeface or embedded font is available. |
|
|
121
|
+
| `assetLibraryStrategy` | perfect-match → any-match substitution | Brand-locked tools. Skips the embedded-subset stage so only asset-library typefaces are used; non-matching fonts go through substitution or vector outline. |
|
|
122
|
+
|
|
123
|
+
```js
|
|
124
|
+
import { PDFParser, exactFidelityStrategy } from "@imgly/pdf-importer";
|
|
125
|
+
|
|
126
|
+
const parser = await PDFParser.fromFile(engine, blob, {
|
|
127
|
+
fontStrategy: exactFidelityStrategy,
|
|
128
|
+
});
|
|
129
|
+
await parser.parse();
|
|
130
|
+
```
|
|
131
|
+
|
|
113
132
|
## NodeJS Quick-Start Example
|
|
114
133
|
|
|
115
134
|
> **Prerequisite — emoji handling.** Two CE.SDK settings need attention when
|
|
@@ -198,7 +217,7 @@ The PDF importer has some limitations and unsupported features that you should b
|
|
|
198
217
|
|
|
199
218
|
2. **Font Support**
|
|
200
219
|
|
|
201
|
-
-
|
|
220
|
+
- Fonts not available as a typeface asset source fall back through the configured `fontStrategy` (see [Font Strategies](#font-strategies) above): embedded subset bytes when present, then resolver substitution, then a vector-outline rendering. The default strategy substitutes; configure `exactFidelityStrategy` to disable substitution.
|
|
202
221
|
|
|
203
222
|
3. **Complex Vector Paths**
|
|
204
223
|
|
|
@@ -214,11 +233,11 @@ The PDF importer has some limitations and unsupported features that you should b
|
|
|
214
233
|
|
|
215
234
|
6. **Image SMask Compositing**
|
|
216
235
|
|
|
217
|
-
-
|
|
236
|
+
- Per-pixel soft masks (image-modulated luminosity SMasks) are supported and composited into the image as an RGBA PNG. As a consequence, JPEG images carrying an SMask lose the JPEG pass-through optimization — they are decoded and re-encoded as PNG, which increases file size.
|
|
218
237
|
|
|
219
|
-
##
|
|
238
|
+
## Changelog
|
|
220
239
|
|
|
221
|
-
See [
|
|
240
|
+
See [CHANGELOG.md](./CHANGELOG.md) for release notes.
|
|
222
241
|
|
|
223
242
|
## License
|
|
224
243
|
|