@mlightcad/cad-pdf-plugin 1.7.8-preview.6 → 1.8.0-preview.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 +15 -9
- package/dist/cad-pdf-plugin.js +3381 -3552
- package/dist/cad-pdf-plugin.umd.cjs +11 -11
- package/lib/AcApConvertToPdfCmd.d.ts +5 -0
- package/lib/AcApConvertToPdfCmd.d.ts.map +1 -1
- package/lib/AcApConvertToPdfCmd.js +47 -2
- package/lib/AcApConvertToPdfCmd.js.map +1 -1
- package/lib/AcApPdfConvertor.d.ts +7 -7
- package/lib/AcApPdfConvertor.d.ts.map +1 -1
- package/lib/AcApPdfConvertor.js +23 -32
- package/lib/AcApPdfConvertor.js.map +1 -1
- package/lib/AcApPdfExportOptions.d.ts +19 -26
- package/lib/AcApPdfExportOptions.d.ts.map +1 -1
- package/lib/AcApPdfExportOptions.js +5 -5
- package/lib/AcApPdfExportOptions.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +13 -11
- package/lib/AcApPdfGlyphProvider.d.ts +0 -15
- package/lib/AcApPdfGlyphProvider.d.ts.map +0 -1
- package/lib/AcApPdfGlyphProvider.js +0 -425
- package/lib/AcApPdfGlyphProvider.js.map +0 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ PDF **export** and **import** plugin for [`@mlightcad/cad-simple-viewer`](../cad
|
|
|
8
8
|
| Command | Description |
|
|
9
9
|
|---------|-------------|
|
|
10
10
|
| `-cpdf` | Export via **command-line prompts** (no dialog; AutoCAD-style `-` prefix) |
|
|
11
|
-
| `cpdf` | Same as `-cpdf` when no UI command is registered. In [`cad-
|
|
11
|
+
| `cpdf` | Same as `-cpdf` when no UI command is registered. In [`cad-editor`](../cad-editor), `cpdf` opens an **export options dialog** instead |
|
|
12
12
|
| `ipdf` | Import vector geometry from a PDF file into model space |
|
|
13
13
|
|
|
14
14
|
The plugin is designed for **lazy loading** so PDF libraries (`pdf-lib` via `@mlightcad/pdf-renderer`, `pdfjs-dist`) are only downloaded when a user runs `-cpdf` / `cpdf` or `ipdf`.
|
|
@@ -17,7 +17,8 @@ The plugin is designed for **lazy loading** so PDF libraries (`pdf-lib` via `@ml
|
|
|
17
17
|
|
|
18
18
|
- **Vector PDF export** — renders model space and each paper-space layout as PDF pages with `@mlightcad/pdf-renderer` (native AcGi PDF backend). Paper-space pages include model content shown through viewports, clipped to each viewport frame.
|
|
19
19
|
- **Busy indicator** — export shows the same conversion spinner as `chtml` so the browser stays responsive
|
|
20
|
-
- **Export options** — model-space framing (`Extents` / `Display`)
|
|
20
|
+
- **Export options** — model-space framing (`Extents` / `Display`), optional paper-space layouts, text mode (`Text` / `Vector`) and colour mode (`Color` / `Monochrome` — black content on white paper)
|
|
21
|
+
- **Shared core (1.8.0+)** — export logic lives in [`@mlightcad/cad-pdf-core`](../cad-pdf-core), which the headless [`@mlightcad/cad-pdf-exporter`](../cad-pdf-exporter) also uses so Node can export PDF without a browser ([upgrade guide](../../docs/development/upgrade-guide.md))
|
|
21
22
|
- **PDF import** — parses vector paths from the first page of a PDF (lines, polylines, Bézier curves) and appends CAD entities
|
|
22
23
|
- **Plugin API** — implements `AcApPlugin`; register once with `registerLazyPdfPlugin`
|
|
23
24
|
- **Framework-agnostic** — no Vue/React dependency; works anywhere `cad-simple-viewer` runs
|
|
@@ -30,9 +31,12 @@ pnpm add @mlightcad/cad-pdf-plugin
|
|
|
30
31
|
|
|
31
32
|
Peer dependencies:
|
|
32
33
|
|
|
34
|
+
- `@mlightcad/cad-pdf-core`
|
|
33
35
|
- `@mlightcad/cad-simple-viewer`
|
|
34
36
|
- `@mlightcad/data-model`
|
|
37
|
+
- `@mlightcad/mtext-parser`
|
|
35
38
|
- `@mlightcad/pdf-renderer`
|
|
39
|
+
- `@mlightcad/three-renderer`
|
|
36
40
|
|
|
37
41
|
Runtime dependencies (bundled with this package):
|
|
38
42
|
|
|
@@ -87,7 +91,7 @@ await AcApDocManager.instance.editor.executeCommand('-cpdf')
|
|
|
87
91
|
await AcApDocManager.instance.editor.executeCommand('ipdf')
|
|
88
92
|
```
|
|
89
93
|
|
|
90
|
-
In [`cad-
|
|
94
|
+
In [`cad-editor`](../cad-editor), use `cpdf` to open the export options dialog; `-cpdf` remains available on the command line for prompt-based export.
|
|
91
95
|
|
|
92
96
|
`cad-viewer` registers this plugin automatically via `registerLazyPlugins()` in its app bootstrap and registers the `cpdf` dialog command separately.
|
|
93
97
|
|
|
@@ -119,7 +123,9 @@ await new AcApPdfConvertor().convert(
|
|
|
119
123
|
context,
|
|
120
124
|
resolveAcApPdfExportOptions({
|
|
121
125
|
modelSpaceFit: 'extents',
|
|
122
|
-
exportLayouts: true
|
|
126
|
+
exportLayouts: true,
|
|
127
|
+
textMode: 'text',
|
|
128
|
+
colorMode: 'monochrome' // or 'color' (default)
|
|
123
129
|
})
|
|
124
130
|
)
|
|
125
131
|
|
|
@@ -132,9 +138,9 @@ await new AcApPdfImportConvertor().convert(context, buffer, 1) // page 1
|
|
|
132
138
|
|
|
133
139
|
### Export (`-cpdf` / dialog)
|
|
134
140
|
|
|
135
|
-
1. Collect options: model-space framing (`Extents` / `Display`)
|
|
141
|
+
1. Collect options: model-space framing (`Extents` / `Display`), whether to export layouts, text mode (`Text` / `Vector`) and colour mode (`Color` / `Monochrome`).
|
|
136
142
|
2. Show the application busy overlay (same animation pattern as `chtml`).
|
|
137
|
-
3. Call `@mlightcad/pdf-
|
|
143
|
+
3. Call `@mlightcad/cad-pdf-core` `acexPdfExportDatabase` (built on `@mlightcad/pdf-renderer`). With layouts enabled, model space and every paper space become one PDF page each. Monochrome paints linework and text black on white paper (solid fills become grey).
|
|
138
144
|
4. Download the resulting PDF bytes.
|
|
139
145
|
|
|
140
146
|
### Import (`ipdf`)
|
|
@@ -156,7 +162,7 @@ Import is **vector-only**; raster/scanned PDF pages produce no entities. Only th
|
|
|
156
162
|
| `AcApConvertToPdfCmd` | `-cpdf` / fallback `cpdf` command class |
|
|
157
163
|
| `AcApImportPdfCmd` | `ipdf` command class |
|
|
158
164
|
| `AcApPdfConvertor` | CAD → PDF export utility |
|
|
159
|
-
| `AcApPdfExportOptions`, `resolveAcApPdfExportOptions` | Export option types and defaults |
|
|
165
|
+
| `AcApPdfExportOptions`, `AcApPdfColorMode`, `resolveAcApPdfExportOptions` | Export option types and defaults (aliases of `@mlightcad/cad-pdf-core`) |
|
|
160
166
|
| `AcApPdfImportConvertor` | PDF → CAD entities import utility |
|
|
161
167
|
|
|
162
168
|
## Project layout
|
|
@@ -167,13 +173,13 @@ Import is **vector-only**; raster/scanned PDF pages produce no entities. Only th
|
|
|
167
173
|
| `src/AcApPdfPlugin.ts` | Plugin lifecycle (`onLoad` / `onUnload`) |
|
|
168
174
|
| `src/AcApConvertToPdfCmd.ts` | `-cpdf` command (command-line prompts) |
|
|
169
175
|
| `src/AcApImportPdfCmd.ts` | `ipdf` command |
|
|
170
|
-
| `src/AcApPdfConvertor.ts` |
|
|
176
|
+
| `src/AcApPdfConvertor.ts` | Browser export: view box, fonts, download (rendering via `cad-pdf-core`) |
|
|
171
177
|
| `src/AcApPdfExportOptions.ts` | Export option types and defaults |
|
|
172
178
|
| `src/AcApPdfImportConvertor.ts` | Import pipeline (pdf.js operator parsing) |
|
|
173
179
|
|
|
174
180
|
## Role in MLightCAD
|
|
175
181
|
|
|
176
|
-
This package extends `cad-simple-viewer` with optional PDF I/O. Export uses `@mlightcad/pdf-renderer
|
|
182
|
+
This package extends `cad-simple-viewer` with optional PDF I/O. Export uses `@mlightcad/cad-pdf-core` (on top of `@mlightcad/pdf-renderer`); import uses `pdfjs-dist`. Heavy PDF dependencies stay out of the core viewer bundle through lazy loading.
|
|
177
183
|
|
|
178
184
|
## License
|
|
179
185
|
|