@mlightcad/cad-pdf-plugin 1.5.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.
Files changed (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +157 -0
  3. package/dist/AcApPdfPlugin-CXWCd8bg.js +34 -0
  4. package/dist/html2canvas.esm-d2sM-0Wm.js +4870 -0
  5. package/dist/index-DNe5YnrC.js +30983 -0
  6. package/dist/index.es-DxTvd7sT.js +5645 -0
  7. package/dist/index.js +11 -0
  8. package/dist/index.umd.cjs +312 -0
  9. package/dist/purify.es-CxNDhYDZ.js +663 -0
  10. package/lib/AcApConvertToPdfCmd.d.ts +14 -0
  11. package/lib/AcApConvertToPdfCmd.d.ts.map +1 -0
  12. package/lib/AcApConvertToPdfCmd.js +86 -0
  13. package/lib/AcApConvertToPdfCmd.js.map +1 -0
  14. package/lib/AcApImportPdfCmd.d.ts +14 -0
  15. package/lib/AcApImportPdfCmd.d.ts.map +1 -0
  16. package/lib/AcApImportPdfCmd.js +81 -0
  17. package/lib/AcApImportPdfCmd.js.map +1 -0
  18. package/lib/AcApPdfConvertor.d.ts +17 -0
  19. package/lib/AcApPdfConvertor.d.ts.map +1 -0
  20. package/lib/AcApPdfConvertor.js +155 -0
  21. package/lib/AcApPdfConvertor.js.map +1 -0
  22. package/lib/AcApPdfImportConvertor.d.ts +23 -0
  23. package/lib/AcApPdfImportConvertor.d.ts.map +1 -0
  24. package/lib/AcApPdfImportConvertor.js +363 -0
  25. package/lib/AcApPdfImportConvertor.js.map +1 -0
  26. package/lib/AcApPdfPlugin.d.ts +32 -0
  27. package/lib/AcApPdfPlugin.d.ts.map +1 -0
  28. package/lib/AcApPdfPlugin.js +70 -0
  29. package/lib/AcApPdfPlugin.js.map +1 -0
  30. package/lib/index.d.ts +11 -0
  31. package/lib/index.d.ts.map +1 -0
  32. package/lib/index.js +11 -0
  33. package/lib/index.js.map +1 -0
  34. package/lib/registerLazyPdfPlugin.d.ts +25 -0
  35. package/lib/registerLazyPdfPlugin.d.ts.map +1 -0
  36. package/lib/registerLazyPdfPlugin.js +103 -0
  37. package/lib/registerLazyPdfPlugin.js.map +1 -0
  38. package/package.json +47 -0
@@ -0,0 +1,14 @@
1
+ import { AcApContext, AcEdCommand } from '@mlightcad/cad-simple-viewer';
2
+ /**
3
+ * Command for converting the current CAD drawing to PDF format.
4
+ * The command name is `cpdf`.
5
+ */
6
+ export declare class AcApConvertToPdfCmd extends AcEdCommand {
7
+ /**
8
+ * Renders the current drawing to PDF and downloads it in the browser.
9
+ *
10
+ * @param context - Application context for the active document
11
+ */
12
+ execute(context: AcApContext): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=AcApConvertToPdfCmd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcApConvertToPdfCmd.d.ts","sourceRoot":"","sources":["../src/AcApConvertToPdfCmd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAIvE;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IAClD;;;;OAIG;IACG,OAAO,CAAC,OAAO,EAAE,WAAW;CAInC"}
@@ -0,0 +1,86 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ var __generator = (this && this.__generator) || function (thisArg, body) {
26
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
27
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
+ function verb(n) { return function (v) { return step([n, v]); }; }
29
+ function step(op) {
30
+ if (f) throw new TypeError("Generator is already executing.");
31
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
32
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
33
+ if (y = 0, t) op = [op[0] & 2, t.value];
34
+ switch (op[0]) {
35
+ case 0: case 1: t = op; break;
36
+ case 4: _.label++; return { value: op[1], done: false };
37
+ case 5: _.label++; y = op[1]; op = [0]; continue;
38
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
+ default:
40
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
+ if (t[2]) _.ops.pop();
45
+ _.trys.pop(); continue;
46
+ }
47
+ op = body.call(thisArg, _);
48
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
+ }
51
+ };
52
+ import { AcEdCommand } from '@mlightcad/cad-simple-viewer';
53
+ import { AcApPdfConvertor } from './AcApPdfConvertor';
54
+ /**
55
+ * Command for converting the current CAD drawing to PDF format.
56
+ * The command name is `cpdf`.
57
+ */
58
+ var AcApConvertToPdfCmd = /** @class */ (function (_super) {
59
+ __extends(AcApConvertToPdfCmd, _super);
60
+ function AcApConvertToPdfCmd() {
61
+ return _super !== null && _super.apply(this, arguments) || this;
62
+ }
63
+ /**
64
+ * Renders the current drawing to PDF and downloads it in the browser.
65
+ *
66
+ * @param context - Application context for the active document
67
+ */
68
+ AcApConvertToPdfCmd.prototype.execute = function (context) {
69
+ return __awaiter(this, void 0, void 0, function () {
70
+ var converter;
71
+ return __generator(this, function (_a) {
72
+ switch (_a.label) {
73
+ case 0:
74
+ converter = new AcApPdfConvertor();
75
+ return [4 /*yield*/, converter.convert(context)];
76
+ case 1:
77
+ _a.sent();
78
+ return [2 /*return*/];
79
+ }
80
+ });
81
+ });
82
+ };
83
+ return AcApConvertToPdfCmd;
84
+ }(AcEdCommand));
85
+ export { AcApConvertToPdfCmd };
86
+ //# sourceMappingURL=AcApConvertToPdfCmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcApConvertToPdfCmd.js","sourceRoot":"","sources":["../src/AcApConvertToPdfCmd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAEvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD;;;GAGG;AACH;IAAyC,uCAAW;IAApD;;IAUA,CAAC;IATC;;;;OAIG;IACG,qCAAO,GAAb,UAAc,OAAoB;;;;;;wBAC1B,SAAS,GAAG,IAAI,gBAAgB,EAAE,CAAA;wBACxC,qBAAM,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,EAAA;;wBAAhC,SAAgC,CAAA;;;;;KACjC;IACH,0BAAC;AAAD,CAAC,AAVD,CAAyC,WAAW,GAUnD"}
@@ -0,0 +1,14 @@
1
+ import { AcApContext, AcEdCommand } from '@mlightcad/cad-simple-viewer';
2
+ /**
3
+ * Command for importing vector geometry from a PDF file.
4
+ * The command name is `ipdf`.
5
+ */
6
+ export declare class AcApImportPdfCmd extends AcEdCommand {
7
+ /**
8
+ * Opens a file picker and imports vector geometry from the selected PDF.
9
+ *
10
+ * @param context - Application context for the target document
11
+ */
12
+ execute(context: AcApContext): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=AcApImportPdfCmd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcApImportPdfCmd.d.ts","sourceRoot":"","sources":["../src/AcApImportPdfCmd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAIvE;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C;;;;OAIG;IACG,OAAO,CAAC,OAAO,EAAE,WAAW;CAInC"}
@@ -0,0 +1,81 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ var __generator = (this && this.__generator) || function (thisArg, body) {
26
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
27
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
+ function verb(n) { return function (v) { return step([n, v]); }; }
29
+ function step(op) {
30
+ if (f) throw new TypeError("Generator is already executing.");
31
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
32
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
33
+ if (y = 0, t) op = [op[0] & 2, t.value];
34
+ switch (op[0]) {
35
+ case 0: case 1: t = op; break;
36
+ case 4: _.label++; return { value: op[1], done: false };
37
+ case 5: _.label++; y = op[1]; op = [0]; continue;
38
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
+ default:
40
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
+ if (t[2]) _.ops.pop();
45
+ _.trys.pop(); continue;
46
+ }
47
+ op = body.call(thisArg, _);
48
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
+ }
51
+ };
52
+ import { AcEdCommand } from '@mlightcad/cad-simple-viewer';
53
+ import { AcApPdfImportConvertor } from './AcApPdfImportConvertor';
54
+ /**
55
+ * Command for importing vector geometry from a PDF file.
56
+ * The command name is `ipdf`.
57
+ */
58
+ var AcApImportPdfCmd = /** @class */ (function (_super) {
59
+ __extends(AcApImportPdfCmd, _super);
60
+ function AcApImportPdfCmd() {
61
+ return _super !== null && _super.apply(this, arguments) || this;
62
+ }
63
+ /**
64
+ * Opens a file picker and imports vector geometry from the selected PDF.
65
+ *
66
+ * @param context - Application context for the target document
67
+ */
68
+ AcApImportPdfCmd.prototype.execute = function (context) {
69
+ return __awaiter(this, void 0, void 0, function () {
70
+ var convertor;
71
+ return __generator(this, function (_a) {
72
+ convertor = new AcApPdfImportConvertor();
73
+ convertor.importFromFilePicker(context);
74
+ return [2 /*return*/];
75
+ });
76
+ });
77
+ };
78
+ return AcApImportPdfCmd;
79
+ }(AcEdCommand));
80
+ export { AcApImportPdfCmd };
81
+ //# sourceMappingURL=AcApImportPdfCmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcApImportPdfCmd.js","sourceRoot":"","sources":["../src/AcApImportPdfCmd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAEvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAEjE;;;GAGG;AACH;IAAsC,oCAAW;IAAjD;;IAUA,CAAC;IATC;;;;OAIG;IACG,kCAAO,GAAb,UAAc,OAAoB;;;;gBAC1B,SAAS,GAAG,IAAI,sBAAsB,EAAE,CAAA;gBAC9C,SAAS,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;;;;KACxC;IACH,uBAAC;AAAD,CAAC,AAVD,CAAsC,WAAW,GAUhD"}
@@ -0,0 +1,17 @@
1
+ import type { AcApContext } from '@mlightcad/cad-simple-viewer';
2
+ /**
3
+ * Utility class for converting CAD drawings to PDF format.
4
+ *
5
+ * Reuses the SVG renderer pipeline and converts the resulting SVG to a
6
+ * vector PDF using jsPDF + svg2pdf.js.
7
+ */
8
+ export declare class AcApPdfConvertor {
9
+ /**
10
+ * Renders the current drawing to PDF and triggers a browser download.
11
+ */
12
+ convert(context: AcApContext): Promise<void>;
13
+ private buildSvg;
14
+ private configureRenderer;
15
+ private downloadAsPdf;
16
+ }
17
+ //# sourceMappingURL=AcApPdfConvertor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcApPdfConvertor.d.ts","sourceRoot":"","sources":["../src/AcApPdfConvertor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAS/D;;;;;GAKG;AACH,qBAAa,gBAAgB;IAC3B;;OAEG;IACG,OAAO,CAAC,OAAO,EAAE,WAAW;YASpB,QAAQ;IActB,OAAO,CAAC,iBAAiB;YAaX,aAAa;CA0B5B"}
@@ -0,0 +1,155 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ var __values = (this && this.__values) || function(o) {
38
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
39
+ if (m) return m.call(o);
40
+ if (o && typeof o.length === "number") return {
41
+ next: function () {
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';
52
+ /**
53
+ * Utility class for converting CAD drawings to PDF format.
54
+ *
55
+ * Reuses the SVG renderer pipeline and converts the resulting SVG to a
56
+ * vector PDF using jsPDF + svg2pdf.js.
57
+ */
58
+ var AcApPdfConvertor = /** @class */ (function () {
59
+ function AcApPdfConvertor() {
60
+ }
61
+ /**
62
+ * Renders the current drawing to PDF and triggers a browser download.
63
+ */
64
+ AcApPdfConvertor.prototype.convert = function (context) {
65
+ return __awaiter(this, void 0, void 0, function () {
66
+ var svgString, downloadName;
67
+ return __generator(this, function (_a) {
68
+ switch (_a.label) {
69
+ case 0: return [4 /*yield*/, this.buildSvg(context)];
70
+ 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
+ _a.sent();
76
+ return [2 /*return*/];
77
+ }
78
+ });
79
+ });
80
+ };
81
+ AcApPdfConvertor.prototype.buildSvg = function (context) {
82
+ return __awaiter(this, void 0, void 0, function () {
83
+ var entities, renderer, entities_1, entities_1_1, entity;
84
+ var e_1, _a;
85
+ return __generator(this, function (_b) {
86
+ AcSvgRenderer.prepareExport();
87
+ entities = context.doc.database.tables.blockTable.modelSpace.newIterator();
88
+ renderer = new AcSvgRenderer();
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
+ });
105
+ });
106
+ };
107
+ AcApPdfConvertor.prototype.configureRenderer = function (renderer, context) {
108
+ var _a;
109
+ var db = context.doc.database;
110
+ renderer.ltscale = db.ltscale;
111
+ renderer.celtscale = db.celtscale;
112
+ renderer.showLineWeight = !!db.lwdisplay;
113
+ renderer.setFontMapping(AcApSettingManager.instance.fontMapping);
114
+ var view = context.view;
115
+ var bg = (_a = view === null || view === void 0 ? void 0 : view.backgroundColor) !== null && _a !== void 0 ? _a : 0xffffff;
116
+ renderer.currentBackgroundColor = bg;
117
+ renderer.changeForeground(bg === 0 ? 0xffffff : 0x000000);
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
+ });
151
+ };
152
+ return AcApPdfConvertor;
153
+ }());
154
+ export { AcApPdfConvertor };
155
+ //# sourceMappingURL=AcApPdfConvertor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcApPdfConvertor.js","sourceRoot":"","sources":["../src/AcApPdfConvertor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EAC1B,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC;;;;;GAKG;AACH;IAAA;IAkEA,CAAC;IAjEC;;OAEG;IACG,kCAAO,GAAb,UAAc,OAAoB;;;;;4BACd,qBAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAA;;wBAAxC,SAAS,GAAG,SAA4B;wBACxC,YAAY,GAAG,yBAAyB,CAC5C,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,EAC5C,KAAK,CACN,CAAA;wBACD,qBAAM,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,YAAY,CAAC,EAAA;;wBAAjD,SAAiD,CAAA;;;;;KAClD;IAEa,mCAAQ,GAAtB,UAAuB,OAAoB;;;;;gBACzC,aAAa,CAAC,aAAa,EAAE,CAAA;gBAEvB,QAAQ,GACZ,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,EAAE,CAAA;gBAC3D,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAA;gBACpC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;;oBAEzC,KAAqB,aAAA,SAAA,QAAQ,CAAA,0FAAE,CAAC;wBAArB,MAAM;wBACf,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;oBAC5B,CAAC;;;;;;;;;gBACD,sBAAO,QAAQ,CAAC,WAAW,EAAE,EAAA;;;KAC9B;IAEO,4CAAiB,GAAzB,UAA0B,QAAuB,EAAE,OAAoB;;QACrE,IAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAA;QAC/B,QAAQ,CAAC,OAAO,GAAG,EAAE,CAAC,OAAO,CAAA;QAC7B,QAAQ,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,CAAA;QACjC,QAAQ,CAAC,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,SAAS,CAAA;QACxC,QAAQ,CAAC,cAAc,CAAC,kBAAkB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;QAEhE,IAAM,IAAI,GAAG,OAAO,CAAC,IAAgD,CAAA;QACrE,IAAM,EAAE,GAAG,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,eAAe,mCAAI,QAAQ,CAAA;QAC5C,QAAQ,CAAC,sBAAsB,GAAG,EAAE,CAAA;QACpC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;IAC3D,CAAC;IAEa,wCAAa,GAA3B,UAA4B,SAAiB,EAAE,YAAoB;;;;;;;wBAC3D,MAAM,GAAG,IAAI,SAAS,EAAE,CAAA;wBACxB,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,SAAS,EAAE,eAAe,CAAC,CAAA;wBAC3D,KAAK,GAAG,MAAM,CAAC,eAA2C,CAAA;wBAE1D,EAAE,GAAG,MAAA,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,0CAAE,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;wBAC1D,OAAO,GAAG,EAAE,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;wBACvD,QAAQ,GAAG,EAAE,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;wBAExD,WAAW,GAAG,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAA;wBAE5D,GAAG,GAAG,IAAI,KAAK,CAAC;4BACpB,WAAW,aAAA;4BACX,IAAI,EAAE,IAAI;4BACV,MAAM,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;yBAC5B,CAAC,CAAA;wBAEF,qBAAM,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE;gCACxB,CAAC,EAAE,CAAC;gCACJ,CAAC,EAAE,CAAC;gCACJ,KAAK,EAAE,OAAO;gCACd,MAAM,EAAE,QAAQ;6BACjB,CAAC,EAAA;;wBALF,SAKE,CAAA;wBAEF,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;;;;;KACvB;IACH,uBAAC;AAAD,CAAC,AAlED,IAkEC"}
@@ -0,0 +1,23 @@
1
+ import type { AcApContext } from '@mlightcad/cad-simple-viewer';
2
+ /**
3
+ * Converts a PDF file into CAD entities appended to the current document's
4
+ * model space.
5
+ */
6
+ export declare class AcApPdfImportConvertor {
7
+ /**
8
+ * Prompts the user to pick a PDF file and imports vector geometry.
9
+ *
10
+ * @param context - Application context for the target document
11
+ */
12
+ importFromFilePicker(context: AcApContext): void;
13
+ /**
14
+ * Converts the first page of a PDF ArrayBuffer into CAD entities.
15
+ * @param context - Application context for the target document
16
+ * @param data - Raw PDF bytes
17
+ * @param pageNumber - 1-based page number (default: 1)
18
+ */
19
+ convert(context: AcApContext, data: ArrayBuffer, pageNumber?: number): Promise<void>;
20
+ private extractEntities;
21
+ private subpathToEntity;
22
+ }
23
+ //# sourceMappingURL=AcApPdfImportConvertor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcApPdfImportConvertor.d.ts","sourceRoot":"","sources":["../src/AcApPdfImportConvertor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAsB/D;;;GAGG;AACH,qBAAa,sBAAsB;IACjC;;;;OAIG;IACH,oBAAoB,CAAC,OAAO,EAAE,WAAW;IAkBzC;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,SAAI;IA2BrE,OAAO,CAAC,eAAe;IAuHvB,OAAO,CAAC,eAAe;CAyBxB"}