@mlightcad/cad-pdf-plugin 1.7.0 → 1.7.2
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 +39 -23
- package/dist/cad-pdf-plugin-register.js +1 -1
- package/dist/cad-pdf-plugin-register.umd.cjs +1 -1
- package/dist/cad-pdf-plugin.js +17087 -41467
- package/dist/cad-pdf-plugin.umd.cjs +13 -270
- package/lib/AcApConvertToPdfCmd.d.ts +13 -2
- package/lib/AcApConvertToPdfCmd.d.ts.map +1 -1
- package/lib/AcApConvertToPdfCmd.js +153 -7
- package/lib/AcApConvertToPdfCmd.js.map +1 -1
- package/lib/AcApPdfConvertor.d.ts +20 -8
- package/lib/AcApPdfConvertor.d.ts.map +1 -1
- package/lib/AcApPdfConvertor.js +89 -94
- package/lib/AcApPdfConvertor.js.map +1 -1
- package/lib/AcApPdfExportOptions.d.ts +38 -0
- package/lib/AcApPdfExportOptions.d.ts.map +1 -0
- package/lib/AcApPdfExportOptions.js +12 -0
- package/lib/AcApPdfExportOptions.js.map +1 -0
- package/lib/AcApPdfFontResolver.d.ts +20 -0
- package/lib/AcApPdfFontResolver.d.ts.map +1 -0
- package/lib/AcApPdfFontResolver.js +105 -0
- package/lib/AcApPdfFontResolver.js.map +1 -0
- package/lib/AcApPdfGlyphProvider.d.ts +15 -0
- package/lib/AcApPdfGlyphProvider.d.ts.map +1 -0
- package/lib/AcApPdfGlyphProvider.js +277 -0
- package/lib/AcApPdfGlyphProvider.js.map +1 -0
- package/lib/AcApPdfPlugin.d.ts +5 -3
- package/lib/AcApPdfPlugin.d.ts.map +1 -1
- package/lib/AcApPdfPlugin.js +13 -6
- package/lib/AcApPdfPlugin.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/register.d.ts +4 -2
- package/lib/register.d.ts.map +1 -1
- package/lib/register.js +4 -2
- package/lib/register.js.map +1 -1
- package/package.json +11 -9
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import { AcApContext, AcEdCommand } from '@mlightcad/cad-simple-viewer';
|
|
2
2
|
/**
|
|
3
3
|
* Command for converting the current CAD drawing to PDF format.
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* Registered as `-cpdf` (command-line prompts). Also registered as `cpdf` when
|
|
6
|
+
* no UI dialog command is already present (e.g. cad-simple-viewer without
|
|
7
|
+
* cad-viewer).
|
|
5
8
|
*/
|
|
6
9
|
export declare class AcApConvertToPdfCmd extends AcEdCommand {
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
11
|
+
* Prompts for export options, then renders and downloads the PDF.
|
|
9
12
|
*
|
|
10
13
|
* @param context - Application context for the active document
|
|
11
14
|
*/
|
|
12
15
|
execute(context: AcApContext): Promise<void>;
|
|
16
|
+
private promptOptions;
|
|
17
|
+
/**
|
|
18
|
+
* Prompts how text is painted: real PDF text (small file, selectable) or
|
|
19
|
+
* vector glyph outlines (current behaviour).
|
|
20
|
+
*/
|
|
21
|
+
private promptTextMode;
|
|
22
|
+
private promptModelSpaceFit;
|
|
23
|
+
private promptYesNo;
|
|
13
24
|
}
|
|
14
25
|
//# sourceMappingURL=AcApConvertToPdfCmd.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcApConvertToPdfCmd.d.ts","sourceRoot":"","sources":["../src/AcApConvertToPdfCmd.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AcApConvertToPdfCmd.d.ts","sourceRoot":"","sources":["../src/AcApConvertToPdfCmd.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAGX,WAAW,EAGZ,MAAM,8BAA8B,CAAA;AASrC;;;;;;GAMG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IAClD;;;;OAIG;IACG,OAAO,CAAC,OAAO,EAAE,WAAW;YAUpB,aAAa;IA4B3B;;;OAGG;YACW,cAAc;YAqCd,mBAAmB;YAwCnB,WAAW;CAoC1B"}
|
|
@@ -49,11 +49,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
49
49
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
-
import { AcEdCommand } from '@mlightcad/cad-simple-viewer';
|
|
52
|
+
import { AcApDocManager, AcApI18n, AcEdCommand, AcEdPromptKeywordOptions, AcEdPromptStatus } from '@mlightcad/cad-simple-viewer';
|
|
53
53
|
import { AcApPdfConvertor } from './AcApPdfConvertor';
|
|
54
|
+
import { resolveAcApPdfExportOptions } from './AcApPdfExportOptions';
|
|
54
55
|
/**
|
|
55
56
|
* Command for converting the current CAD drawing to PDF format.
|
|
56
|
-
*
|
|
57
|
+
*
|
|
58
|
+
* Registered as `-cpdf` (command-line prompts). Also registered as `cpdf` when
|
|
59
|
+
* no UI dialog command is already present (e.g. cad-simple-viewer without
|
|
60
|
+
* cad-viewer).
|
|
57
61
|
*/
|
|
58
62
|
var AcApConvertToPdfCmd = /** @class */ (function (_super) {
|
|
59
63
|
__extends(AcApConvertToPdfCmd, _super);
|
|
@@ -61,25 +65,167 @@ var AcApConvertToPdfCmd = /** @class */ (function (_super) {
|
|
|
61
65
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
62
66
|
}
|
|
63
67
|
/**
|
|
64
|
-
*
|
|
68
|
+
* Prompts for export options, then renders and downloads the PDF.
|
|
65
69
|
*
|
|
66
70
|
* @param context - Application context for the active document
|
|
67
71
|
*/
|
|
68
72
|
AcApConvertToPdfCmd.prototype.execute = function (context) {
|
|
69
73
|
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
-
var converter;
|
|
74
|
+
var options, converter;
|
|
71
75
|
return __generator(this, function (_a) {
|
|
72
76
|
switch (_a.label) {
|
|
73
|
-
case 0:
|
|
74
|
-
converter = new AcApPdfConvertor();
|
|
75
|
-
return [4 /*yield*/, converter.convert(context)];
|
|
77
|
+
case 0: return [4 /*yield*/, this.promptOptions()];
|
|
76
78
|
case 1:
|
|
79
|
+
options = _a.sent();
|
|
80
|
+
if (!options) {
|
|
81
|
+
return [2 /*return*/];
|
|
82
|
+
}
|
|
83
|
+
converter = new AcApPdfConvertor();
|
|
84
|
+
return [4 /*yield*/, converter.convert(context, options)];
|
|
85
|
+
case 2:
|
|
77
86
|
_a.sent();
|
|
78
87
|
return [2 /*return*/];
|
|
79
88
|
}
|
|
80
89
|
});
|
|
81
90
|
});
|
|
82
91
|
};
|
|
92
|
+
AcApConvertToPdfCmd.prototype.promptOptions = function () {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
94
|
+
var defaults, modelSpaceFit, exportLayouts, textMode;
|
|
95
|
+
return __generator(this, function (_a) {
|
|
96
|
+
switch (_a.label) {
|
|
97
|
+
case 0:
|
|
98
|
+
defaults = resolveAcApPdfExportOptions();
|
|
99
|
+
return [4 /*yield*/, this.promptModelSpaceFit()];
|
|
100
|
+
case 1:
|
|
101
|
+
modelSpaceFit = _a.sent();
|
|
102
|
+
if (modelSpaceFit === undefined) {
|
|
103
|
+
return [2 /*return*/, undefined];
|
|
104
|
+
}
|
|
105
|
+
return [4 /*yield*/, this.promptYesNo('jig.cpdf.exportLayouts', defaults.exportLayouts)];
|
|
106
|
+
case 2:
|
|
107
|
+
exportLayouts = _a.sent();
|
|
108
|
+
if (exportLayouts === undefined) {
|
|
109
|
+
return [2 /*return*/, undefined];
|
|
110
|
+
}
|
|
111
|
+
return [4 /*yield*/, this.promptTextMode()];
|
|
112
|
+
case 3:
|
|
113
|
+
textMode = _a.sent();
|
|
114
|
+
if (textMode === undefined) {
|
|
115
|
+
return [2 /*return*/, undefined];
|
|
116
|
+
}
|
|
117
|
+
return [2 /*return*/, resolveAcApPdfExportOptions({
|
|
118
|
+
modelSpaceFit: modelSpaceFit,
|
|
119
|
+
exportLayouts: exportLayouts,
|
|
120
|
+
textMode: textMode
|
|
121
|
+
})];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Prompts how text is painted: real PDF text (small file, selectable) or
|
|
128
|
+
* vector glyph outlines (current behaviour).
|
|
129
|
+
*/
|
|
130
|
+
AcApConvertToPdfCmd.prototype.promptTextMode = function () {
|
|
131
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
132
|
+
var defaults, prompt, text, vector, result;
|
|
133
|
+
return __generator(this, function (_a) {
|
|
134
|
+
switch (_a.label) {
|
|
135
|
+
case 0:
|
|
136
|
+
defaults = resolveAcApPdfExportOptions();
|
|
137
|
+
prompt = new AcEdPromptKeywordOptions(AcApI18n.t('jig.cpdf.textMode'));
|
|
138
|
+
prompt.allowNone = true;
|
|
139
|
+
text = prompt.keywords.add(AcApI18n.t('jig.cpdf.keywords.text.display'), AcApI18n.t('jig.cpdf.keywords.text.global'), AcApI18n.t('jig.cpdf.keywords.text.local'));
|
|
140
|
+
vector = prompt.keywords.add(AcApI18n.t('jig.cpdf.keywords.vector.display'), AcApI18n.t('jig.cpdf.keywords.vector.global'), AcApI18n.t('jig.cpdf.keywords.vector.local'));
|
|
141
|
+
prompt.keywords.default = defaults.textMode === 'vector' ? vector : text;
|
|
142
|
+
return [4 /*yield*/, AcApDocManager.instance.editor.getKeywords(prompt)];
|
|
143
|
+
case 1:
|
|
144
|
+
result = _a.sent();
|
|
145
|
+
if (result.status === AcEdPromptStatus.Cancel) {
|
|
146
|
+
return [2 /*return*/, undefined];
|
|
147
|
+
}
|
|
148
|
+
if (result.status === AcEdPromptStatus.None) {
|
|
149
|
+
return [2 /*return*/, defaults.textMode];
|
|
150
|
+
}
|
|
151
|
+
if (result.status === AcEdPromptStatus.OK ||
|
|
152
|
+
result.status === AcEdPromptStatus.Keyword) {
|
|
153
|
+
if (!result.stringResult) {
|
|
154
|
+
return [2 /*return*/, defaults.textMode];
|
|
155
|
+
}
|
|
156
|
+
return [2 /*return*/, result.stringResult === 'Vector' ? 'vector' : 'text'];
|
|
157
|
+
}
|
|
158
|
+
return [2 /*return*/, undefined];
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
AcApConvertToPdfCmd.prototype.promptModelSpaceFit = function () {
|
|
164
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
165
|
+
var defaults, prompt, extents, display, result;
|
|
166
|
+
return __generator(this, function (_a) {
|
|
167
|
+
switch (_a.label) {
|
|
168
|
+
case 0:
|
|
169
|
+
defaults = resolveAcApPdfExportOptions();
|
|
170
|
+
prompt = new AcEdPromptKeywordOptions(AcApI18n.t('jig.cpdf.modelSpaceFit'));
|
|
171
|
+
prompt.allowNone = true;
|
|
172
|
+
extents = prompt.keywords.add(AcApI18n.t('jig.cpdf.keywords.extents.display'), AcApI18n.t('jig.cpdf.keywords.extents.global'), AcApI18n.t('jig.cpdf.keywords.extents.local'));
|
|
173
|
+
display = prompt.keywords.add(AcApI18n.t('jig.cpdf.keywords.display.display'), AcApI18n.t('jig.cpdf.keywords.display.global'), AcApI18n.t('jig.cpdf.keywords.display.local'));
|
|
174
|
+
prompt.keywords.default =
|
|
175
|
+
defaults.modelSpaceFit === 'display' ? display : extents;
|
|
176
|
+
return [4 /*yield*/, AcApDocManager.instance.editor.getKeywords(prompt)];
|
|
177
|
+
case 1:
|
|
178
|
+
result = _a.sent();
|
|
179
|
+
if (result.status === AcEdPromptStatus.Cancel) {
|
|
180
|
+
return [2 /*return*/, undefined];
|
|
181
|
+
}
|
|
182
|
+
if (result.status === AcEdPromptStatus.None) {
|
|
183
|
+
return [2 /*return*/, defaults.modelSpaceFit];
|
|
184
|
+
}
|
|
185
|
+
if (result.status === AcEdPromptStatus.OK ||
|
|
186
|
+
result.status === AcEdPromptStatus.Keyword) {
|
|
187
|
+
if (!result.stringResult) {
|
|
188
|
+
return [2 /*return*/, defaults.modelSpaceFit];
|
|
189
|
+
}
|
|
190
|
+
return [2 /*return*/, result.stringResult === 'Display' ? 'display' : 'extents'];
|
|
191
|
+
}
|
|
192
|
+
return [2 /*return*/, undefined];
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
AcApConvertToPdfCmd.prototype.promptYesNo = function (messageKey, defaultYes) {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
+
var prompt, yes, no, result;
|
|
200
|
+
return __generator(this, function (_a) {
|
|
201
|
+
switch (_a.label) {
|
|
202
|
+
case 0:
|
|
203
|
+
prompt = new AcEdPromptKeywordOptions(AcApI18n.t(messageKey));
|
|
204
|
+
prompt.allowNone = true;
|
|
205
|
+
yes = prompt.keywords.add(AcApI18n.t('jig.cpdf.keywords.yes.display'), AcApI18n.t('jig.cpdf.keywords.yes.global'), AcApI18n.t('jig.cpdf.keywords.yes.local'));
|
|
206
|
+
no = prompt.keywords.add(AcApI18n.t('jig.cpdf.keywords.no.display'), AcApI18n.t('jig.cpdf.keywords.no.global'), AcApI18n.t('jig.cpdf.keywords.no.local'));
|
|
207
|
+
prompt.keywords.default = defaultYes ? yes : no;
|
|
208
|
+
return [4 /*yield*/, AcApDocManager.instance.editor.getKeywords(prompt)];
|
|
209
|
+
case 1:
|
|
210
|
+
result = _a.sent();
|
|
211
|
+
if (result.status === AcEdPromptStatus.Cancel) {
|
|
212
|
+
return [2 /*return*/, undefined];
|
|
213
|
+
}
|
|
214
|
+
if (result.status === AcEdPromptStatus.None) {
|
|
215
|
+
return [2 /*return*/, defaultYes];
|
|
216
|
+
}
|
|
217
|
+
if (result.status === AcEdPromptStatus.OK ||
|
|
218
|
+
result.status === AcEdPromptStatus.Keyword) {
|
|
219
|
+
if (!result.stringResult) {
|
|
220
|
+
return [2 /*return*/, defaultYes];
|
|
221
|
+
}
|
|
222
|
+
return [2 /*return*/, result.stringResult === 'Yes'];
|
|
223
|
+
}
|
|
224
|
+
return [2 /*return*/, undefined];
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
};
|
|
83
229
|
return AcApConvertToPdfCmd;
|
|
84
230
|
}(AcEdCommand));
|
|
85
231
|
export { AcApConvertToPdfCmd };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcApConvertToPdfCmd.js","sourceRoot":"","sources":["../src/AcApConvertToPdfCmd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AcApConvertToPdfCmd.js","sourceRoot":"","sources":["../src/AcApConvertToPdfCmd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAEL,cAAc,EACd,QAAQ,EACR,WAAW,EACX,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,8BAA8B,CAAA;AAErC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAGL,2BAA2B,EAC5B,MAAM,wBAAwB,CAAA;AAE/B;;;;;;GAMG;AACH;IAAyC,uCAAW;IAApD;;IAiKA,CAAC;IAhKC;;;;OAIG;IACG,qCAAO,GAAb,UAAc,OAAoB;;;;;4BAChB,qBAAM,IAAI,CAAC,aAAa,EAAE,EAAA;;wBAApC,OAAO,GAAG,SAA0B;wBAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;4BACb,sBAAM;wBACR,CAAC;wBAEK,SAAS,GAAG,IAAI,gBAAgB,EAAE,CAAA;wBACxC,qBAAM,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,EAAA;;wBAAzC,SAAyC,CAAA;;;;;KAC1C;IAEa,2CAAa,GAA3B;;;;;;wBACQ,QAAQ,GAAG,2BAA2B,EAAE,CAAA;wBAExB,qBAAM,IAAI,CAAC,mBAAmB,EAAE,EAAA;;wBAAhD,aAAa,GAAG,SAAgC;wBACtD,IAAI,aAAa,KA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';
|
|
2
|
+
import { type AcApPdfExportOptions } from './AcApPdfExportOptions';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* Converts the current CAD drawing to a vector PDF and downloads it.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
6
|
+
* Framing matches HTML export: `'extents'` fits drawable geometry; `'display'`
|
|
7
|
+
* uses the live camera box. Paper-space pages ignore model-space fit and use
|
|
8
|
+
* their own drawable extents.
|
|
9
|
+
*
|
|
10
|
+
* When {@link AcApPdfExportOptions.exportLayouts} is true, every layout becomes
|
|
11
|
+
* one PDF page. Stroke widths follow the drawing `LWDISPLAY` flag: on uses
|
|
12
|
+
* object lineweights, off emits true PDF hairlines. A busy indicator is shown
|
|
13
|
+
* for the duration.
|
|
7
14
|
*/
|
|
8
15
|
export declare class AcApPdfConvertor {
|
|
9
16
|
/**
|
|
10
17
|
* Renders the current drawing to PDF and triggers a browser download.
|
|
18
|
+
*
|
|
19
|
+
* @param context - Active document context
|
|
20
|
+
* @param options - Export framing and layout options
|
|
21
|
+
*/
|
|
22
|
+
convert(context: AcApContext, options?: AcApPdfExportOptions): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Captures the visible world box from the active view’s screen corners.
|
|
11
25
|
*/
|
|
12
|
-
|
|
13
|
-
private
|
|
14
|
-
private configureRenderer;
|
|
15
|
-
private downloadAsPdf;
|
|
26
|
+
private captureFitBox;
|
|
27
|
+
private downloadBytes;
|
|
16
28
|
}
|
|
17
29
|
//# sourceMappingURL=AcApPdfConvertor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcApPdfConvertor.d.ts","sourceRoot":"","sources":["../src/AcApPdfConvertor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"AcApPdfConvertor.d.ts","sourceRoot":"","sources":["../src/AcApPdfConvertor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAMjB,MAAM,8BAA8B,CAAA;AAMrC,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,wBAAwB,CAAA;AAI/B;;;;;;;;;;;GAWG;AACH,qBAAa,gBAAgB;IAC3B;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,GAAE,oBAAyB;IA2CtE;;OAEG;IACH,OAAO,CAAC,aAAa;IAkBrB,OAAO,CAAC,aAAa;CAYtB"}
|
package/lib/AcApPdfConvertor.js
CHANGED
|
@@ -34,120 +34,115 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
34
34
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (o && i >= o.length) o = void 0;
|
|
43
|
-
return { value: o && o[i++], done: !o };
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
47
|
-
};
|
|
48
|
-
import { AcApSettingManager, resolveExportDownloadName } from '@mlightcad/cad-simple-viewer';
|
|
49
|
-
import { AcSvgRenderer } from '@mlightcad/cad-svg-plugin';
|
|
50
|
-
import { jsPDF } from 'jspdf';
|
|
51
|
-
import { svg2pdf } from 'svg2pdf.js';
|
|
37
|
+
import { AcApDocManager, AcApI18n, AcApSettingManager, resolveExportDownloadName } from '@mlightcad/cad-simple-viewer';
|
|
38
|
+
import { exportDatabaseToPdf } from '@mlightcad/pdf-renderer';
|
|
39
|
+
import { resolveAcApPdfExportOptions } from './AcApPdfExportOptions';
|
|
40
|
+
import { resolveViewerTextFont } from './AcApPdfFontResolver';
|
|
41
|
+
import { createViewerPdfGlyphProvider } from './AcApPdfGlyphProvider';
|
|
52
42
|
/**
|
|
53
|
-
*
|
|
43
|
+
* Converts the current CAD drawing to a vector PDF and downloads it.
|
|
44
|
+
*
|
|
45
|
+
* Framing matches HTML export: `'extents'` fits drawable geometry; `'display'`
|
|
46
|
+
* uses the live camera box. Paper-space pages ignore model-space fit and use
|
|
47
|
+
* their own drawable extents.
|
|
54
48
|
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
49
|
+
* When {@link AcApPdfExportOptions.exportLayouts} is true, every layout becomes
|
|
50
|
+
* one PDF page. Stroke widths follow the drawing `LWDISPLAY` flag: on uses
|
|
51
|
+
* object lineweights, off emits true PDF hairlines. A busy indicator is shown
|
|
52
|
+
* for the duration.
|
|
57
53
|
*/
|
|
58
54
|
var AcApPdfConvertor = /** @class */ (function () {
|
|
59
55
|
function AcApPdfConvertor() {
|
|
60
56
|
}
|
|
61
57
|
/**
|
|
62
58
|
* Renders the current drawing to PDF and triggers a browser download.
|
|
59
|
+
*
|
|
60
|
+
* @param context - Active document context
|
|
61
|
+
* @param options - Export framing and layout options
|
|
63
62
|
*/
|
|
64
|
-
AcApPdfConvertor.prototype.convert = function (
|
|
65
|
-
return __awaiter(this,
|
|
66
|
-
var
|
|
63
|
+
AcApPdfConvertor.prototype.convert = function (context_1) {
|
|
64
|
+
return __awaiter(this, arguments, void 0, function (context, options) {
|
|
65
|
+
var resolved;
|
|
66
|
+
var _this = this;
|
|
67
|
+
if (options === void 0) { options = {}; }
|
|
67
68
|
return __generator(this, function (_a) {
|
|
68
69
|
switch (_a.label) {
|
|
69
|
-
case 0:
|
|
70
|
+
case 0:
|
|
71
|
+
resolved = resolveAcApPdfExportOptions(options);
|
|
72
|
+
return [4 /*yield*/, AcApDocManager.instance.withBusyIndicator(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
73
|
+
var db, pdfOptions, inModelSpace, bytes, downloadName;
|
|
74
|
+
return __generator(this, function (_a) {
|
|
75
|
+
switch (_a.label) {
|
|
76
|
+
case 0:
|
|
77
|
+
db = context.doc.database;
|
|
78
|
+
pdfOptions = {
|
|
79
|
+
title: context.doc.fileName || context.doc.docTitle,
|
|
80
|
+
ltscale: db.ltscale,
|
|
81
|
+
celtscale: db.celtscale,
|
|
82
|
+
showLineWeight: !!db.lwdisplay,
|
|
83
|
+
fontMapping: AcApSettingManager.instance.fontMapping,
|
|
84
|
+
background: 'none',
|
|
85
|
+
fit: resolved.modelSpaceFit === 'display' ? 'current' : 'extents',
|
|
86
|
+
layouts: resolved.exportLayouts ? 'all' : 'current',
|
|
87
|
+
glyphProvider: createViewerPdfGlyphProvider(),
|
|
88
|
+
textMode: resolved.textMode
|
|
89
|
+
};
|
|
90
|
+
if (resolved.textMode === 'text') {
|
|
91
|
+
pdfOptions.textFontResolver = resolveViewerTextFont;
|
|
92
|
+
}
|
|
93
|
+
if (resolved.modelSpaceFit === 'display') {
|
|
94
|
+
inModelSpace = db.currentSpaceId === db.tables.blockTable.modelSpace.objectId;
|
|
95
|
+
if (inModelSpace || !resolved.exportLayouts) {
|
|
96
|
+
pdfOptions.fitBox = this.captureFitBox(context.view);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return [4 /*yield*/, exportDatabaseToPdf(db, pdfOptions)];
|
|
100
|
+
case 1:
|
|
101
|
+
bytes = _a.sent();
|
|
102
|
+
downloadName = resolveExportDownloadName(context.doc.fileName || context.doc.docTitle, 'pdf');
|
|
103
|
+
this.downloadBytes(bytes, downloadName);
|
|
104
|
+
return [2 /*return*/];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}); }, AcApI18n.t('main.message.exportingPdf'))];
|
|
70
108
|
case 1:
|
|
71
|
-
svgString = _a.sent();
|
|
72
|
-
downloadName = resolveExportDownloadName(context.doc.fileName || context.doc.docTitle, 'pdf');
|
|
73
|
-
return [4 /*yield*/, this.downloadAsPdf(svgString, downloadName)];
|
|
74
|
-
case 2:
|
|
75
109
|
_a.sent();
|
|
76
110
|
return [2 /*return*/];
|
|
77
111
|
}
|
|
78
112
|
});
|
|
79
113
|
});
|
|
80
114
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
this.configureRenderer(renderer, context);
|
|
90
|
-
try {
|
|
91
|
-
for (entities_1 = __values(entities), entities_1_1 = entities_1.next(); !entities_1_1.done; entities_1_1 = entities_1.next()) {
|
|
92
|
-
entity = entities_1_1.value;
|
|
93
|
-
entity.worldDraw(renderer);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
97
|
-
finally {
|
|
98
|
-
try {
|
|
99
|
-
if (entities_1_1 && !entities_1_1.done && (_a = entities_1.return)) _a.call(entities_1);
|
|
100
|
-
}
|
|
101
|
-
finally { if (e_1) throw e_1.error; }
|
|
102
|
-
}
|
|
103
|
-
return [2 /*return*/, renderer.exportAsync()];
|
|
104
|
-
});
|
|
115
|
+
/**
|
|
116
|
+
* Captures the visible world box from the active view’s screen corners.
|
|
117
|
+
*/
|
|
118
|
+
AcApPdfConvertor.prototype.captureFitBox = function (view) {
|
|
119
|
+
var topLeft = view.screenToWorld({ x: 0, y: 0 });
|
|
120
|
+
var bottomRight = view.screenToWorld({
|
|
121
|
+
x: view.width,
|
|
122
|
+
y: view.height
|
|
105
123
|
});
|
|
124
|
+
return {
|
|
125
|
+
min: {
|
|
126
|
+
x: Math.min(topLeft.x, bottomRight.x),
|
|
127
|
+
y: Math.min(topLeft.y, bottomRight.y)
|
|
128
|
+
},
|
|
129
|
+
max: {
|
|
130
|
+
x: Math.max(topLeft.x, bottomRight.x),
|
|
131
|
+
y: Math.max(topLeft.y, bottomRight.y)
|
|
132
|
+
}
|
|
133
|
+
};
|
|
106
134
|
};
|
|
107
|
-
AcApPdfConvertor.prototype.
|
|
108
|
-
var
|
|
109
|
-
var
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
};
|
|
119
|
-
AcApPdfConvertor.prototype.downloadAsPdf = function (svgString, downloadName) {
|
|
120
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
121
|
-
var parser, svgDoc, svgEl, vb, vbWidth, vbHeight, orientation, pdf;
|
|
122
|
-
var _a;
|
|
123
|
-
return __generator(this, function (_b) {
|
|
124
|
-
switch (_b.label) {
|
|
125
|
-
case 0:
|
|
126
|
-
parser = new DOMParser();
|
|
127
|
-
svgDoc = parser.parseFromString(svgString, 'image/svg+xml');
|
|
128
|
-
svgEl = svgDoc.documentElement;
|
|
129
|
-
vb = (_a = svgEl.getAttribute('viewBox')) === null || _a === void 0 ? void 0 : _a.split(' ').map(Number);
|
|
130
|
-
vbWidth = vb && vb.length === 4 ? Math.abs(vb[2]) : 297;
|
|
131
|
-
vbHeight = vb && vb.length === 4 ? Math.abs(vb[3]) : 210;
|
|
132
|
-
orientation = vbWidth >= vbHeight ? 'landscape' : 'portrait';
|
|
133
|
-
pdf = new jsPDF({
|
|
134
|
-
orientation: orientation,
|
|
135
|
-
unit: 'mm',
|
|
136
|
-
format: [vbWidth, vbHeight]
|
|
137
|
-
});
|
|
138
|
-
return [4 /*yield*/, svg2pdf(svgEl, pdf, {
|
|
139
|
-
x: 0,
|
|
140
|
-
y: 0,
|
|
141
|
-
width: vbWidth,
|
|
142
|
-
height: vbHeight
|
|
143
|
-
})];
|
|
144
|
-
case 1:
|
|
145
|
-
_b.sent();
|
|
146
|
-
pdf.save(downloadName);
|
|
147
|
-
return [2 /*return*/];
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
});
|
|
135
|
+
AcApPdfConvertor.prototype.downloadBytes = function (bytes, downloadName) {
|
|
136
|
+
var blob = new Blob([bytes], { type: 'application/pdf' });
|
|
137
|
+
var url = URL.createObjectURL(blob);
|
|
138
|
+
var link = document.createElement('a');
|
|
139
|
+
link.href = url;
|
|
140
|
+
link.download = downloadName || 'drawing.pdf';
|
|
141
|
+
link.rel = 'noopener';
|
|
142
|
+
document.body.appendChild(link);
|
|
143
|
+
link.click();
|
|
144
|
+
document.body.removeChild(link);
|
|
145
|
+
window.setTimeout(function () { return URL.revokeObjectURL(url); }, 60000);
|
|
151
146
|
};
|
|
152
147
|
return AcApPdfConvertor;
|
|
153
148
|
}());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcApPdfConvertor.js","sourceRoot":"","sources":["../src/AcApPdfConvertor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AcApPdfConvertor.js","sourceRoot":"","sources":["../src/AcApPdfConvertor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAEL,cAAc,EACd,QAAQ,EACR,kBAAkB,EAElB,yBAAyB,EAC1B,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAEL,mBAAmB,EACpB,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EAEL,2BAA2B,EAC5B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAA;AAErE;;;;;;;;;;;GAWG;AACH;IAAA;IAmFA,CAAC;IAlFC;;;;;OAKG;IACG,kCAAO,GAAb;4DAAc,OAAoB,EAAE,OAAkC;;;YAAlC,wBAAA,EAAA,YAAkC;;;;wBAC9D,QAAQ,GAAG,2BAA2B,CAAC,OAAO,CAAC,CAAA;wBAErD,qBAAM,cAAc,CAAC,QAAQ,CAAC,iBAAiB,CAAC;;;;;4CACxC,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAA;4CACzB,UAAU,GAAuB;gDACrC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ;gDACnD,OAAO,EAAE,EAAE,CAAC,OAAO;gDACnB,SAAS,EAAE,EAAE,CAAC,SAAS;gDACvB,cAAc,EAAE,CAAC,CAAC,EAAE,C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AA;QACZ,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;QAC/B,MAAM,CAAC,UAAU,CAAC,cAAM,OAAA,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,EAAxB,CAAwB,EAAE,KAAM,CAAC,CAAA;IAC3D,CAAC;IACH,uBAAC;AAAD,CAAC,AAnFD,IAmFC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-space page framing for PDF export.
|
|
3
|
+
*
|
|
4
|
+
* - `display` — fit the live viewport (on-screen view).
|
|
5
|
+
* - `extents` — fit drawable geometry in the current space.
|
|
6
|
+
*/
|
|
7
|
+
export type AcApPdfModelSpaceFit = 'display' | 'extents';
|
|
8
|
+
/**
|
|
9
|
+
* User-configurable options for PDF export (`cpdf` dialog, `-cpdf`, and API).
|
|
10
|
+
*/
|
|
11
|
+
export interface AcApPdfExportOptions {
|
|
12
|
+
/**
|
|
13
|
+
* How to frame model-space pages. Defaults to `'extents'`.
|
|
14
|
+
* Paper-space pages always use their own drawable extents / paper size.
|
|
15
|
+
*/
|
|
16
|
+
modelSpaceFit?: AcApPdfModelSpaceFit;
|
|
17
|
+
/**
|
|
18
|
+
* When `true`, every layout (model + paper space) becomes a PDF page.
|
|
19
|
+
* When `false`, only the current space is exported. Defaults to `true`.
|
|
20
|
+
*/
|
|
21
|
+
exportLayouts?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* How MTEXT/TEXT are painted.
|
|
24
|
+
*
|
|
25
|
+
* - `'text'` (default): laid-out text is painted as real PDF text through
|
|
26
|
+
* fonts resolved from the viewer font catalog — text stays
|
|
27
|
+
* selectable/searchable and the file shrinks dramatically. Texts whose
|
|
28
|
+
* font is SHX or cannot be embedded fall back to vector glyphs.
|
|
29
|
+
* - `'vector'`: glyphs are tessellated into line/fill geometry
|
|
30
|
+
* (self-contained, but dense text dominates the file size).
|
|
31
|
+
*/
|
|
32
|
+
textMode?: 'vector' | 'text';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolves PDF export options with package defaults.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveAcApPdfExportOptions(options?: AcApPdfExportOptions): Required<AcApPdfExportOptions>;
|
|
38
|
+
//# sourceMappingURL=AcApPdfExportOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcApPdfExportOptions.d.ts","sourceRoot":"","sources":["../src/AcApPdfExportOptions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,SAAS,CAAA;AAExD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,aAAa,CAAC,EAAE,oBAAoB,CAAA;IACpC;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAA;CAC7B;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,GAAE,oBAAyB,GACjC,QAAQ,CAAC,oBAAoB,CAAC,CAOhC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves PDF export options with package defaults.
|
|
3
|
+
*/
|
|
4
|
+
export function resolveAcApPdfExportOptions(options) {
|
|
5
|
+
if (options === void 0) { options = {}; }
|
|
6
|
+
return {
|
|
7
|
+
modelSpaceFit: options.modelSpaceFit === 'display' ? 'display' : 'extents',
|
|
8
|
+
exportLayouts: options.exportLayouts !== false,
|
|
9
|
+
textMode: options.textMode === 'vector' ? 'vector' : 'text'
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=AcApPdfExportOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcApPdfExportOptions.js","sourceRoot":"","sources":["../src/AcApPdfExportOptions.ts"],"names":[],"mappings":"AAmCA;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,OAAkC;IAAlC,wBAAA,EAAA,YAAkC;IAElC,OAAO;QACL,aAAa,EACX,OAAO,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QAC7D,aAAa,EAAE,OAAO,CAAC,aAAa,KAAK,KAAK;QAC9C,QAAQ,EAAE,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM;KAC5D,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AcPdfTextFontResolver } from '@mlightcad/pdf-renderer';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves embeddable TTF/OTF/WOFF font programs for `textMode: 'text'` PDF
|
|
4
|
+
* exports from the viewer font catalog.
|
|
5
|
+
*
|
|
6
|
+
* Lookup mirrors on-screen text rendering: direct catalog hit first, then the
|
|
7
|
+
* font manager's replacement chain (`getReplacementFontName`) for style fonts
|
|
8
|
+
* the catalog does not list ("Standard", localized aliases like "标准", …).
|
|
9
|
+
* Only a catalog *miss* falls through to the replacement — a direct SHX hit
|
|
10
|
+
* stays SHX so those texts keep their vector-glyph appearance in the PDF.
|
|
11
|
+
*
|
|
12
|
+
* The catalog entry's `url` is fetched on demand; bytes are not kept between
|
|
13
|
+
* calls beyond pdf-lib's own embed cache, so a document using several CJK
|
|
14
|
+
* faces embeds each subset once regardless of how many texts reference it.
|
|
15
|
+
*
|
|
16
|
+
* SHX fonts have no embeddable program and resolve `undefined` — the renderer
|
|
17
|
+
* then paints those texts as vector glyphs, matching the on-screen fallback.
|
|
18
|
+
*/
|
|
19
|
+
export declare const resolveViewerTextFont: AcPdfTextFontResolver;
|
|
20
|
+
//# sourceMappingURL=AcApPdfFontResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcApPdfFontResolver.d.ts","sourceRoot":"","sources":["../src/AcApPdfFontResolver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAEpE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,qBAAqB,EAAE,qBA+BnC,CAAA"}
|