@mlightcad/cad-pdf-plugin 1.8.0-preview.3 → 1.8.0-preview.4
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/LICENSE +21 -21
- package/README.md +280 -186
- package/dist/cad-pdf-plugin-register.js +29 -11
- package/dist/cad-pdf-plugin-register.umd.cjs +1 -1
- package/dist/cad-pdf-plugin.js +17568 -8428
- package/dist/cad-pdf-plugin.umd.cjs +847 -13
- package/lib/AcApConvertToPdfCmd.d.ts.map +1 -1
- package/lib/AcApConvertToPdfCmd.js +14 -3
- package/lib/AcApConvertToPdfCmd.js.map +1 -1
- package/lib/AcApImportPdfCmd.d.ts +5 -3
- package/lib/AcApImportPdfCmd.d.ts.map +1 -1
- package/lib/AcApImportPdfCmd.js +5 -3
- package/lib/AcApImportPdfCmd.js.map +1 -1
- package/lib/AcApImportPdfPromptCmd.d.ts +16 -0
- package/lib/AcApImportPdfPromptCmd.d.ts.map +1 -0
- package/lib/AcApImportPdfPromptCmd.js +89 -0
- package/lib/AcApImportPdfPromptCmd.js.map +1 -0
- package/lib/AcApPdfBlockCmd.d.ts +15 -0
- package/lib/AcApPdfBlockCmd.d.ts.map +1 -0
- package/lib/AcApPdfBlockCmd.js +75 -0
- package/lib/AcApPdfBlockCmd.js.map +1 -0
- package/lib/AcApPdfDimCmd.d.ts +20 -0
- package/lib/AcApPdfDimCmd.d.ts.map +1 -0
- package/lib/AcApPdfDimCmd.js +413 -0
- package/lib/AcApPdfDimCmd.js.map +1 -0
- package/lib/AcApPdfDimSession.d.ts +82 -0
- package/lib/AcApPdfDimSession.d.ts.map +1 -0
- package/lib/AcApPdfDimSession.js +252 -0
- package/lib/AcApPdfDimSession.js.map +1 -0
- package/lib/AcApPdfFontResolver.d.ts.map +1 -1
- package/lib/AcApPdfFontResolver.js +2 -5
- package/lib/AcApPdfFontResolver.js.map +1 -1
- package/lib/AcApPdfHatchCmd.d.ts +33 -0
- package/lib/AcApPdfHatchCmd.d.ts.map +1 -0
- package/lib/AcApPdfHatchCmd.js +411 -0
- package/lib/AcApPdfHatchCmd.js.map +1 -0
- package/lib/AcApPdfHatchSession.d.ts +122 -0
- package/lib/AcApPdfHatchSession.d.ts.map +1 -0
- package/lib/AcApPdfHatchSession.js +357 -0
- package/lib/AcApPdfHatchSession.js.map +1 -0
- package/lib/AcApPdfImportConvertor.d.ts +47 -5
- package/lib/AcApPdfImportConvertor.d.ts.map +1 -1
- package/lib/AcApPdfImportConvertor.js +999 -108
- package/lib/AcApPdfImportConvertor.js.map +1 -1
- package/lib/AcApPdfImportOptions.d.ts +116 -0
- package/lib/AcApPdfImportOptions.d.ts.map +1 -0
- package/lib/AcApPdfImportOptions.js +31 -0
- package/lib/AcApPdfImportOptions.js.map +1 -0
- package/lib/AcApPdfImportResources.d.ts +41 -0
- package/lib/AcApPdfImportResources.d.ts.map +1 -0
- package/lib/AcApPdfImportResources.js +52 -0
- package/lib/AcApPdfImportResources.js.map +1 -0
- package/lib/AcApPdfPlugin.d.ts +3 -3
- package/lib/AcApPdfPlugin.d.ts.map +1 -1
- package/lib/AcApPdfPlugin.js +23 -5
- package/lib/AcApPdfPlugin.js.map +1 -1
- package/lib/AcApPdfScaleCmd.d.ts +22 -0
- package/lib/AcApPdfScaleCmd.d.ts.map +1 -0
- package/lib/AcApPdfScaleCmd.js +185 -0
- package/lib/AcApPdfScaleCmd.js.map +1 -0
- package/lib/AcApPdfTextCmd.d.ts +73 -0
- package/lib/AcApPdfTextCmd.d.ts.map +1 -0
- package/lib/AcApPdfTextCmd.js +777 -0
- package/lib/AcApPdfTextCmd.js.map +1 -0
- package/lib/AcApPdfTextSession.d.ts +232 -0
- package/lib/AcApPdfTextSession.d.ts.map +1 -0
- package/lib/AcApPdfTextSession.js +826 -0
- package/lib/AcApPdfTextSession.js.map +1 -0
- package/lib/acapPdfI18n.d.ts +11 -0
- package/lib/acapPdfI18n.d.ts.map +1 -0
- package/lib/acapPdfI18n.js +57 -0
- package/lib/acapPdfI18n.js.map +1 -0
- package/lib/acapPdfPrompts.d.ts +12 -0
- package/lib/acapPdfPrompts.d.ts.map +1 -0
- package/lib/acapPdfPrompts.js +100 -0
- package/lib/acapPdfPrompts.js.map +1 -0
- package/lib/index.d.ts +28 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +28 -0
- package/lib/index.js.map +1 -1
- package/lib/pdfDeprecatedMatching.d.ts +27 -0
- package/lib/pdfDeprecatedMatching.d.ts.map +1 -0
- package/lib/pdfDeprecatedMatching.js +20 -0
- package/lib/pdfDeprecatedMatching.js.map +1 -0
- package/lib/pdfDimStrokeTexts.d.ts +55 -0
- package/lib/pdfDimStrokeTexts.d.ts.map +1 -0
- package/lib/pdfDimStrokeTexts.js +274 -0
- package/lib/pdfDimStrokeTexts.js.map +1 -0
- package/lib/pdfDimensionConvert.d.ts +80 -0
- package/lib/pdfDimensionConvert.d.ts.map +1 -0
- package/lib/pdfDimensionConvert.js +566 -0
- package/lib/pdfDimensionConvert.js.map +1 -0
- package/lib/pdfEntityStrokes.d.ts +13 -0
- package/lib/pdfEntityStrokes.d.ts.map +1 -0
- package/lib/pdfEntityStrokes.js +86 -0
- package/lib/pdfEntityStrokes.js.map +1 -0
- package/lib/pdfHatchRecover.d.ts +57 -0
- package/lib/pdfHatchRecover.d.ts.map +1 -0
- package/lib/pdfHatchRecover.js +315 -0
- package/lib/pdfHatchRecover.js.map +1 -0
- package/lib/pdfImportAppend.d.ts +24 -0
- package/lib/pdfImportAppend.d.ts.map +1 -0
- package/lib/pdfImportAppend.js +35 -0
- package/lib/pdfImportAppend.js.map +1 -0
- package/lib/pdfImportEntities.d.ts +63 -0
- package/lib/pdfImportEntities.d.ts.map +1 -0
- package/lib/pdfImportEntities.js +307 -0
- package/lib/pdfImportEntities.js.map +1 -0
- package/lib/pdfImportImages.d.ts +90 -0
- package/lib/pdfImportImages.d.ts.map +1 -0
- package/lib/pdfImportImages.js +294 -0
- package/lib/pdfImportImages.js.map +1 -0
- package/lib/pdfImportShapes.d.ts +63 -0
- package/lib/pdfImportShapes.d.ts.map +1 -0
- package/lib/pdfImportShapes.js +248 -0
- package/lib/pdfImportShapes.js.map +1 -0
- package/lib/pdfVectorImport.d.ts +218 -5
- package/lib/pdfVectorImport.d.ts.map +1 -1
- package/lib/pdfVectorImport.js +566 -98
- package/lib/pdfVectorImport.js.map +1 -1
- package/lib/recognition/pdfCurveRecognition.d.ts +91 -0
- package/lib/recognition/pdfCurveRecognition.d.ts.map +1 -0
- package/lib/recognition/pdfCurveRecognition.js +506 -0
- package/lib/recognition/pdfCurveRecognition.js.map +1 -0
- package/lib/recognition/pdfDimDigitRecognition.d.ts +18 -0
- package/lib/recognition/pdfDimDigitRecognition.d.ts.map +1 -0
- package/lib/recognition/pdfDimDigitRecognition.js +520 -0
- package/lib/recognition/pdfDimDigitRecognition.js.map +1 -0
- package/lib/recognition/pdfDimensionPattern.d.ts +173 -0
- package/lib/recognition/pdfDimensionPattern.d.ts.map +1 -0
- package/lib/recognition/pdfDimensionPattern.js +1023 -0
- package/lib/recognition/pdfDimensionPattern.js.map +1 -0
- package/lib/recognition/pdfFormBlocks.d.ts +58 -0
- package/lib/recognition/pdfFormBlocks.d.ts.map +1 -0
- package/lib/recognition/pdfFormBlocks.js +260 -0
- package/lib/recognition/pdfFormBlocks.js.map +1 -0
- package/lib/recognition/pdfGlyphClustering.d.ts +81 -0
- package/lib/recognition/pdfGlyphClustering.d.ts.map +1 -0
- package/lib/recognition/pdfGlyphClustering.js +1005 -0
- package/lib/recognition/pdfGlyphClustering.js.map +1 -0
- package/lib/recognition/pdfGlyphDictionary.d.ts +49 -0
- package/lib/recognition/pdfGlyphDictionary.d.ts.map +1 -0
- package/lib/recognition/pdfGlyphDictionary.js +188 -0
- package/lib/recognition/pdfGlyphDictionary.js.map +1 -0
- package/lib/recognition/pdfHatchFaces.d.ts +84 -0
- package/lib/recognition/pdfHatchFaces.d.ts.map +1 -0
- package/lib/recognition/pdfHatchFaces.js +1285 -0
- package/lib/recognition/pdfHatchFaces.js.map +1 -0
- package/lib/recognition/pdfHatchRecognition.d.ts +222 -0
- package/lib/recognition/pdfHatchRecognition.d.ts.map +1 -0
- package/lib/recognition/pdfHatchRecognition.js +3781 -0
- package/lib/recognition/pdfHatchRecognition.js.map +1 -0
- package/lib/recognition/pdfRecGeometry.d.ts +67 -0
- package/lib/recognition/pdfRecGeometry.d.ts.map +1 -0
- package/lib/recognition/pdfRecGeometry.js +365 -0
- package/lib/recognition/pdfRecGeometry.js.map +1 -0
- package/lib/recognition/pdfTextFontKind.d.ts +16 -0
- package/lib/recognition/pdfTextFontKind.d.ts.map +1 -0
- package/lib/recognition/pdfTextFontKind.js +51 -0
- package/lib/recognition/pdfTextFontKind.js.map +1 -0
- package/lib/recognition/pdfTextMerge.d.ts +71 -0
- package/lib/recognition/pdfTextMerge.d.ts.map +1 -0
- package/lib/recognition/pdfTextMerge.js +382 -0
- package/lib/recognition/pdfTextMerge.js.map +1 -0
- package/lib/recognition/pdfTextRunMerge.d.ts +28 -0
- package/lib/recognition/pdfTextRunMerge.d.ts.map +1 -0
- package/lib/recognition/pdfTextRunMerge.js +90 -0
- package/lib/recognition/pdfTextRunMerge.js.map +1 -0
- package/lib/register.d.ts +8 -2
- package/lib/register.d.ts.map +1 -1
- package/lib/register.js +29 -4
- package/lib/register.js.map +1 -1
- package/lib/ui/AcUiPdfDimPanel.d.ts +55 -0
- package/lib/ui/AcUiPdfDimPanel.d.ts.map +1 -0
- package/lib/ui/AcUiPdfDimPanel.js +347 -0
- package/lib/ui/AcUiPdfDimPanel.js.map +1 -0
- package/lib/ui/AcUiPdfHatchPanel.d.ts +57 -0
- package/lib/ui/AcUiPdfHatchPanel.d.ts.map +1 -0
- package/lib/ui/AcUiPdfHatchPanel.js +420 -0
- package/lib/ui/AcUiPdfHatchPanel.js.map +1 -0
- package/lib/ui/AcUiPdfImportDialog.d.ts +120 -0
- package/lib/ui/AcUiPdfImportDialog.d.ts.map +1 -0
- package/lib/ui/AcUiPdfImportDialog.js +673 -0
- package/lib/ui/AcUiPdfImportDialog.js.map +1 -0
- package/lib/ui/AcUiPdfTextPanel.d.ts +95 -0
- package/lib/ui/AcUiPdfTextPanel.d.ts.map +1 -0
- package/lib/ui/AcUiPdfTextPanel.js +775 -0
- package/lib/ui/AcUiPdfTextPanel.js.map +1 -0
- package/package.json +11 -11
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 mlightcad
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mlightcad
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,186 +1,280 @@
|
|
|
1
|
-
# @mlightcad/cad-pdf-plugin
|
|
2
|
-
|
|
3
|
-
[](https://opensource.org/licenses/MIT)
|
|
4
|
-
[](https://www.npmjs.com/package/@mlightcad/cad-pdf-plugin)
|
|
5
|
-
|
|
6
|
-
PDF **export** and **import** plugin for [`@mlightcad/cad-simple-viewer`](../cad-simple-viewer). Registers system commands:
|
|
7
|
-
|
|
8
|
-
| Command | Description |
|
|
9
|
-
|---------|-------------|
|
|
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-editor`](../cad-editor), `cpdf` opens an **export options dialog** instead |
|
|
12
|
-
| `
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
##
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
1
|
+
# @mlightcad/cad-pdf-plugin
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://www.npmjs.com/package/@mlightcad/cad-pdf-plugin)
|
|
5
|
+
|
|
6
|
+
PDF **export** and **import** plugin for [`@mlightcad/cad-simple-viewer`](../cad-simple-viewer). Registers system commands:
|
|
7
|
+
|
|
8
|
+
| Command | Description |
|
|
9
|
+
|---------|-------------|
|
|
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-editor`](../cad-editor), `cpdf` opens an **export options dialog** instead |
|
|
12
|
+
| `pdfimport` | Import vector geometry from a PDF file into model space through the Import PDF dialog, recovering circles, arcs, ellipses and splines |
|
|
13
|
+
| `-pdfimport` | Same import with command-line prompts (page, insertion point, `Scale`, `Mode`) instead of the dialog |
|
|
14
|
+
| `pdfscale` | Calibrate imported PDF geometry: pick two points of a known distance and type its real length |
|
|
15
|
+
| `pdftext` | Convert exploded text (SHX line text, outlined fonts) back into `AcDbText`, semi-automatically |
|
|
16
|
+
| `pdfblock` | Turn repeated geometry back into a block: select one instance, every rotated / mirrored copy is found and replaced |
|
|
17
|
+
| `pdfdim` | Turn exploded dimensions (arrows or ticks, lines, extension lines, texts — including stroke digits) back into linear, radius, diameter and angular dimensions via a review palette |
|
|
18
|
+
|
|
19
|
+
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 `pdfimport`.
|
|
20
|
+
|
|
21
|
+
## Key features
|
|
22
|
+
|
|
23
|
+
- **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.
|
|
24
|
+
- **Busy indicator** — export shows the same conversion spinner as `chtml` so the browser stays responsive
|
|
25
|
+
- **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)
|
|
26
|
+
- **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))
|
|
27
|
+
- **PDF import** — parses vector paths from a chosen PDF page and appends CAD entities. Bézier chains are rebuilt as true `AcDbCircle` / `AcDbArc` / `AcDbEllipse`, mixed line–arc outlines as bulged `AcDbPolyline`, free-form curves as exact `AcDbSpline`, and arcs a producer already flattened into short lines are refitted. Stroke widths become line weights, dashed strokes get matching `PDF_DASH_*` linetypes, PDF fonts become `PDF_<family>` text styles, filled areas become solid hatches in paint order (`fillHatches`), pattern hatches that the PDF holds as short lines are rebuilt as `AcDbHatch` with their `acadiso.pat` pattern, scale and angle (`recognizeHatches`, kept only when re-drawing reproduces the lines), and exact duplicate outlines are dropped
|
|
28
|
+
- **Scale calibration** — `pdfscale` rescales imported geometry from one known distance, since printed PDFs are rarely 1:1. When the selection holds exploded dimensions, the scale their texts imply pre-fills the real length
|
|
29
|
+
- **Block recovery** — `pdfimport` turns Form XObjects painted two or more times with identical content into a block definition with one reference per paint (rotation, mirroring and scale come from each paint's form matrix). `pdfblock` handles PDFs that draw repeated symbols inline: select one instance, pick a base point and name, and every copy under rotation and mirroring (optionally scaling) is highlighted for confirmation and replaced by a block reference
|
|
30
|
+
- **Dimension recovery** — `pdfdim` recognizes linear (any angle, inside or outside arrows, architectural ticks, chained), radius, diameter and angular dimensions in a selected area, including value text still drawn as strokes (grid template matcher, no LLM). A review palette lets you edit values, pick or create a dim style (shared style preview), then Apply; Cancel leaves the drawing unchanged. It infers the drawing scale from the texts and pins paper sizes via entity overrides on the chosen style (existing styles are left unchanged in the table; `PDF_DIM` / newly created styles get the recovered metrics written in) so a large inherited DIMSCALE cannot hide extensions, and a 1:100 drawing keeps its real values
|
|
31
|
+
- **Text recovery** — real PDF text runs that continue one line are merged into one `AcDbText`. `pdftext` turns exploded text strokes back into text: it clusters strokes into lines (position, height, rotation), reads lines made of known glyph shapes from its glyph dictionary, and, with an OCR recognizer registered in `AcApTextRecognitionService` (`@mlightcad/cad-llm-plugin` registers one that uses the configured vision model), sends all other lines at once via `recognizeBatch` and converts the whole selection in one edit. Only lines nothing could read are prompted; typed glyph shapes are learned.
|
|
32
|
+
- **Plugin API** — implements `AcApPlugin`; register once with `registerLazyPdfPlugin`
|
|
33
|
+
- **Framework-agnostic** — no Vue/React dependency; works anywhere `cad-simple-viewer` runs
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pnpm add @mlightcad/cad-pdf-plugin
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Peer dependencies:
|
|
42
|
+
|
|
43
|
+
- `@mlightcad/cad-pdf-core`
|
|
44
|
+
- `@mlightcad/cad-simple-viewer`
|
|
45
|
+
- `@mlightcad/data-model`
|
|
46
|
+
- `@mlightcad/mtext-parser`
|
|
47
|
+
- `@mlightcad/pdf-renderer`
|
|
48
|
+
- `@mlightcad/three-renderer`
|
|
49
|
+
|
|
50
|
+
Runtime dependencies (bundled with this package):
|
|
51
|
+
|
|
52
|
+
- `pdfjs-dist` (import only)
|
|
53
|
+
|
|
54
|
+
## Build
|
|
55
|
+
|
|
56
|
+
Produces `dist/index.js` (main library) and `dist/register.js` (lazy-registration entry).
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pnpm --filter @mlightcad/cad-pdf-plugin build
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
### Lazy registration (recommended)
|
|
65
|
+
|
|
66
|
+
Register the plugin with the document manager's plugin manager. Import from the `/register` subpath so only the registration stub enters your initial bundle; the main plugin chunk loads on first use of `-cpdf`, `cpdf`, or `pdfimport`:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { AcApDocManager } from '@mlightcad/cad-simple-viewer'
|
|
70
|
+
import { registerLazyPdfPlugin } from '@mlightcad/cad-pdf-plugin/register'
|
|
71
|
+
|
|
72
|
+
registerLazyPdfPlugin(AcApDocManager.instance.pluginManager)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Do **not** import `registerLazyPdfPlugin` from the package root in application code — that resolves to the full library build and defeats lazy loading.
|
|
76
|
+
|
|
77
|
+
Equivalent manual registration:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import {
|
|
81
|
+
createPdfPlugin,
|
|
82
|
+
PDF_PLUGIN_NAME,
|
|
83
|
+
PDF_PLUGIN_TRIGGERS
|
|
84
|
+
} from '@mlightcad/cad-pdf-plugin'
|
|
85
|
+
|
|
86
|
+
AcApDocManager.instance.pluginManager.registerLazyPlugin({
|
|
87
|
+
name: PDF_PLUGIN_NAME,
|
|
88
|
+
triggers: [...PDF_PLUGIN_TRIGGERS],
|
|
89
|
+
loader: createPdfPlugin
|
|
90
|
+
})
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
After registration, users (or your UI) invoke commands through the editor:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
// Export current drawing to PDF (command-line prompts)
|
|
97
|
+
await AcApDocManager.instance.editor.executeCommand('-cpdf')
|
|
98
|
+
|
|
99
|
+
// Open the file picker and the Import PDF dialog, then import PDF vectors
|
|
100
|
+
await AcApDocManager.instance.editor.executeCommand('pdfimport')
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
In [`cad-editor`](../cad-editor), use `cpdf` to open the export options dialog; `-cpdf` remains available on the command line for prompt-based export.
|
|
104
|
+
|
|
105
|
+
`cad-viewer` registers this plugin automatically via `registerLazyPlugins()` in its app bootstrap and registers the `cpdf` dialog command separately.
|
|
106
|
+
|
|
107
|
+
### Eager registration
|
|
108
|
+
|
|
109
|
+
If you prefer loading PDF support up front:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { AcApPdfPlugin } from '@mlightcad/cad-pdf-plugin'
|
|
113
|
+
|
|
114
|
+
await AcApDocManager.instance.pluginManager.loadPlugin(new AcApPdfPlugin())
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Programmatic convertors
|
|
118
|
+
|
|
119
|
+
You can bypass the command layer and call the convertors directly:
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import { AcApContext } from '@mlightcad/cad-simple-viewer'
|
|
123
|
+
import {
|
|
124
|
+
AcApPdfConvertor,
|
|
125
|
+
AcApPdfImportConvertor,
|
|
126
|
+
resolveAcApPdfExportOptions
|
|
127
|
+
} from '@mlightcad/cad-pdf-plugin'
|
|
128
|
+
|
|
129
|
+
// Export
|
|
130
|
+
const context: AcApContext = /* active context */
|
|
131
|
+
await new AcApPdfConvertor().convert(
|
|
132
|
+
context,
|
|
133
|
+
resolveAcApPdfExportOptions({
|
|
134
|
+
modelSpaceFit: 'extents',
|
|
135
|
+
exportLayouts: true,
|
|
136
|
+
textMode: 'text',
|
|
137
|
+
colorMode: 'monochrome' // or 'color' (default)
|
|
138
|
+
})
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
// Import from bytes
|
|
142
|
+
const buffer: ArrayBuffer = /* PDF file */
|
|
143
|
+
await new AcApPdfImportConvertor().convert(context, buffer, 1) // page 1
|
|
144
|
+
|
|
145
|
+
// ...or with full options
|
|
146
|
+
await new AcApPdfImportConvertor().convert(context, buffer, {
|
|
147
|
+
pageNumber: 2,
|
|
148
|
+
insertionPoint: { x: 1000, y: 0 },
|
|
149
|
+
scale: 100, // drawing printed at 1:100
|
|
150
|
+
mode: 'recover', // default; 'visual' keeps the PDF look (see below)
|
|
151
|
+
recognizeCurves: true, // recover mode default; false = flatten curves
|
|
152
|
+
curveRecognition: { tolerance: 0.01, splines: true },
|
|
153
|
+
lineWeights: true,
|
|
154
|
+
removeDuplicates: true,
|
|
155
|
+
dashLinetypes: true, // PDF_DASH_* linetypes for dashed strokes
|
|
156
|
+
textStyles: true, // PDF_<family> text styles
|
|
157
|
+
fillHatches: true, // false: filled areas import as outlines only
|
|
158
|
+
recognizeHatches: true, // rebuild pattern hatches from their strokes
|
|
159
|
+
fitTextWidth: true, // stretch/squeeze text to its PDF width
|
|
160
|
+
images: true // raster images become AcDbRasterImage (PDF_IMAGE_n.png)
|
|
161
|
+
})
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
`mode` picks the defaults of the reconstruction options. `'recover'` turns on `recognizeCurves`, `removeDuplicates`, `mergeTextRuns`, `formBlocks` and `textStyles` to rebuild the source drawing. `'visual'` turns them off, so every path becomes a line or flattened polyline and every text run its own `AcDbText`, keeping the page exactly as painted (the behaviour before curve recovery). Line weights and dash linetypes stay on in both modes, and any option passed explicitly overrides the mode.
|
|
165
|
+
|
|
166
|
+
The pure recognition step is also exported: `recognizePdfCurves(segments)` turns the exact segments of one `PdfImportedSubpath` into `PdfRecognizedShape`s, and `buildPdfImportShapes(content, options)` runs it over a whole page with placement and de-duplication.
|
|
167
|
+
|
|
168
|
+
## How it works
|
|
169
|
+
|
|
170
|
+
### Export (`-cpdf` / dialog)
|
|
171
|
+
|
|
172
|
+
1. Collect options: model-space framing (`Extents` / `Display`), whether to export layouts, text mode (`Text` / `Vector`) and colour mode (`Color` / `Monochrome`).
|
|
173
|
+
2. Show the application busy overlay (same animation pattern as `chtml`).
|
|
174
|
+
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).
|
|
175
|
+
4. Download the resulting PDF bytes.
|
|
176
|
+
|
|
177
|
+
### Block recovery (`pdfblock`)
|
|
178
|
+
|
|
179
|
+
1. Select one instance. Lines, arcs, circles, polylines, ellipses, splines and text take part; other entity types are left alone.
|
|
180
|
+
2. Pick the base point. The `Scale` keyword toggles matching scaled copies; it is off by default.
|
|
181
|
+
3. Enter the block name. A free `PDF_BLOCK_n` name is pre-filled.
|
|
182
|
+
4. `recognition/pdfShapeMatching.ts` takes two anchor shapes: the largest one, and the one farthest from it. Each candidate pair of anchors fixes a similarity transform, and a copy counts only if every template shape lands on a free shape of the same kind, size and point set.
|
|
183
|
+
5. All copies are highlighted. Choose `Yes` (replace all), `No` (only the selection becomes a block) or `Review` (Yes / No / All / Exit per copy).
|
|
184
|
+
|
|
185
|
+
### Dimension recovery (`pdfdim`)
|
|
186
|
+
|
|
187
|
+
1. Select the area; lines, closed triangles, circles, arcs and texts take part. Exploded stroke text (before `pdftext`) is included: the glyph dictionary and a built-in digit/symbol template matcher read it locally — no LLM. When strokes still cannot be read, linear dimensions fall back to the measured length.
|
|
188
|
+
2. `recognition/pdfDimensionPattern.ts` finds the parts:
|
|
189
|
+
- **Arrowheads**: slender closed triangles. The tip is the sharpest corner, and the direction runs from the base midpoint to the tip.
|
|
190
|
+
- **Ticks**: short oblique lines at the ends of a longer line.
|
|
191
|
+
- **Linear dimensions**: two terminators on a common axis pointing apart or together, plus a numeric text beside them. Pairs are taken shortest first, so chained dimensions stay separate. Perpendicular lines through the tips are extension lines and give the definition points; chained dimensions may share them.
|
|
192
|
+
- **Radius and diameter**: an arrow whose tip touches a circle and points along its radius, plus an `R…` or `Ø…` text.
|
|
193
|
+
- **Angular**: an arc with an arrow at each end pointing along it, a value text near its middle, and radial extension lines. These become `AcDb3PointAngularDimension`; angles are compared without DIMLFAC, and a `°` counts as a plain number.
|
|
194
|
+
3. The most common text / measured-length ratio among linear dimensions is the drawing scale. It is snapped to 1, 2, 2.5 or 5 × 10ⁿ when within 1 %. Stroke misreadings such as a run of `1`s are replaced by the measured length when they disagree with that scale.
|
|
195
|
+
4. A palette review opens (like `pdftext` / `pdfhatch`): edit each value, include or skip rows, pick an existing dim style or create a new one, then Apply. Without a DOM, every dimension found is converted directly.
|
|
196
|
+
5. The chosen style is created or updated when it is `PDF_DIM` or brand-new. It starts from the current style, then takes the measured text height, arrow size and extension, forces both extension lines on, sets arrow fit from inside/outside tips, and DIMLFAC = scale; ticks set `_ArchTick`. Other existing styles are left unchanged.
|
|
197
|
+
6. Each accepted dimension becomes `AcDbRotatedDimension`, `AcDbRadialDimension` or `AcDbDiametricDimension`. Texts that are not plain numbers, or that disagree with measurement × scale, are kept as text overrides. The source shapes are erased.
|
|
198
|
+
|
|
199
|
+
### Text recovery (`pdftext`)
|
|
200
|
+
|
|
201
|
+
1. Select the strokes; a window around the text is enough. Strokes much larger than the text (frames, table lines) are ignored.
|
|
202
|
+
2. Strokes within a word gap form phrases. Each phrase gets its baseline direction from the minimum-height oriented bounding box, then splits into rows and lines (`recognition/pdfGlyphClustering.ts`). The cap height and baseline ignore descenders.
|
|
203
|
+
3. Lines whose glyphs are all in the session's glyph dictionary (`recognition/pdfGlyphDictionary.ts`) are read from it. All other lines are rendered to images and sent to OCR in one `AcApTextRecognitionService.recognizeBatch` call (the LLM recognizer packs up to 20 images per request). Recognizer errors are shown to the user once per run.
|
|
204
|
+
4. Everything read is converted in one append and one erase. Only lines still unread are highlighted for the user to type; empty skips, Esc stops and keeps what was converted. The run is one undo step.
|
|
205
|
+
5. Typed text whose character count matches the glyph boxes teaches the dictionary: each glyph's normalized, quantized stroke geometry maps to its character. The 5000 most recently confirmed shapes are kept in `localStorage`, so later sessions and other drawings with the same font benefit.
|
|
206
|
+
|
|
207
|
+
### Import (`pdfimport`)
|
|
208
|
+
|
|
209
|
+
1. Show a native file picker (`.pdf`).
|
|
210
|
+
2. Open the Import PDF dialog (`AcUiPdfImportDialog`, framework-free, built on `AcUiDialog`): file name with Browse, page number with a page preview or thumbnail grid and the page size, insertion point X/Y or "Specify insertion point on-screen", scale, and import mode (`Recover` rebuilds the drawing, default; `Visual` keeps the PDF look). Location, scale and mode are remembered for the next `pdfimport`. With the on-screen option, OK is followed by one insertion point prompt (Enter accepts the origin). `-pdfimport` skips the dialog and prompts for the page (multi-page files only), then the insertion point with `Scale` and `Mode` options.
|
|
211
|
+
3. Use `pdfjs-dist` to read operator lists from the selected page.
|
|
212
|
+
4. Keep every path as exact segments (lines and cubic Béziers; quadratics are degree-elevated) in model-space millimeters, and `showText` runs as `AcDbText`.
|
|
213
|
+
5. In `Recover` mode, recognize CAD curves per subpath (`recognition/pdfCurveRecognition.ts`): a cubic whose samples and end tangents match one circle becomes an arc; consecutive arcs on the same circle merge, and a closed 360° chain becomes a circle. Chains that fit a conic become an ellipse. Runs of at least six short, evenly turning lines (turn ≤ 15°, so octagons stay polygons) are refitted as arcs. Lines plus arcs give a bulged polyline; pure free-form chains give an exact spline (triple interior knots). Default tolerance: max(0.01 mm, 0.2 % of the radius).
|
|
214
|
+
6. In `Recover` mode, group top-level Form XObject paints whose geometry is identical in form space (`recognition/pdfFormBlocks.ts`; PDF.js inlines forms without naming them). Each group of two or more becomes a `PDF_FORM_n` block, and each paint becomes a reference whose transform comes from its form matrix. Paints with shear stay as plain geometry. Turn this off with `formBlocks: false`.
|
|
215
|
+
7. Map PDF optional content groups to CAD layers when present.
|
|
216
|
+
8. Remap paper-contrast ink to ACI 7 (AutoCAD foreground): black ink on white PDF paper, or white ink on dark PDF paper. ACI 7 follows the CAD canvas background.
|
|
217
|
+
|
|
218
|
+
9. Fit each text to its PDF advance width: the text is measured in the font the viewer will draw it with (`AcApFontUtil.measureTextWidth`, which mirrors the TEXT renderer's style font → big font → default font lookup) and its width factor is set to `pdfWidth / measuredWidth`. Turn this off with `fitTextWidth: false`.
|
|
219
|
+
10. Turn image paints (`paintImageXObject`, inline images) into `AcDbRasterImage` entities (`pdfImportImages.ts`). Each image is redrawn with its full placement (rotation, mirroring, skew) into an upright PNG covering its bounding box, so the entity needs no rotation. Dark ink on transparency (QR codes, stamps) is laid on white, as on the PDF page. The PNG lives in memory on the entity; the `PDF_IMAGE_n.png` definition is a name only, because DWG/DXF reference images as external files. Turn this off with `images: false`. Image masks and clipping paths are not applied.
|
|
220
|
+
|
|
221
|
+
Only the requested page is processed (default: page 1). Form XObject `/Matrix` is applied so nested content keeps its placement.
|
|
222
|
+
|
|
223
|
+
## Main exports
|
|
224
|
+
|
|
225
|
+
| Export | Role |
|
|
226
|
+
|--------|------|
|
|
227
|
+
| `createPdfPlugin` | Async factory used by lazy loader |
|
|
228
|
+
| `PDF_PLUGIN_NAME`, `PDF_PLUGIN_TRIGGERS` | Plugin id and command triggers |
|
|
229
|
+
| `@mlightcad/cad-pdf-plugin/register` | `registerLazyPdfPlugin` and registration constants |
|
|
230
|
+
| `AcApPdfPlugin` | `AcApPlugin` implementation |
|
|
231
|
+
| `AcApConvertToPdfCmd` | `-cpdf` / fallback `cpdf` command class |
|
|
232
|
+
| `AcApImportPdfCmd` | `pdfimport` command class |
|
|
233
|
+
| `AcApImportPdfPromptCmd` | `-pdfimport` command class |
|
|
234
|
+
| `AcUiPdfImportDialog` | Import PDF dialog opened by `pdfimport` (page preview, location, scale, mode) |
|
|
235
|
+
| `AcApPdfScaleCmd` | `pdfscale` command class |
|
|
236
|
+
| `AcApPdfTextCmd` | `pdftext` command class |
|
|
237
|
+
| `AcApPdfBlockCmd` | `pdfblock` command class |
|
|
238
|
+
| `AcApPdfDimCmd` | `pdfdim` command class |
|
|
239
|
+
| `AcApPdfDimSession`, `AcUiPdfDimPanel` | Review state and palette UI for `pdfdim` |
|
|
240
|
+
| `recognizePdfDimensions`, `suggestPdfDimensionScale`, `pdfArrowFromPolygon`, `parsePdfDimensionValue`, `recognizePdfDimStrokeText` | Dimension recognition (including lightweight stroke digits) |
|
|
241
|
+
| `pdfEntitiesToDimInput`, `acapPdfEnsureDimStyle`, `acapPdfCreateDimensions`, `acapPdfNiceScale` | Dimension conversion against a database |
|
|
242
|
+
| `findPdfShapeMatches`, `buildPdfFormBlocks`, `pdfEntityToFeature` | Block recovery building blocks |
|
|
243
|
+
| `clusterPdfTextStrokes`, `PdfGlyphDictionary`, `mergePdfTextRuns`, `pdfEntityToStroke` | Text recovery building blocks |
|
|
244
|
+
| `AcApPdfImportOptions`, `resolveAcApPdfImportOptions` | Import options (mode, page, placement, scale, curve recognition) |
|
|
245
|
+
| `recognizePdfCurves`, `buildPdfImportShapes`, `PdfRecognizedShape` | Curve recognition and page-level shape building |
|
|
246
|
+
| `AcApPdfConvertor` | CAD → PDF export utility |
|
|
247
|
+
| `AcApPdfExportOptions`, `AcApPdfColorMode`, `resolveAcApPdfExportOptions` | Export option types and defaults (aliases of `@mlightcad/cad-pdf-core`) |
|
|
248
|
+
| `AcApPdfImportConvertor` | PDF → CAD entities import utility |
|
|
249
|
+
| `extractPdfImportSubpaths`, `PDF_IMPORT_FOREGROUND_COLOR`, `PdfImportExtractOptions`, contrast helpers | Programmatic vector import / ACI 7 remapping |
|
|
250
|
+
|
|
251
|
+
## Project layout
|
|
252
|
+
|
|
253
|
+
| Path | Role |
|
|
254
|
+
|------|------|
|
|
255
|
+
| `src/register.ts` | Lazy plugin registration (`/register` entry) and `createPdfPlugin` |
|
|
256
|
+
| `src/AcApPdfPlugin.ts` | Plugin lifecycle (`onLoad` / `onUnload`) |
|
|
257
|
+
| `src/AcApConvertToPdfCmd.ts` | `-cpdf` command (command-line prompts) |
|
|
258
|
+
| `src/AcApImportPdfCmd.ts` | `pdfimport` command |
|
|
259
|
+
| `src/AcApPdfScaleCmd.ts` | `pdfscale` command |
|
|
260
|
+
| `src/AcApPdfTextCmd.ts` | `pdftext` command |
|
|
261
|
+
| `src/AcApPdfBlockCmd.ts` | `pdfblock` command |
|
|
262
|
+
| `src/AcApPdfDimCmd.ts` | `pdfdim` command |
|
|
263
|
+
| `src/pdfDimensionConvert.ts` | Dimension entities and the `PDF_DIM` style |
|
|
264
|
+
| `src/acapPdfPrompts.ts` | Shared Yes / No / Review prompt |
|
|
265
|
+
| `src/pdfEntityFeatures.ts` | Describes entities for instance matching |
|
|
266
|
+
| `src/pdfEntityStrokes.ts` | Samples curve entities into strokes |
|
|
267
|
+
| `src/AcApPdfImportOptions.ts` | Import option types and defaults |
|
|
268
|
+
| `src/pdfImportShapes.ts` | Page-level recognition, placement and de-duplication |
|
|
269
|
+
| `src/recognition/` | Pure geometry: curve recognition and fitting helpers |
|
|
270
|
+
| `src/AcApPdfConvertor.ts` | Browser export: view box, fonts, download (rendering via `cad-pdf-core`) |
|
|
271
|
+
| `src/AcApPdfExportOptions.ts` | Export option types and defaults |
|
|
272
|
+
| `src/AcApPdfImportConvertor.ts` | Import pipeline (pdf.js operator parsing) |
|
|
273
|
+
|
|
274
|
+
## Role in MLightCAD
|
|
275
|
+
|
|
276
|
+
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.
|
|
277
|
+
|
|
278
|
+
## License
|
|
279
|
+
|
|
280
|
+
MIT
|
|
@@ -1,17 +1,35 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const e = "PdfPlugin", i = [
|
|
2
|
+
"-cpdf",
|
|
3
|
+
"cpdf",
|
|
4
|
+
"pdfimport",
|
|
5
|
+
"-pdfimport",
|
|
6
|
+
"pdfscale",
|
|
7
|
+
"pdftext",
|
|
8
|
+
"pdfblock",
|
|
9
|
+
"pdfdim",
|
|
10
|
+
"pdfhatch"
|
|
11
|
+
], o = [
|
|
12
|
+
"pdfimport",
|
|
13
|
+
"-pdfimport",
|
|
14
|
+
"pdfscale",
|
|
15
|
+
"pdftext",
|
|
16
|
+
"pdfblock",
|
|
17
|
+
"pdfdim",
|
|
18
|
+
"pdfhatch"
|
|
19
|
+
];
|
|
20
|
+
function c(d, p = {}) {
|
|
21
|
+
const t = p.disableExport === !0, r = t ? [...o] : [...i];
|
|
22
|
+
d.registerLazyPlugin({
|
|
23
|
+
name: e,
|
|
24
|
+
triggers: [...r],
|
|
7
25
|
loader: async () => {
|
|
8
|
-
const { createPdfPlugin:
|
|
9
|
-
return
|
|
26
|
+
const { createPdfPlugin: f } = await import("@mlightcad/cad-pdf-plugin");
|
|
27
|
+
return f({ disableExport: t });
|
|
10
28
|
}
|
|
11
29
|
});
|
|
12
30
|
}
|
|
13
31
|
export {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
32
|
+
e as PDF_PLUGIN_NAME,
|
|
33
|
+
i as PDF_PLUGIN_TRIGGERS,
|
|
34
|
+
c as registerLazyPdfPlugin
|
|
17
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var P=Object.create;var p=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var s=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty;var l=(t,d,e,i)=>{if(d&&typeof d=="object"||typeof d=="function")for(let r of n(d))!a.call(t,r)&&r!==e&&p(t,r,{get:()=>d[r],enumerable:!(i=c(d,r))||i.enumerable});return t};var g=(t,d,e)=>(e=t!=null?P(s(t)):{},l(d||!t||!t.__esModule?p(e,"default",{value:t,enumerable:!0}):e,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f="PdfPlugin",o=["-cpdf","cpdf","pdfimport","-pdfimport","pdfscale","pdftext","pdfblock","pdfdim","pdfhatch"],u=["pdfimport","-pdfimport","pdfscale","pdftext","pdfblock","pdfdim","pdfhatch"];function G(t,d={}){const e=d.disableExport===!0,i=e?[...u]:[...o];t.registerLazyPlugin({name:f,triggers:[...i],loader:async()=>{const{createPdfPlugin:r}=await import("@mlightcad/cad-pdf-plugin");return r({disableExport:e})}})}exports.PDF_PLUGIN_NAME=f;exports.PDF_PLUGIN_TRIGGERS=o;exports.registerLazyPdfPlugin=G;
|