@mlightcad/cad-pdf-exporter 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 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,80 +1,81 @@
1
- # @mlightcad/cad-pdf-exporter
2
-
3
- Headless (Node) export of DXF/DWG drawings to vector PDF.
4
-
5
- > **1.8.0:** New package. Same shared pipeline as browser `cpdf`, via
6
- > `@mlightcad/cad-pdf-core`, so server/CI export does not need Playwright or a
7
- > browser. See the [upgrade guide](../../docs/development/upgrade-guide.md).
8
-
9
- Uses `@mlightcad/data-model` + `@mlightcad/pdf-renderer` through
10
- `@mlightcad/cad-pdf-core`, the same pipeline as the browser `cpdf` command in
11
- `@mlightcad/cad-pdf-plugin`. **Does not** depend on
12
- `@mlightcad/cad-simple-viewer` or a browser.
13
-
14
- ## Options
15
-
16
- | Option | Values | Default | Notes |
17
- | --------------- | ----------------------- | --------- | ----- |
18
- | `colorMode` | `color` / `monochrome` | `color` | `monochrome`: white paper, all drawing content black |
19
- | `textMode` | `text` / `vector` | `text` | `text` embeds fonts so text stays selectable |
20
- | `exportLayouts` | `true` / `false` | `true` | `true`: model space and every paper-space layout, one page each |
21
- | `title` | string | file stem | PDF document title |
22
- | `fontsDir` | path | — | Local font library (takes precedence over `fontsUrl`) |
23
- | `fontsUrl` | URL | jsDelivr | Remote font library base URL |
24
- | `fontMapping` | `{ [from]: to }` | — | Font name substitutions |
25
- | `dwgParser` | `libredwg` / `dwg` | `libredwg`| `dwg` needs the optional `@mlightcad/dwg-converter` |
26
- | `dwgLicenseKey` | string | — | License for `dwgParser: 'dwg'` |
27
- | `drawNoPlotLayers` | `true` / `false` | `false` | `false`: omit no-plot layers (matches cad-editor / AutoCAD plot) |
28
-
29
- Model space is always framed by drawable extents. A headless export has no
30
- live view, so the plugin's `Display` framing is not offered.
31
-
32
- In `monochrome` mode, linework and text are black and solid/gradient fills
33
- become grey by luminance. Wipeouts still mask in white and raster images keep
34
- their pixels. PNG and JPEG images are embedded; other raster formats (BMP,
35
- GIF) need a browser canvas to convert, so they are skipped in Node.
36
-
37
- ## Example
38
-
39
- After `pnpm build`, from this package:
40
-
41
- ```sh
42
- node examples/export-pdf.mjs drawing.dwg drawing.pdf
43
- node examples/export-pdf.mjs drawing.dwg drawing-bw.pdf --color-mode monochrome
44
- node examples/export-pdf.mjs drawing.dwg drawing.pdf --text-mode vector --no-layouts --fonts-dir D:/cad-data
45
- ```
46
-
47
- ## API
48
-
49
- ```ts
50
- import {
51
- convertDatabaseToPdf,
52
- exportFileToPdf
53
- } from '@mlightcad/cad-pdf-exporter'
54
-
55
- // File → file
56
- await exportFileToPdf('drawing.dwg', 'drawing.pdf', {
57
- colorMode: 'monochrome',
58
- // Local font library: a face folder, that folder with fonts.json, or a
59
- // cad-data checkout (faces resolved from its fonts/ directory).
60
- fontsDir: 'D:/code/cad-data'
61
- })
62
-
63
- // Already-open database → bytes
64
- const bytes = await convertDatabaseToPdf(database, { title: 'drawing' })
65
- ```
66
-
67
- ## Fonts
68
-
69
- Text is drawn by the same MText engine as the viewer, running on the Node
70
- main thread. Fonts come from `fontsDir` or `fontsUrl` (by default the public
71
- cad-data library on jsDelivr; set `HTTPS_PROXY` when the network needs a
72
- proxy). With `textMode: 'text'`, TrueType/OpenType/WOFF faces are subset
73
- and embedded. SHX fonts have nothing to embed, so their text is drawn as
74
- vector glyphs.
75
-
76
- ## Related packages
77
-
78
- - `@mlightcad/cad-pdf-core` — shared options and export pipeline
79
- - `@mlightcad/cad-pdf-plugin` — browser `cpdf` / `-cpdf` commands
80
- - `@mlightcad/cad-html-exporter` — the HTML counterpart of this package
1
+ # @mlightcad/cad-pdf-exporter
2
+
3
+ Headless (Node) export of DXF/DWG drawings to vector PDF.
4
+
5
+ > **1.8.0:** New package. Same shared pipeline as browser `cpdf`, via
6
+ > `@mlightcad/cad-pdf-core`, so server/CI export does not need Playwright or a
7
+ > browser. See the [upgrade guide](../../docs/development/upgrade-guide.md).
8
+
9
+ Uses `@mlightcad/data-model` + `@mlightcad/pdf-renderer` through
10
+ `@mlightcad/cad-pdf-core`, the same pipeline as the browser `cpdf` command in
11
+ `@mlightcad/cad-pdf-plugin`. **Does not** depend on
12
+ `@mlightcad/cad-simple-viewer` or a browser.
13
+
14
+ ## Options
15
+
16
+ | Option | Values | Default | Notes |
17
+ | --------------- | ----------------------- | --------- | ----- |
18
+ | `colorMode` | `color` / `monochrome` | `color` | `monochrome`: white paper, all drawing content black |
19
+ | `textMode` | `text` / `vector` | `text` | `text` embeds fonts so text stays selectable |
20
+ | `exportLayouts` | `true` / `false` | `true` | `true`: model space and every paper-space layout, one page each |
21
+ | `exportEmptyLayouts` | `true` / `false` | `false` | `false`: skip empty paper-space layouts; model space is always kept |
22
+ | `title` | string | file stem | PDF document title |
23
+ | `fontsDir` | path | — | Local font library (takes precedence over `fontsUrl`) |
24
+ | `fontsUrl` | URL | jsDelivr | Remote font library base URL |
25
+ | `fontMapping` | `{ [from]: to }` | — | Font name substitutions |
26
+ | `dwgParser` | `libredwg` / `dwg` | `libredwg`| `dwg` needs the optional `@mlightcad/dwg-converter` |
27
+ | `dwgLicenseKey` | string | — | License for `dwgParser: 'dwg'` |
28
+ | `drawNoPlotLayers` | `true` / `false` | `false` | `false`: omit no-plot layers (matches cad-editor / AutoCAD plot) |
29
+
30
+ Model space is always framed by drawable extents. A headless export has no
31
+ live view, so the plugin's `Display` framing is not offered.
32
+
33
+ In `monochrome` mode, linework and text are black and solid/gradient fills
34
+ become grey by luminance. Wipeouts still mask in white and raster images keep
35
+ their pixels. PNG and JPEG images are embedded; other raster formats (BMP,
36
+ GIF) need a browser canvas to convert, so they are skipped in Node.
37
+
38
+ ## Example
39
+
40
+ After `pnpm build`, from this package:
41
+
42
+ ```sh
43
+ node examples/export-pdf.mjs drawing.dwg drawing.pdf
44
+ node examples/export-pdf.mjs drawing.dwg drawing-bw.pdf --color-mode monochrome
45
+ node examples/export-pdf.mjs drawing.dwg drawing.pdf --text-mode vector --no-layouts --fonts-dir D:/cad-data
46
+ ```
47
+
48
+ ## API
49
+
50
+ ```ts
51
+ import {
52
+ convertDatabaseToPdf,
53
+ exportFileToPdf
54
+ } from '@mlightcad/cad-pdf-exporter'
55
+
56
+ // File → file
57
+ await exportFileToPdf('drawing.dwg', 'drawing.pdf', {
58
+ colorMode: 'monochrome',
59
+ // Local font library: a face folder, that folder with fonts.json, or a
60
+ // cad-data checkout (faces resolved from its fonts/ directory).
61
+ fontsDir: 'D:/code/cad-data'
62
+ })
63
+
64
+ // Already-open database → bytes
65
+ const bytes = await convertDatabaseToPdf(database, { title: 'drawing' })
66
+ ```
67
+
68
+ ## Fonts
69
+
70
+ Text is drawn by the same MText engine as the viewer, running on the Node
71
+ main thread. Fonts come from `fontsDir` or `fontsUrl` (by default the public
72
+ cad-data library on jsDelivr; set `HTTPS_PROXY` when the network needs a
73
+ proxy). With `textMode: 'text'`, TrueType/OpenType/WOFF faces are subset
74
+ and embedded. SHX fonts have nothing to embed, so their text is drawn as
75
+ vector glyphs.
76
+
77
+ ## Related packages
78
+
79
+ - `@mlightcad/cad-pdf-core` — shared options and export pipeline
80
+ - `@mlightcad/cad-pdf-plugin` — browser `cpdf` / `-cpdf` commands
81
+ - `@mlightcad/cad-html-exporter` — the HTML counterpart of this package