@imgly/pdf-importer 0.1.0-rc.1 → 0.1.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 +30 -0
- package/README.md +23 -4
- package/dist/browser.d.cts +11054 -0
- package/dist/browser.d.ts +10780 -26
- package/dist/browser.js +12 -12
- package/dist/node.cjs +15 -0
- package/dist/node.d.cts +11054 -0
- package/dist/node.d.ts +10780 -26
- package/dist/node.js +11 -11
- package/package.json +30 -20
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @imgly/pdf-importer
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
First public release of `@imgly/pdf-importer` — convert PDF files into
|
|
6
|
+
CE.SDK scenes using `@imgly/pdfjs-dist` (an IMG.LY fork of Mozilla
|
|
7
|
+
pdf.js, https://github.com/imgly/pdf.js).
|
|
8
|
+
|
|
9
|
+
### Pipeline
|
|
10
|
+
|
|
11
|
+
- Extract → post-process → emit pipeline: walks pdf.js operator streams (`extract/walker.mjs`), emits drawable blocks (images, vector paths, text outlines) in paint order, uses `page.getTextContent()` for editable text runs, merges adjacent same-font/size runs with horizontal overlap into multi-line paragraph blocks, and writes the IR as CE.SDK blocks.
|
|
12
|
+
- Text is always imported as full-paragraph blocks (no per-character or per-word splitting mode).
|
|
13
|
+
- PDF points are converted to inches (1pt = 1/72 inch) for CE.SDK design units.
|
|
14
|
+
- Spot color detection (CutContour, Thru-cut, etc.) for cut/fold mark handling.
|
|
15
|
+
- `addGfontsAssetLibrary` helper to register the shared `@imgly/gfonts` asset source.
|
|
16
|
+
|
|
17
|
+
### Font handling
|
|
18
|
+
|
|
19
|
+
- Font-strategy cascade with lazy vector fallback. Shipped presets: `editableFirstStrategy` (default), `exactFidelityStrategy`, `assetLibraryStrategy`. `createFontStrategy` / `createFontCascade` for custom cascades.
|
|
20
|
+
|
|
21
|
+
### Image handling
|
|
22
|
+
|
|
23
|
+
- Image-modulated luminosity SMask support (per-pixel alpha compositing of soft masks).
|
|
24
|
+
- PDF fill rule (`f`/`F` vs `f*`/`B*`) is forwarded to the `vector_path` shape.
|
|
25
|
+
- Skia 9-patch tiling-pattern decomposition is accepted as-is.
|
|
26
|
+
|
|
27
|
+
### Robustness
|
|
28
|
+
|
|
29
|
+
- 180°-rotated text runs are no longer dropped during text pickup.
|
|
30
|
+
- Tiling-pattern bitmaps and pdf.js `objs` cleanup race conditions are handled.
|
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
|
|