@mlightcad/cad-pdf-plugin 1.8.0-preview.2 → 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.
Files changed (189) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +280 -186
  3. package/dist/cad-pdf-plugin-register.js +29 -11
  4. package/dist/cad-pdf-plugin-register.umd.cjs +1 -1
  5. package/dist/cad-pdf-plugin.js +17568 -8428
  6. package/dist/cad-pdf-plugin.umd.cjs +847 -13
  7. package/lib/AcApConvertToPdfCmd.d.ts.map +1 -1
  8. package/lib/AcApConvertToPdfCmd.js +14 -3
  9. package/lib/AcApConvertToPdfCmd.js.map +1 -1
  10. package/lib/AcApImportPdfCmd.d.ts +5 -3
  11. package/lib/AcApImportPdfCmd.d.ts.map +1 -1
  12. package/lib/AcApImportPdfCmd.js +5 -3
  13. package/lib/AcApImportPdfCmd.js.map +1 -1
  14. package/lib/AcApImportPdfPromptCmd.d.ts +16 -0
  15. package/lib/AcApImportPdfPromptCmd.d.ts.map +1 -0
  16. package/lib/AcApImportPdfPromptCmd.js +89 -0
  17. package/lib/AcApImportPdfPromptCmd.js.map +1 -0
  18. package/lib/AcApPdfBlockCmd.d.ts +15 -0
  19. package/lib/AcApPdfBlockCmd.d.ts.map +1 -0
  20. package/lib/AcApPdfBlockCmd.js +75 -0
  21. package/lib/AcApPdfBlockCmd.js.map +1 -0
  22. package/lib/AcApPdfDimCmd.d.ts +20 -0
  23. package/lib/AcApPdfDimCmd.d.ts.map +1 -0
  24. package/lib/AcApPdfDimCmd.js +413 -0
  25. package/lib/AcApPdfDimCmd.js.map +1 -0
  26. package/lib/AcApPdfDimSession.d.ts +82 -0
  27. package/lib/AcApPdfDimSession.d.ts.map +1 -0
  28. package/lib/AcApPdfDimSession.js +252 -0
  29. package/lib/AcApPdfDimSession.js.map +1 -0
  30. package/lib/AcApPdfFontResolver.d.ts.map +1 -1
  31. package/lib/AcApPdfFontResolver.js +2 -5
  32. package/lib/AcApPdfFontResolver.js.map +1 -1
  33. package/lib/AcApPdfHatchCmd.d.ts +33 -0
  34. package/lib/AcApPdfHatchCmd.d.ts.map +1 -0
  35. package/lib/AcApPdfHatchCmd.js +411 -0
  36. package/lib/AcApPdfHatchCmd.js.map +1 -0
  37. package/lib/AcApPdfHatchSession.d.ts +122 -0
  38. package/lib/AcApPdfHatchSession.d.ts.map +1 -0
  39. package/lib/AcApPdfHatchSession.js +357 -0
  40. package/lib/AcApPdfHatchSession.js.map +1 -0
  41. package/lib/AcApPdfImportConvertor.d.ts +47 -5
  42. package/lib/AcApPdfImportConvertor.d.ts.map +1 -1
  43. package/lib/AcApPdfImportConvertor.js +999 -108
  44. package/lib/AcApPdfImportConvertor.js.map +1 -1
  45. package/lib/AcApPdfImportOptions.d.ts +116 -0
  46. package/lib/AcApPdfImportOptions.d.ts.map +1 -0
  47. package/lib/AcApPdfImportOptions.js +31 -0
  48. package/lib/AcApPdfImportOptions.js.map +1 -0
  49. package/lib/AcApPdfImportResources.d.ts +41 -0
  50. package/lib/AcApPdfImportResources.d.ts.map +1 -0
  51. package/lib/AcApPdfImportResources.js +52 -0
  52. package/lib/AcApPdfImportResources.js.map +1 -0
  53. package/lib/AcApPdfPlugin.d.ts +3 -3
  54. package/lib/AcApPdfPlugin.d.ts.map +1 -1
  55. package/lib/AcApPdfPlugin.js +23 -5
  56. package/lib/AcApPdfPlugin.js.map +1 -1
  57. package/lib/AcApPdfScaleCmd.d.ts +22 -0
  58. package/lib/AcApPdfScaleCmd.d.ts.map +1 -0
  59. package/lib/AcApPdfScaleCmd.js +185 -0
  60. package/lib/AcApPdfScaleCmd.js.map +1 -0
  61. package/lib/AcApPdfTextCmd.d.ts +73 -0
  62. package/lib/AcApPdfTextCmd.d.ts.map +1 -0
  63. package/lib/AcApPdfTextCmd.js +777 -0
  64. package/lib/AcApPdfTextCmd.js.map +1 -0
  65. package/lib/AcApPdfTextSession.d.ts +232 -0
  66. package/lib/AcApPdfTextSession.d.ts.map +1 -0
  67. package/lib/AcApPdfTextSession.js +826 -0
  68. package/lib/AcApPdfTextSession.js.map +1 -0
  69. package/lib/acapPdfI18n.d.ts +11 -0
  70. package/lib/acapPdfI18n.d.ts.map +1 -0
  71. package/lib/acapPdfI18n.js +57 -0
  72. package/lib/acapPdfI18n.js.map +1 -0
  73. package/lib/acapPdfPrompts.d.ts +12 -0
  74. package/lib/acapPdfPrompts.d.ts.map +1 -0
  75. package/lib/acapPdfPrompts.js +100 -0
  76. package/lib/acapPdfPrompts.js.map +1 -0
  77. package/lib/index.d.ts +28 -0
  78. package/lib/index.d.ts.map +1 -1
  79. package/lib/index.js +28 -0
  80. package/lib/index.js.map +1 -1
  81. package/lib/pdfDeprecatedMatching.d.ts +27 -0
  82. package/lib/pdfDeprecatedMatching.d.ts.map +1 -0
  83. package/lib/pdfDeprecatedMatching.js +20 -0
  84. package/lib/pdfDeprecatedMatching.js.map +1 -0
  85. package/lib/pdfDimStrokeTexts.d.ts +55 -0
  86. package/lib/pdfDimStrokeTexts.d.ts.map +1 -0
  87. package/lib/pdfDimStrokeTexts.js +274 -0
  88. package/lib/pdfDimStrokeTexts.js.map +1 -0
  89. package/lib/pdfDimensionConvert.d.ts +80 -0
  90. package/lib/pdfDimensionConvert.d.ts.map +1 -0
  91. package/lib/pdfDimensionConvert.js +566 -0
  92. package/lib/pdfDimensionConvert.js.map +1 -0
  93. package/lib/pdfEntityStrokes.d.ts +13 -0
  94. package/lib/pdfEntityStrokes.d.ts.map +1 -0
  95. package/lib/pdfEntityStrokes.js +86 -0
  96. package/lib/pdfEntityStrokes.js.map +1 -0
  97. package/lib/pdfHatchRecover.d.ts +57 -0
  98. package/lib/pdfHatchRecover.d.ts.map +1 -0
  99. package/lib/pdfHatchRecover.js +315 -0
  100. package/lib/pdfHatchRecover.js.map +1 -0
  101. package/lib/pdfImportAppend.d.ts +24 -0
  102. package/lib/pdfImportAppend.d.ts.map +1 -0
  103. package/lib/pdfImportAppend.js +35 -0
  104. package/lib/pdfImportAppend.js.map +1 -0
  105. package/lib/pdfImportEntities.d.ts +63 -0
  106. package/lib/pdfImportEntities.d.ts.map +1 -0
  107. package/lib/pdfImportEntities.js +307 -0
  108. package/lib/pdfImportEntities.js.map +1 -0
  109. package/lib/pdfImportImages.d.ts +90 -0
  110. package/lib/pdfImportImages.d.ts.map +1 -0
  111. package/lib/pdfImportImages.js +294 -0
  112. package/lib/pdfImportImages.js.map +1 -0
  113. package/lib/pdfImportShapes.d.ts +63 -0
  114. package/lib/pdfImportShapes.d.ts.map +1 -0
  115. package/lib/pdfImportShapes.js +248 -0
  116. package/lib/pdfImportShapes.js.map +1 -0
  117. package/lib/pdfVectorImport.d.ts +218 -5
  118. package/lib/pdfVectorImport.d.ts.map +1 -1
  119. package/lib/pdfVectorImport.js +566 -98
  120. package/lib/pdfVectorImport.js.map +1 -1
  121. package/lib/recognition/pdfCurveRecognition.d.ts +91 -0
  122. package/lib/recognition/pdfCurveRecognition.d.ts.map +1 -0
  123. package/lib/recognition/pdfCurveRecognition.js +506 -0
  124. package/lib/recognition/pdfCurveRecognition.js.map +1 -0
  125. package/lib/recognition/pdfDimDigitRecognition.d.ts +18 -0
  126. package/lib/recognition/pdfDimDigitRecognition.d.ts.map +1 -0
  127. package/lib/recognition/pdfDimDigitRecognition.js +520 -0
  128. package/lib/recognition/pdfDimDigitRecognition.js.map +1 -0
  129. package/lib/recognition/pdfDimensionPattern.d.ts +173 -0
  130. package/lib/recognition/pdfDimensionPattern.d.ts.map +1 -0
  131. package/lib/recognition/pdfDimensionPattern.js +1023 -0
  132. package/lib/recognition/pdfDimensionPattern.js.map +1 -0
  133. package/lib/recognition/pdfFormBlocks.d.ts +58 -0
  134. package/lib/recognition/pdfFormBlocks.d.ts.map +1 -0
  135. package/lib/recognition/pdfFormBlocks.js +260 -0
  136. package/lib/recognition/pdfFormBlocks.js.map +1 -0
  137. package/lib/recognition/pdfGlyphClustering.d.ts +81 -0
  138. package/lib/recognition/pdfGlyphClustering.d.ts.map +1 -0
  139. package/lib/recognition/pdfGlyphClustering.js +1005 -0
  140. package/lib/recognition/pdfGlyphClustering.js.map +1 -0
  141. package/lib/recognition/pdfGlyphDictionary.d.ts +49 -0
  142. package/lib/recognition/pdfGlyphDictionary.d.ts.map +1 -0
  143. package/lib/recognition/pdfGlyphDictionary.js +188 -0
  144. package/lib/recognition/pdfGlyphDictionary.js.map +1 -0
  145. package/lib/recognition/pdfHatchFaces.d.ts +84 -0
  146. package/lib/recognition/pdfHatchFaces.d.ts.map +1 -0
  147. package/lib/recognition/pdfHatchFaces.js +1285 -0
  148. package/lib/recognition/pdfHatchFaces.js.map +1 -0
  149. package/lib/recognition/pdfHatchRecognition.d.ts +222 -0
  150. package/lib/recognition/pdfHatchRecognition.d.ts.map +1 -0
  151. package/lib/recognition/pdfHatchRecognition.js +3781 -0
  152. package/lib/recognition/pdfHatchRecognition.js.map +1 -0
  153. package/lib/recognition/pdfRecGeometry.d.ts +67 -0
  154. package/lib/recognition/pdfRecGeometry.d.ts.map +1 -0
  155. package/lib/recognition/pdfRecGeometry.js +365 -0
  156. package/lib/recognition/pdfRecGeometry.js.map +1 -0
  157. package/lib/recognition/pdfTextFontKind.d.ts +16 -0
  158. package/lib/recognition/pdfTextFontKind.d.ts.map +1 -0
  159. package/lib/recognition/pdfTextFontKind.js +51 -0
  160. package/lib/recognition/pdfTextFontKind.js.map +1 -0
  161. package/lib/recognition/pdfTextMerge.d.ts +71 -0
  162. package/lib/recognition/pdfTextMerge.d.ts.map +1 -0
  163. package/lib/recognition/pdfTextMerge.js +382 -0
  164. package/lib/recognition/pdfTextMerge.js.map +1 -0
  165. package/lib/recognition/pdfTextRunMerge.d.ts +28 -0
  166. package/lib/recognition/pdfTextRunMerge.d.ts.map +1 -0
  167. package/lib/recognition/pdfTextRunMerge.js +90 -0
  168. package/lib/recognition/pdfTextRunMerge.js.map +1 -0
  169. package/lib/register.d.ts +8 -2
  170. package/lib/register.d.ts.map +1 -1
  171. package/lib/register.js +29 -4
  172. package/lib/register.js.map +1 -1
  173. package/lib/ui/AcUiPdfDimPanel.d.ts +55 -0
  174. package/lib/ui/AcUiPdfDimPanel.d.ts.map +1 -0
  175. package/lib/ui/AcUiPdfDimPanel.js +347 -0
  176. package/lib/ui/AcUiPdfDimPanel.js.map +1 -0
  177. package/lib/ui/AcUiPdfHatchPanel.d.ts +57 -0
  178. package/lib/ui/AcUiPdfHatchPanel.d.ts.map +1 -0
  179. package/lib/ui/AcUiPdfHatchPanel.js +420 -0
  180. package/lib/ui/AcUiPdfHatchPanel.js.map +1 -0
  181. package/lib/ui/AcUiPdfImportDialog.d.ts +120 -0
  182. package/lib/ui/AcUiPdfImportDialog.d.ts.map +1 -0
  183. package/lib/ui/AcUiPdfImportDialog.js +673 -0
  184. package/lib/ui/AcUiPdfImportDialog.js.map +1 -0
  185. package/lib/ui/AcUiPdfTextPanel.d.ts +95 -0
  186. package/lib/ui/AcUiPdfTextPanel.d.ts.map +1 -0
  187. package/lib/ui/AcUiPdfTextPanel.js +775 -0
  188. package/lib/ui/AcUiPdfTextPanel.js.map +1 -0
  189. package/package.json +11 -11
@@ -0,0 +1,185 @@
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 { AcApDocManager, AcApI18n, AcEdCommand, AcEdOpenMode, AcEdPromptDoubleOptions, AcEdPromptPointOptions, AcEdPromptStatus, resolveSelectedEntities } from '@mlightcad/cad-simple-viewer';
53
+ import { AcGeMatrix3d, AcGePoint3d } from '@mlightcad/data-model';
54
+ import { acapPdfT } from './acapPdfI18n';
55
+ import { AcApPdfTextCmd } from './AcApPdfTextCmd';
56
+ import { acapPdfNiceScale, pdfEntitiesToDimInput } from './pdfDimensionConvert';
57
+ import { acapPdfPrepareDimStrokeTexts } from './pdfDimStrokeTexts';
58
+ import { recognizePdfDimensions, suggestPdfDimensionScale } from './recognition/pdfDimensionPattern';
59
+ /**
60
+ * `pdfscale`: calibrates imported PDF geometry to real-world units.
61
+ *
62
+ * PDF drawings are usually printed at a scale (1:50, 1:100, ...), so a
63
+ * 1 pt = 25.4/72 mm import is rarely 1:1. The user picks two points of a
64
+ * known distance (typically the ends of a dimension) and types the true
65
+ * length; the selection is scaled uniformly about the first point. When the
66
+ * selection contains exploded dimensions, the scale their texts imply
67
+ * pre-fills the real length.
68
+ */
69
+ var AcApPdfScaleCmd = /** @class */ (function (_super) {
70
+ __extends(AcApPdfScaleCmd, _super);
71
+ function AcApPdfScaleCmd() {
72
+ var _this = _super.call(this) || this;
73
+ _this.mode = AcEdOpenMode.Write;
74
+ return _this;
75
+ }
76
+ /**
77
+ * Computes the uniform scale factor from a measured and a real length.
78
+ *
79
+ * @returns The factor, or `undefined` when either length is not positive.
80
+ */
81
+ AcApPdfScaleCmd.scaleFactor = function (measured, real) {
82
+ if (!(measured > 0) || !(real > 0))
83
+ return undefined;
84
+ return real / measured;
85
+ };
86
+ AcApPdfScaleCmd.prototype.execute = function (context) {
87
+ return __awaiter(this, void 0, void 0, function () {
88
+ var resolved, editor, byId, dimInput, suggested, dimensionScale, selectionSet, firstPrompt, first, base, secondPrompt, second, measured, lengthPrompt, length, realLength, factor, matrix, count;
89
+ return __generator(this, function (_a) {
90
+ switch (_a.label) {
91
+ case 0: return [4 /*yield*/, resolveSelectedEntities(context, {
92
+ promptKey: 'pdfscale'
93
+ })];
94
+ case 1:
95
+ resolved = _a.sent();
96
+ if (!resolved)
97
+ return [2 /*return*/];
98
+ editor = AcApDocManager.instance.editor;
99
+ byId = new Map(resolved.ids.map(function (id, i) { return [id, resolved.entities[i]]; }));
100
+ dimInput = pdfEntitiesToDimInput(byId);
101
+ acapPdfPrepareDimStrokeTexts(dimInput, byId, AcApPdfTextCmd.glyphDictionary);
102
+ suggested = suggestPdfDimensionScale(recognizePdfDimensions(dimInput));
103
+ dimensionScale = suggested !== undefined ? acapPdfNiceScale(suggested) : undefined;
104
+ selectionSet = context.view.selectionSet;
105
+ firstPrompt = new AcEdPromptPointOptions(AcApI18n.t('jig.pdfscale.firstPoint'));
106
+ return [4 /*yield*/, editor.getPoint(firstPrompt)];
107
+ case 2:
108
+ first = _a.sent();
109
+ if (first.status !== AcEdPromptStatus.OK || !first.value) {
110
+ selectionSet.clear();
111
+ return [2 /*return*/];
112
+ }
113
+ base = new AcGePoint3d(first.value);
114
+ secondPrompt = new AcEdPromptPointOptions(AcApI18n.t('jig.pdfscale.secondPoint'));
115
+ secondPrompt.useBasePoint = true;
116
+ secondPrompt.useDashedLine = true;
117
+ secondPrompt.basePoint = base;
118
+ return [4 /*yield*/, editor.getPoint(secondPrompt)];
119
+ case 3:
120
+ second = _a.sent();
121
+ if (second.status !== AcEdPromptStatus.OK || !second.value) {
122
+ selectionSet.clear();
123
+ return [2 /*return*/];
124
+ }
125
+ measured = Math.hypot(second.value.x - base.x, second.value.y - base.y);
126
+ if (!(measured > 0)) {
127
+ this.notify(AcApI18n.t('jig.pdfscale.zeroDistance'), 'warning');
128
+ selectionSet.clear();
129
+ return [2 /*return*/];
130
+ }
131
+ lengthPrompt = new AcEdPromptDoubleOptions(dimensionScale !== undefined
132
+ ? acapPdfT('jig.pdfscale.realLengthFromDimensions', {
133
+ measured: formatNumber(measured),
134
+ scale: formatNumber(dimensionScale)
135
+ })
136
+ : acapPdfT('jig.pdfscale.realLength', {
137
+ measured: formatNumber(measured)
138
+ }));
139
+ lengthPrompt.allowNegative = false;
140
+ lengthPrompt.allowZero = false;
141
+ if (dimensionScale !== undefined) {
142
+ lengthPrompt.defaultValue = Number((measured * dimensionScale).toPrecision(10));
143
+ lengthPrompt.useDefaultValue = true;
144
+ lengthPrompt.allowNone = true;
145
+ }
146
+ return [4 /*yield*/, editor.getDouble(lengthPrompt)];
147
+ case 4:
148
+ length = _a.sent();
149
+ realLength = length.status === AcEdPromptStatus.OK
150
+ ? length.value
151
+ : length.status === AcEdPromptStatus.None &&
152
+ dimensionScale !== undefined
153
+ ? lengthPrompt.defaultValue
154
+ : undefined;
155
+ if (realLength == null) {
156
+ selectionSet.clear();
157
+ return [2 /*return*/];
158
+ }
159
+ factor = AcApPdfScaleCmd.scaleFactor(measured, realLength);
160
+ if (factor === undefined) {
161
+ selectionSet.clear();
162
+ return [2 /*return*/];
163
+ }
164
+ matrix = new AcGeMatrix3d()
165
+ .makeTranslation(base.x, base.y, base.z)
166
+ .multiply(new AcGeMatrix3d().makeScale(factor, factor, factor))
167
+ .multiply(new AcGeMatrix3d().makeTranslation(-base.x, -base.y, -base.z));
168
+ count = context.doc.entityService.transformEntities(resolved.entities, matrix);
169
+ selectionSet.clear();
170
+ this.notify(acapPdfT('jig.pdfscale.applied', {
171
+ count: count,
172
+ factor: formatNumber(factor)
173
+ }));
174
+ return [2 /*return*/];
175
+ }
176
+ });
177
+ });
178
+ };
179
+ return AcApPdfScaleCmd;
180
+ }(AcEdCommand));
181
+ export { AcApPdfScaleCmd };
182
+ function formatNumber(value) {
183
+ return Number(value.toPrecision(6)).toString();
184
+ }
185
+ //# sourceMappingURL=AcApPdfScaleCmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcApPdfSca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,IAAI,CAAC,MAAM,CACT,QAAQ,CAAC,sBAAsB,EAAE;4BAC/B,KAAK,OAAA;4BACL,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC;yBAC7B,CAAC,CACH,CAAA;;;;;KACF;IACH,sBAAC;AAAD,CAAC,AA7HD,CAAqC,WAAW,GA6H/C;;AAED,SAAS,YAAY,CAAC,KAAa;IACjC,OAAO,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;AAChD,CAAC"}
@@ -0,0 +1,73 @@
1
+ import { type AcApContext, AcEdCommand } from '@mlightcad/cad-simple-viewer';
2
+ import { PdfGlyphDictionary } from './recognition/pdfGlyphDictionary';
3
+ /** `localStorage` key of the persisted glyph dictionary. */
4
+ export declare const PDF_GLYPH_STORAGE_KEY = "mlightcad.pdftext.glyphs.v1";
5
+ /**
6
+ * `pdftext`: converts exploded text (SHX line text or outlined fonts that a
7
+ * PDF stores as paths) back into `AcDbText`.
8
+ *
9
+ * Workflow:
10
+ * 1. The user selects the strokes (a window around the text is enough;
11
+ * frames and other large strokes are ignored).
12
+ * 2. Strokes are clustered into text lines with an estimated position,
13
+ * height and rotation, and each line is classified as SHX line text or
14
+ * TrueType outline text.
15
+ * 3. Lines whose glyphs are all in the glyph dictionary (shapes the user
16
+ * already typed) are read from it.
17
+ * 4. All remaining lines are sent at once to OCR, when a recognizer is
18
+ * registered in {@link AcApTextRecognitionService}.
19
+ * 5. A review panel opens in the palette. Per font kind the user picks an
20
+ * existing text style or creates one, checks or replaces its fonts and
21
+ * adjusts the size; per line the user fixes or types the text. The result
22
+ * is previewed in the drawing. Apply converts everything in one undo step;
23
+ * Cancel, or closing the palette, changes nothing. Without a DOM, what
24
+ * was read is converted directly with the suggested styles.
25
+ *
26
+ * The dictionary is kept in `localStorage` (the 5000 most recently
27
+ * confirmed shapes), so later runs, on this drawing or
28
+ * another one using the same font, recognize more and more lines on their own.
29
+ */
30
+ export declare class AcApPdfTextCmd extends AcEdCommand {
31
+ private static readonly dictionary;
32
+ private static dictionaryLoaded;
33
+ /** Set once the "OCR is off" hint was shown, so it does not nag. */
34
+ private static ocrHintShown;
35
+ /**
36
+ * The shared glyph dictionary, loaded from `localStorage` on first use so
37
+ * glyphs taught in earlier sessions are recognized too.
38
+ */
39
+ static get glyphDictionary(): PdfGlyphDictionary;
40
+ private static saveDictionary;
41
+ /** Set once an OCR failure was reported in this run, so it does not nag. */
42
+ private ocrErrorShown;
43
+ constructor();
44
+ execute(context: AcApContext): Promise<void>;
45
+ /**
46
+ * Shows the review panel in the palette and previews the result in the
47
+ * drawing until the user applies or cancels.
48
+ *
49
+ * @returns Whether the user applied.
50
+ */
51
+ private review;
52
+ /**
53
+ * Sends every line `texts` has no entry for to OCR in one batch, behind the
54
+ * busy indicator, and fills `texts` in place.
55
+ *
56
+ * OCR answers are not taught to the glyph dictionary: only text the user
57
+ * typed is trusted to recognize other drawings.
58
+ *
59
+ * @returns How many lines OCR read.
60
+ */
61
+ private recognizeAll;
62
+ /**
63
+ * Tells the user once per session how to turn on OCR suggestions when the
64
+ * shared AI model settings report no image-capable model.
65
+ */
66
+ private hintWhenOcrUnavailable;
67
+ /**
68
+ * Tells the user, once per run, why no suggestion came (bad API key,
69
+ * network, quota, ...) instead of leaving unexplained unread lines.
70
+ */
71
+ private reportOcrError;
72
+ }
73
+ //# sourceMappingURL=AcApPdfTextCmd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcApPdfTextCmd.d.ts","sourceRoot":"","sources":["../src/AcApPdfTextCmd.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAQhB,WAAW,EAGZ,MAAM,8BAA8B,CAAA;AAqBrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAOrE,4DAA4D;AAC5D,eAAO,MAAM,qBAAqB,gCAAgC,CAAA;AAiBlE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,cAAe,SAAQ,WAAW;IAC7C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAA2B;IAC7D,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAQ;IACvC,oEAAoE;IACpE,OAAO,CAAC,MAAM,CAAC,YAAY,CAAQ;IAEnC;;;OAGG;IACH,MAAM,KAAK,eAAe,IAAI,kBAAkB,CAW/C;IAED,OAAO,CAAC,MAAM,CAAC,cAAc;IAa7B,4EAA4E;IAC5E,OAAO,CAAC,aAAa,CAAQ;;IAOvB,OAAO,CAAC,OAAO,EAAE,WAAW;IAkGlC;;;;;OAKG;YACW,MAAM;IAiHpB;;;;;;;;OAQG;YACW,YAAY;IAiC1B;;;OAGG;YACW,sBAAsB;IAQpC;;;OAGG;IACH,OAAO,CAAC,cAAc;CASvB"}