@yudaocode/univer-pdfs 1.6.217 → 1.6.219

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/lib/es/index.js CHANGED
@@ -19,6 +19,9 @@ import {
19
19
  MultiVariableText,
20
20
  PAGE_SIZE_PRESETS_MM,
21
21
  PDF_PAGE_PRESETS,
22
+ PDF_PASSWORD_PADDING,
23
+ PDF_STANDARD_STAMP_PRESETS,
24
+ PDF_STANDARD_STAMP_PRESET_MAP,
22
25
  PDF_TABLE_THEME_PRESETS,
23
26
  PT_PER_MM,
24
27
  Page,
@@ -29,6 +32,7 @@ import {
29
32
  PdfListKind,
30
33
  PdfListPresetId,
31
34
  PdfRenderError,
35
+ PdfSecurityError,
32
36
  PdfTableBorderStyle,
33
37
  PdfTableCellVerticalAlign,
34
38
  PdfTextAnchor,
@@ -44,7 +48,11 @@ import {
44
48
  Text,
45
49
  UNIVER_PDF_SCHEMA,
46
50
  UNIVER_PDF_SCHEMA_VERSION,
51
+ applyPdfSecurityToDocument,
47
52
  buildMinimalTestTrueTypeFont,
53
+ buildObjectEncryptionKey,
54
+ buildPdfApprovalStampSvg,
55
+ bytesToHex,
48
56
  calculatePdfTableRowCapacity,
49
57
  clearPdfFontUrlCache,
50
58
  cmykToRgb,
@@ -60,13 +68,20 @@ import {
60
68
  computeExifTransformMatrix,
61
69
  computeExpandedTextHeightMm,
62
70
  computeExpandedTextHeightPt,
71
+ computeFileEncryptionKeyFromPadded,
63
72
  computeFontUrlCacheKey,
64
73
  computeImageFitPlacement,
74
+ computeOwnerPasswordValue,
65
75
  computePasteCascadeOffset,
66
76
  computePdfTableSummaryRow,
67
77
  computeSmartSnapWithEqualGap,
78
+ computeUserPasswordValue,
68
79
  createDefaultPdfUnitData,
80
+ createPdfApprovalStampElement,
81
+ createPdfApprovalStampSvgElement,
69
82
  createPdfCjkFontSources,
83
+ decodePdfPermissionFlags,
84
+ decryptPdfBytes,
70
85
  detectCJKCharacters,
71
86
  detectCJKInPdfInputs,
72
87
  detectCJKInPdfTemplate,
@@ -86,35 +101,45 @@ import {
86
101
  encodeJapanPost,
87
102
  encodeNw7,
88
103
  encodePdf417,
104
+ encodePdfPermissionFlags,
89
105
  encodeQrCodeMatrix,
90
106
  encodeUpcA,
91
107
  encodeUpcE,
108
+ encryptPdfBytes,
92
109
  evaluateSafeTemplateExpression,
93
110
  exportBatchPdfBytes,
94
111
  exportCalibrationGridPdfBytes,
95
112
  exportJsxToPdfBytes,
96
113
  exportPdfBytes,
114
+ exportPdfUnitToBytes,
97
115
  exportToPdfmeTemplate,
98
116
  extractAcroFormValuesFromPdfBytes,
99
117
  extractNativeTextSpansFromPdfBytes,
100
118
  extractPdfFormValues,
119
+ extractSvgTextDescriptors,
101
120
  fillPdfFormValues,
102
121
  formatBatesNumber,
103
122
  formatGs1HumanReadable,
104
123
  formatPdfDateTimeValue,
124
+ formatPdfPageIndicesLabel,
105
125
  formatPdfTableCell,
106
126
  fromPdfmeTemplate,
107
127
  getDefaultDateTimeFormat,
128
+ getPdfStandardStampPreset,
108
129
  getTrueTypeMappedCodePoints,
130
+ hexToBytes,
109
131
  importFromPdfmeTemplate,
110
132
  insertPdfPagesBytes,
133
+ inspectPdfEncryption,
111
134
  inspectPdfExportCapabilities,
112
135
  inspectTrueTypeFont,
113
136
  isAspectRatioLockedBarcodeType,
114
137
  isCircleMarkChecked,
115
138
  isExifDimensionsSwapped,
116
139
  isFontUrlSafeToFetch,
140
+ isPdfSecurityActive,
117
141
  mayBeJson,
142
+ md5Bytes,
118
143
  mergePdfBytes,
119
144
  mmToPt,
120
145
  movePdfPageBytes,
@@ -123,6 +148,7 @@ import {
123
148
  normalizeImageCrop,
124
149
  organizePdfBytes,
125
150
  overlayDiagnosticGridOnPdfBytes,
151
+ padPdfPassword,
126
152
  paginatePdfListItems,
127
153
  paginatePdfTableRows,
128
154
  parseGs1ApplicationIdentifiers,
@@ -131,10 +157,12 @@ import {
131
157
  parsePdfColorWithAlpha,
132
158
  parsePdfContentStreamTextOps,
133
159
  parsePdfPageRange,
160
+ parsePdfPageRangeSpec,
134
161
  parseSafeKeyValueRecord,
135
162
  parseSvgToVectorCommands,
136
163
  parseSvgTransformAttr,
137
164
  ptToMm,
165
+ rc4Bytes,
138
166
  readJpegExifOrientation,
139
167
  rectsIntersect,
140
168
  removePdfPagesBytes,
@@ -155,6 +183,7 @@ import {
155
183
  resolveDynamicTableRawRows,
156
184
  resolveMultiVariableText,
157
185
  resolvePageSizeMm,
186
+ resolvePdfCropBoxPt,
158
187
  resolvePolygonNormalizedPoints,
159
188
  resolveTemplateString,
160
189
  rgbToCmyk,
@@ -163,6 +192,8 @@ import {
163
192
  scanTemplateExpressionTokens,
164
193
  smoothSignatureStrokeQuadratic,
165
194
  splitPdfBytes,
195
+ splitPdfBytesByRanges,
196
+ splitPdfUnitByRanges,
166
197
  stripPdfPageNativeTextInRects,
167
198
  subsetTrueTypeFont,
168
199
  svgToDataUri,
@@ -173,10 +204,11 @@ import {
173
204
  validatePdfInputContract,
174
205
  validatePdfTemplateSchema,
175
206
  validatePdfTemplateVariables,
207
+ verifyAndDecryptPdfBytes,
176
208
  visitTemplateVariables,
177
209
  wrapMixedCjkAndLatinLines,
178
210
  wrapPdfTextLines
179
- } from "./chunk-EMSHTYYU.js";
211
+ } from "./chunk-PQUNQAVL.js";
180
212
  import {
181
213
  Fragment,
182
214
  PDF_JSX_ELEMENT_SYMBOL,
@@ -732,6 +764,15 @@ var PdfSelectionService = class extends Disposable {
732
764
  this.viewportRatio$ = this._viewportRatio$.asObservable();
733
765
  this._previewOpen$ = new BehaviorSubject(false);
734
766
  this.previewOpen$ = this._previewOpen$.asObservable();
767
+ this._splitModalOpen$ = new BehaviorSubject(false);
768
+ this.splitModalOpen$ = this._splitModalOpen$.asObservable();
769
+ this._findReplaceOpen$ = new BehaviorSubject(false);
770
+ this.findReplaceOpen$ = this._findReplaceOpen$.asObservable();
771
+ this._searchHighlight$ = new BehaviorSubject(null);
772
+ this.searchHighlight$ = this._searchHighlight$.asObservable();
773
+ this._scrollSeq = 0;
774
+ this._scrollTarget$ = new BehaviorSubject(null);
775
+ this.scrollTarget$ = this._scrollTarget$.asObservable();
735
776
  this._clipboard$ = new BehaviorSubject([]);
736
777
  this.clipboard$ = this._clipboard$.asObservable();
737
778
  const sub = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_PDF).subscribe((unit) => {
@@ -771,6 +812,10 @@ var PdfSelectionService = class extends Disposable {
771
812
  this._inkColor$.complete();
772
813
  this._viewportRatio$.complete();
773
814
  this._previewOpen$.complete();
815
+ this._splitModalOpen$.complete();
816
+ this._findReplaceOpen$.complete();
817
+ this._searchHighlight$.complete();
818
+ this._scrollTarget$.complete();
774
819
  this._clipboard$.complete();
775
820
  }
776
821
  getState() {
@@ -908,6 +953,35 @@ var PdfSelectionService = class extends Disposable {
908
953
  setPreviewOpen(open) {
909
954
  this._previewOpen$.next(open);
910
955
  }
956
+ getSplitModalOpen() {
957
+ return this._splitModalOpen$.getValue();
958
+ }
959
+ setSplitModalOpen(open) {
960
+ this._splitModalOpen$.next(open);
961
+ }
962
+ getFindReplaceOpen() {
963
+ return this._findReplaceOpen$.getValue();
964
+ }
965
+ setFindReplaceOpen(open) {
966
+ this._findReplaceOpen$.next(open);
967
+ if (!open) {
968
+ this._searchHighlight$.next(null);
969
+ }
970
+ }
971
+ getSearchHighlight() {
972
+ return this._searchHighlight$.getValue();
973
+ }
974
+ setSearchHighlight(highlight) {
975
+ this._searchHighlight$.next(highlight);
976
+ }
977
+ requestScrollToTopPt(topPt, pageId) {
978
+ this._scrollSeq += 1;
979
+ this._scrollTarget$.next({
980
+ pageId,
981
+ topPt: Math.max(0, Number(topPt) || 0),
982
+ seq: this._scrollSeq
983
+ });
984
+ }
911
985
  setClipboard(elements) {
912
986
  this._pasteStep = 0;
913
987
  this._clipboard$.next(elements);
@@ -1301,8 +1375,12 @@ function createDefaultElementByType(type, partial) {
1301
1375
  type: "stamp" /* STAMP */,
1302
1376
  name: partial?.name ?? "\u7535\u5B50\u7B7E\u7AE0",
1303
1377
  stampShape: partial?.stampShape ?? "oval",
1378
+ ...partial?.preset ? { preset: partial.preset } : {},
1304
1379
  primaryText: partial?.primaryText ?? "\u828B\u9053\u79D1\u6280\u5408\u540C\u4E13\u7528\u7AE0",
1305
1380
  secondaryText: partial?.secondaryText ?? "\u5DF2\u5BA1\u6838 \xB7 APPROVED",
1381
+ ...partial?.signer ? { signer: partial.signer } : {},
1382
+ ...partial?.dateText ? { dateText: partial.dateText } : {},
1383
+ ...partial?.svgContent ? { svgContent: partial.svgContent } : {},
1306
1384
  color: partial?.color ?? "#dc2626",
1307
1385
  opacity: partial?.opacity ?? 0.88,
1308
1386
  transform: {
@@ -1513,6 +1591,7 @@ function createDefaultElementByType(type, partial) {
1513
1591
  const annotationType = partial?.annotationType ?? "highlight";
1514
1592
  const defaultColor = annotationType === "highlight" ? "#facc15" : annotationType === "stickyNote" ? "#f59e0b" : annotationType === "squiggly" ? "#f97316" : "#ef4444";
1515
1593
  const isSticky = annotationType === "stickyNote";
1594
+ const resolvedReviewStatus = partial?.reviewStatus ?? (partial?.status === "accepted" || partial?.status === "rejected" || partial?.status === "completed" || partial?.status === "cancelled" ? partial.status : "open");
1516
1595
  return {
1517
1596
  id,
1518
1597
  type: "annotation" /* ANNOTATION */,
@@ -1522,7 +1601,8 @@ function createDefaultElementByType(type, partial) {
1522
1601
  opacity: partial?.opacity ?? (annotationType === "highlight" ? 0.38 : 0.95),
1523
1602
  author: partial?.author ?? "Reviewer",
1524
1603
  comment: partial?.comment ?? "",
1525
- status: partial?.status ?? "open",
1604
+ status: partial?.status ?? resolvedReviewStatus,
1605
+ reviewStatus: resolvedReviewStatus,
1526
1606
  replies: Array.isArray(partial?.replies) ? Tools2.deepClone(partial.replies) : [],
1527
1607
  transform: {
1528
1608
  ...baseTransform,
@@ -1628,6 +1708,14 @@ var UpdatePdfElementsCommand = {
1628
1708
  ...item.patch.style ?? {}
1629
1709
  };
1630
1710
  }
1711
+ if (merged.type === "annotation" /* ANNOTATION */) {
1712
+ const patchAny = item.patch;
1713
+ if (patchAny.status !== void 0 && patchAny.reviewStatus === void 0) {
1714
+ merged.reviewStatus = patchAny.status === "resolved" ? "completed" : patchAny.status;
1715
+ } else if (patchAny.reviewStatus !== void 0 && patchAny.status === void 0) {
1716
+ merged.status = patchAny.reviewStatus;
1717
+ }
1718
+ }
1631
1719
  afterUpdates.push({ id: item.id, element: merged });
1632
1720
  }
1633
1721
  }
@@ -2036,13 +2124,16 @@ var SetPdfPageCropBoxCommand = {
2036
2124
  if (!prevPage) return false;
2037
2125
  const beforePage = Tools2.deepClone(prevPage);
2038
2126
  const afterPage = Tools2.deepClone(prevPage);
2039
- if (params?.cropBox) {
2040
- afterPage.cropBox = {
2041
- left: Math.max(0, Number(params.cropBox.left) || 0),
2042
- top: Math.max(0, Number(params.cropBox.top) || 0),
2043
- width: Math.max(8, Number(params.cropBox.width) || 8),
2044
- height: Math.max(8, Number(params.cropBox.height) || 8)
2045
- };
2127
+ const resolvedCrop = resolvePdfCropBoxPt(params?.cropBox ?? null);
2128
+ if (resolvedCrop && params?.cropBox) {
2129
+ const hasPtAliases = "leftPt" in params.cropBox || "topPt" in params.cropBox || "widthPt" in params.cropBox || "heightPt" in params.cropBox;
2130
+ afterPage.cropBox = hasPtAliases ? {
2131
+ ...resolvedCrop,
2132
+ leftPt: resolvedCrop.left,
2133
+ topPt: resolvedCrop.top,
2134
+ widthPt: resolvedCrop.width,
2135
+ heightPt: resolvedCrop.height
2136
+ } : resolvedCrop;
2046
2137
  } else {
2047
2138
  delete afterPage.cropBox;
2048
2139
  }
@@ -2168,7 +2259,9 @@ var ReplacePdfSnapshotCommand = {
2168
2259
  document: next.document,
2169
2260
  editState: next.editState,
2170
2261
  layers: next.layers ?? null,
2262
+ bookmarks: next.bookmarks ?? next.metadata?.bookmarks ?? null,
2171
2263
  attachments: next.attachments ?? null,
2264
+ security: next.security ?? next.metadata?.security ?? null,
2172
2265
  securityPermissions: next.securityPermissions ?? null,
2173
2266
  signatureEnvelope: next.signatureEnvelope ?? null,
2174
2267
  pdfACompliant: next.pdfACompliant ?? null,
@@ -2183,7 +2276,9 @@ var ReplacePdfSnapshotCommand = {
2183
2276
  document: prev.document,
2184
2277
  editState: prev.editState,
2185
2278
  layers: prev.layers ?? null,
2279
+ bookmarks: prev.bookmarks ?? prev.metadata?.bookmarks ?? null,
2186
2280
  attachments: prev.attachments ?? null,
2281
+ security: prev.security ?? prev.metadata?.security ?? null,
2187
2282
  securityPermissions: prev.securityPermissions ?? null,
2188
2283
  signatureEnvelope: prev.signatureEnvelope ?? null,
2189
2284
  pdfACompliant: prev.pdfACompliant ?? null,
@@ -2564,15 +2659,26 @@ var SetPdfBookmarksCommand = {
2564
2659
  handler: (accessor, params) => {
2565
2660
  const ctx = resolveContext(accessor, params?.unitId);
2566
2661
  if (!ctx || !Array.isArray(params?.bookmarks)) return false;
2567
- const prevMetadata = Tools2.deepClone(ctx.unit.save().metadata ?? {});
2662
+ const prevSnap = ctx.unit.save();
2663
+ const prevBookmarks = Tools2.deepClone(prevSnap.bookmarks ?? prevSnap.metadata?.bookmarks ?? []);
2664
+ const nextBookmarks = Tools2.deepClone(params.bookmarks);
2665
+ const prevMetadata = Tools2.deepClone(prevSnap.metadata ?? {});
2568
2666
  const nextMetadata = {
2569
2667
  ...Tools2.deepClone(prevMetadata),
2570
- bookmarks: Tools2.deepClone(params.bookmarks)
2668
+ bookmarks: Tools2.deepClone(nextBookmarks)
2571
2669
  };
2572
2670
  const commandService = accessor.get(ICommandService);
2573
2671
  const undoRedoService = accessor.get(IUndoRedoService);
2574
- const redoPatch = { metadata: nextMetadata, replaceMetadata: true };
2575
- const undoPatch = { metadata: prevMetadata, replaceMetadata: true };
2672
+ const redoPatch = {
2673
+ bookmarks: nextBookmarks,
2674
+ metadata: nextMetadata,
2675
+ replaceMetadata: true
2676
+ };
2677
+ const undoPatch = {
2678
+ bookmarks: prevSnap.bookmarks !== void 0 || prevSnap.metadata?.bookmarks !== void 0 ? prevBookmarks : null,
2679
+ metadata: prevMetadata,
2680
+ replaceMetadata: true
2681
+ };
2576
2682
  const result = commandService.syncExecuteCommand(UpdatePdfUnitPropsMutation.id, {
2577
2683
  unitId: ctx.unitId,
2578
2684
  patch: redoPatch
@@ -2880,6 +2986,48 @@ var SetPdfAttachmentsCommand = {
2880
2986
  return Boolean(result);
2881
2987
  }
2882
2988
  };
2989
+ var SetPdfSecurityConfigCommand = {
2990
+ id: "pdfs.command.set-security-config",
2991
+ type: CommandType2.COMMAND,
2992
+ handler: (accessor, params) => {
2993
+ const ctx = resolveContext(accessor, params?.unitId);
2994
+ if (!ctx) return false;
2995
+ const prevSnap = ctx.unit.save();
2996
+ const prevSecurity = prevSnap.security ?? prevSnap.metadata?.security ?? null;
2997
+ const nextSecurity = params?.security ? Tools2.deepClone(params.security) : null;
2998
+ const prevMetadata = Tools2.deepClone(prevSnap.metadata ?? {});
2999
+ const nextMetadata = Tools2.deepClone(prevMetadata);
3000
+ if (nextSecurity) {
3001
+ nextMetadata.security = Tools2.deepClone(nextSecurity);
3002
+ } else {
3003
+ delete nextMetadata.security;
3004
+ }
3005
+ const commandService = accessor.get(ICommandService);
3006
+ const undoRedoService = accessor.get(IUndoRedoService);
3007
+ const redoPatch = {
3008
+ security: nextSecurity,
3009
+ metadata: nextMetadata,
3010
+ replaceMetadata: true
3011
+ };
3012
+ const undoPatch = {
3013
+ security: prevSecurity ? Tools2.deepClone(prevSecurity) : null,
3014
+ metadata: prevMetadata,
3015
+ replaceMetadata: true
3016
+ };
3017
+ const result = commandService.syncExecuteCommand(UpdatePdfUnitPropsMutation.id, {
3018
+ unitId: ctx.unitId,
3019
+ patch: redoPatch
3020
+ });
3021
+ if (result) {
3022
+ undoRedoService.pushUndoRedo({
3023
+ unitID: ctx.unitId,
3024
+ undoMutations: [{ id: UpdatePdfUnitPropsMutation.id, params: { unitId: ctx.unitId, patch: undoPatch } }],
3025
+ redoMutations: [{ id: UpdatePdfUnitPropsMutation.id, params: { unitId: ctx.unitId, patch: redoPatch } }]
3026
+ });
3027
+ }
3028
+ return Boolean(result);
3029
+ }
3030
+ };
2883
3031
  var UpdatePdfPagePropsCommand = {
2884
3032
  id: "pdfs.command.update-page-props",
2885
3033
  type: CommandType2.COMMAND,
@@ -2951,9 +3099,17 @@ var UpdatePdfUnitPropsCommand = {
2951
3099
  if (rawPatch.layers !== void 0) {
2952
3100
  undoPatch.layers = prevSnap.layers ? Tools2.deepClone(prevSnap.layers) : null;
2953
3101
  }
3102
+ if (rawPatch.bookmarks !== void 0) {
3103
+ const prevBm = prevSnap.bookmarks ?? prevSnap.metadata?.bookmarks;
3104
+ undoPatch.bookmarks = prevBm ? Tools2.deepClone(prevBm) : null;
3105
+ }
2954
3106
  if (rawPatch.attachments !== void 0) {
2955
3107
  undoPatch.attachments = prevSnap.attachments ? Tools2.deepClone(prevSnap.attachments) : null;
2956
3108
  }
3109
+ if (rawPatch.security !== void 0) {
3110
+ const prevSec = prevSnap.security ?? prevSnap.metadata?.security;
3111
+ undoPatch.security = prevSec ? Tools2.deepClone(prevSec) : null;
3112
+ }
2957
3113
  if (rawPatch.securityPermissions !== void 0) {
2958
3114
  undoPatch.securityPermissions = prevSnap.securityPermissions ? Tools2.deepClone(prevSnap.securityPermissions) : null;
2959
3115
  }
@@ -2982,6 +3138,153 @@ var UpdatePdfUnitPropsCommand = {
2982
3138
  return Boolean(result);
2983
3139
  }
2984
3140
  };
3141
+ function resolveAnnotationTarget(unit, preferredPageId, elementId) {
3142
+ const direct = unit.getElement(preferredPageId, elementId);
3143
+ if (direct && direct.type === "annotation" /* ANNOTATION */) {
3144
+ return { pageId: preferredPageId, element: direct };
3145
+ }
3146
+ for (const pid of unit.getPageOrder()) {
3147
+ const found = unit.getElement(pid, elementId);
3148
+ if (found && found.type === "annotation" /* ANNOTATION */) {
3149
+ return { pageId: pid, element: found };
3150
+ }
3151
+ }
3152
+ return null;
3153
+ }
3154
+ var AddPdfAnnotationReplyCommand = {
3155
+ id: "pdfs.command.add-annotation-reply",
3156
+ type: CommandType2.COMMAND,
3157
+ handler: (accessor, params) => {
3158
+ if (!params?.elementId) return false;
3159
+ const rawContent = (params.reply?.content ?? params.content ?? "").trim();
3160
+ if (!rawContent) return false;
3161
+ const ctx = resolveContext(accessor, params.unitId, params.pageId);
3162
+ if (!ctx) return false;
3163
+ const target = resolveAnnotationTarget(ctx.unit, ctx.pageId, params.elementId);
3164
+ if (!target) return false;
3165
+ const newReply = {
3166
+ id: params.reply?.id || params.id || `reply-${generateRandomId3(6)}`,
3167
+ author: (params.reply?.author ?? params.author ?? "Reviewer").trim() || "Reviewer",
3168
+ content: rawContent,
3169
+ createdAt: params.reply?.createdAt || params.createdAt || (/* @__PURE__ */ new Date()).toISOString()
3170
+ };
3171
+ const beforeEl = Tools2.deepClone(target.element);
3172
+ const afterEl = {
3173
+ ...Tools2.deepClone(target.element),
3174
+ replies: [...Tools2.deepClone(target.element.replies ?? []), Tools2.deepClone(newReply)]
3175
+ };
3176
+ const commandService = accessor.get(ICommandService);
3177
+ const undoRedoService = accessor.get(IUndoRedoService);
3178
+ const redoParams = {
3179
+ unitId: ctx.unitId,
3180
+ pageId: target.pageId,
3181
+ updates: [{ id: target.element.id, element: afterEl }]
3182
+ };
3183
+ const undoParams = {
3184
+ unitId: ctx.unitId,
3185
+ pageId: target.pageId,
3186
+ updates: [{ id: target.element.id, element: beforeEl }]
3187
+ };
3188
+ const result = commandService.syncExecuteCommand(UpdatePdfElementsMutation.id, redoParams);
3189
+ if (result) {
3190
+ undoRedoService.pushUndoRedo({
3191
+ unitID: ctx.unitId,
3192
+ undoMutations: [{ id: UpdatePdfElementsMutation.id, params: undoParams }],
3193
+ redoMutations: [{ id: UpdatePdfElementsMutation.id, params: redoParams }]
3194
+ });
3195
+ params.onCreated?.(Tools2.deepClone(newReply));
3196
+ }
3197
+ return Boolean(result);
3198
+ }
3199
+ };
3200
+ var DeletePdfAnnotationReplyCommand = {
3201
+ id: "pdfs.command.delete-annotation-reply",
3202
+ type: CommandType2.COMMAND,
3203
+ handler: (accessor, params) => {
3204
+ if (!params?.elementId || !params?.replyId) return false;
3205
+ const ctx = resolveContext(accessor, params.unitId, params.pageId);
3206
+ if (!ctx) return false;
3207
+ const target = resolveAnnotationTarget(ctx.unit, ctx.pageId, params.elementId);
3208
+ if (!target) return false;
3209
+ const prevReplies = target.element.replies ?? [];
3210
+ if (!prevReplies.some((r) => r.id === params.replyId)) {
3211
+ return false;
3212
+ }
3213
+ const beforeEl = Tools2.deepClone(target.element);
3214
+ const afterEl = {
3215
+ ...Tools2.deepClone(target.element),
3216
+ replies: Tools2.deepClone(prevReplies.filter((r) => r.id !== params.replyId))
3217
+ };
3218
+ const commandService = accessor.get(ICommandService);
3219
+ const undoRedoService = accessor.get(IUndoRedoService);
3220
+ const redoParams = {
3221
+ unitId: ctx.unitId,
3222
+ pageId: target.pageId,
3223
+ updates: [{ id: target.element.id, element: afterEl }]
3224
+ };
3225
+ const undoParams = {
3226
+ unitId: ctx.unitId,
3227
+ pageId: target.pageId,
3228
+ updates: [{ id: target.element.id, element: beforeEl }]
3229
+ };
3230
+ const result = commandService.syncExecuteCommand(UpdatePdfElementsMutation.id, redoParams);
3231
+ if (result) {
3232
+ undoRedoService.pushUndoRedo({
3233
+ unitID: ctx.unitId,
3234
+ undoMutations: [{ id: UpdatePdfElementsMutation.id, params: undoParams }],
3235
+ redoMutations: [{ id: UpdatePdfElementsMutation.id, params: redoParams }]
3236
+ });
3237
+ }
3238
+ return Boolean(result);
3239
+ }
3240
+ };
3241
+ var VALID_ANNOTATION_REVIEW_STATUSES = /* @__PURE__ */ new Set([
3242
+ "open",
3243
+ "accepted",
3244
+ "rejected",
3245
+ "completed",
3246
+ "cancelled"
3247
+ ]);
3248
+ var SetPdfAnnotationReviewStatusCommand = {
3249
+ id: "pdfs.command.set-annotation-review-status",
3250
+ type: CommandType2.COMMAND,
3251
+ handler: (accessor, params) => {
3252
+ if (!params?.elementId || !VALID_ANNOTATION_REVIEW_STATUSES.has(params.reviewStatus)) {
3253
+ return false;
3254
+ }
3255
+ const ctx = resolveContext(accessor, params.unitId, params.pageId);
3256
+ if (!ctx) return false;
3257
+ const target = resolveAnnotationTarget(ctx.unit, ctx.pageId, params.elementId);
3258
+ if (!target) return false;
3259
+ const beforeEl = Tools2.deepClone(target.element);
3260
+ const afterEl = {
3261
+ ...Tools2.deepClone(target.element),
3262
+ reviewStatus: params.reviewStatus,
3263
+ status: params.reviewStatus
3264
+ };
3265
+ const commandService = accessor.get(ICommandService);
3266
+ const undoRedoService = accessor.get(IUndoRedoService);
3267
+ const redoParams = {
3268
+ unitId: ctx.unitId,
3269
+ pageId: target.pageId,
3270
+ updates: [{ id: target.element.id, element: afterEl }]
3271
+ };
3272
+ const undoParams = {
3273
+ unitId: ctx.unitId,
3274
+ pageId: target.pageId,
3275
+ updates: [{ id: target.element.id, element: beforeEl }]
3276
+ };
3277
+ const result = commandService.syncExecuteCommand(UpdatePdfElementsMutation.id, redoParams);
3278
+ if (result) {
3279
+ undoRedoService.pushUndoRedo({
3280
+ unitID: ctx.unitId,
3281
+ undoMutations: [{ id: UpdatePdfElementsMutation.id, params: undoParams }],
3282
+ redoMutations: [{ id: UpdatePdfElementsMutation.id, params: redoParams }]
3283
+ });
3284
+ }
3285
+ return Boolean(result);
3286
+ }
3287
+ };
2985
3288
 
2986
3289
  // src/exporter/pdf-advanced-tools.ts
2987
3290
  import { generateRandomId as generateRandomId4, Tools as Tools3 } from "@univerjs/core";
@@ -4605,7 +4908,7 @@ function toUtf8Bytes(input) {
4605
4908
  if (input instanceof Uint8Array) return input;
4606
4909
  return new TextEncoder().encode(input);
4607
4910
  }
4608
- function bytesToHex(bytes) {
4911
+ function bytesToHex2(bytes) {
4609
4912
  let hex = "";
4610
4913
  for (let i = 0; i < bytes.length; i++) {
4611
4914
  hex += bytes[i].toString(16).padStart(2, "0");
@@ -4688,7 +4991,7 @@ function sha256BytesSync(input) {
4688
4991
  return out;
4689
4992
  }
4690
4993
  function sha256HexSync(input) {
4691
- return bytesToHex(sha256BytesSync(input));
4994
+ return bytesToHex2(sha256BytesSync(input));
4692
4995
  }
4693
4996
  async function sha256Hex(input) {
4694
4997
  const bytes = toUtf8Bytes(input);
@@ -4698,7 +5001,7 @@ async function sha256Hex(input) {
4698
5001
  const copy = new Uint8Array(bytes.byteLength);
4699
5002
  copy.set(bytes);
4700
5003
  const digestBuf = await subtle.digest("SHA-256", copy.buffer);
4701
- return bytesToHex(new Uint8Array(digestBuf));
5004
+ return bytesToHex2(new Uint8Array(digestBuf));
4702
5005
  } catch {
4703
5006
  return sha256HexSync(bytes);
4704
5007
  }
@@ -4712,7 +5015,7 @@ function canonicalJsonStringify(value) {
4712
5015
  }
4713
5016
  if (typeof value === "string") return JSON.stringify(value);
4714
5017
  if (value instanceof Uint8Array) {
4715
- return JSON.stringify(`uint8:${bytesToHex(value)}`);
5018
+ return JSON.stringify(`uint8:${bytesToHex2(value)}`);
4716
5019
  }
4717
5020
  if (Array.isArray(value)) {
4718
5021
  return `[${value.map((item) => canonicalJsonStringify(item)).join(",")}]`;
@@ -4968,25 +5271,1139 @@ async function verifyPdfAuditSeal(pdfBytes) {
4968
5271
  }
4969
5272
 
4970
5273
  // src/exporter/pdf-convert-and-compliance.ts
4971
- import { generateRandomId as generateRandomId5, Tools as Tools4 } from "@univerjs/core";
5274
+ import { generateRandomId as generateRandomId6, Tools as Tools5 } from "@univerjs/core";
4972
5275
  import {
4973
5276
  clip,
4974
5277
  concatTransformationMatrix,
4975
5278
  decodePDFRawStream,
4976
5279
  drawObject,
4977
5280
  endPath,
5281
+ PDFArray as PDFArray4,
5282
+ PDFDict as PDFDict4,
5283
+ PDFDocument as PDFDocument4,
5284
+ PDFHexString as PDFHexString4,
5285
+ PDFName as PDFName4,
5286
+ PDFRawStream as PDFRawStream2,
5287
+ PDFRef as PDFRef4,
5288
+ PDFString as PDFString4,
5289
+ popGraphicsState,
5290
+ pushGraphicsState,
5291
+ rectangle
5292
+ } from "pdf-lib";
5293
+
5294
+ // src/exporter/pdf-importer.ts
5295
+ import { generateRandomId as generateRandomId5, Tools as Tools4 } from "@univerjs/core";
5296
+ import {
4978
5297
  PDFArray as PDFArray3,
4979
5298
  PDFDict as PDFDict3,
4980
5299
  PDFDocument as PDFDocument3,
4981
5300
  PDFHexString as PDFHexString3,
4982
5301
  PDFName as PDFName3,
4983
- PDFRawStream as PDFRawStream2,
5302
+ PDFNumber as PDFNumber2,
4984
5303
  PDFRef as PDFRef3,
4985
- PDFString as PDFString3,
4986
- popGraphicsState,
4987
- pushGraphicsState,
4988
- rectangle
5304
+ PDFString as PDFString3
4989
5305
  } from "pdf-lib";
5306
+ function hasPdfMagicHeader(bytes) {
5307
+ if (!bytes || bytes.byteLength < 5) return false;
5308
+ const maxScan = Math.min(bytes.byteLength - 5, 1024);
5309
+ for (let i = 0; i <= maxScan; i++) {
5310
+ if (bytes[i] === 37 && bytes[i + 1] === 80 && bytes[i + 2] === 68 && bytes[i + 3] === 70 && bytes[i + 4] === 45) {
5311
+ return true;
5312
+ }
5313
+ }
5314
+ return false;
5315
+ }
5316
+ function decodePdfTextValue(obj) {
5317
+ if (obj instanceof PDFHexString3 || obj instanceof PDFString3 || obj instanceof PDFName3) {
5318
+ return obj.decodeText();
5319
+ }
5320
+ return "";
5321
+ }
5322
+ function extractOutlinesBookmarksFromDoc(doc) {
5323
+ const outlinesRef = doc.catalog.get(PDFName3.of("Outlines"));
5324
+ const outlinesDict = doc.context.lookupMaybe(outlinesRef, PDFDict3);
5325
+ if (!outlinesDict) return [];
5326
+ const pages = doc.getPages();
5327
+ const pageRefKeyToIdx = /* @__PURE__ */ new Map();
5328
+ pages.forEach((p, idx) => {
5329
+ pageRefKeyToIdx.set(`${p.ref.objectNumber}:${p.ref.generationNumber}`, idx);
5330
+ });
5331
+ const resolveDest = (itemDict) => {
5332
+ let destObj = itemDict.get(PDFName3.of("Dest"));
5333
+ if (!destObj) {
5334
+ const actionDict = doc.context.lookupMaybe(itemDict.get(PDFName3.of("A")), PDFDict3);
5335
+ if (actionDict) {
5336
+ destObj = actionDict.get(PDFName3.of("D"));
5337
+ }
5338
+ }
5339
+ const destArr = doc.context.lookupMaybe(destObj, PDFArray3);
5340
+ if (!destArr || destArr.size() === 0) return { pageIndex: 0 };
5341
+ const pRef = destArr.get(0);
5342
+ let pageIndex = 0;
5343
+ if (pRef instanceof PDFRef3) {
5344
+ pageIndex = pageRefKeyToIdx.get(`${pRef.objectNumber}:${pRef.generationNumber}`) ?? 0;
5345
+ } else if (pRef instanceof PDFNumber2) {
5346
+ pageIndex = Math.max(0, Math.min(pages.length - 1, Math.floor(pRef.asNumber())));
5347
+ }
5348
+ let topPt;
5349
+ if (destArr.size() >= 4) {
5350
+ const yObj = destArr.get(3);
5351
+ if (yObj instanceof PDFNumber2 && pages[pageIndex]) {
5352
+ const pageHeight = pages[pageIndex].getHeight();
5353
+ topPt = Math.round(Math.max(0, pageHeight - yObj.asNumber()) * 100) / 100;
5354
+ }
5355
+ }
5356
+ return { pageIndex, topPt };
5357
+ };
5358
+ const visited = /* @__PURE__ */ new Set();
5359
+ const walkLevel = (firstRef) => {
5360
+ const list = [];
5361
+ let cur = firstRef;
5362
+ while (cur) {
5363
+ if (cur instanceof PDFRef3) {
5364
+ const key = `${cur.objectNumber}:${cur.generationNumber}`;
5365
+ if (visited.has(key)) break;
5366
+ visited.add(key);
5367
+ }
5368
+ const itemDict = cur instanceof PDFDict3 ? cur : doc.context.lookupMaybe(cur, PDFDict3);
5369
+ if (!itemDict) break;
5370
+ const title = decodePdfTextValue(itemDict.get(PDFName3.of("Title"))) || "Bookmark";
5371
+ const { pageIndex, topPt } = resolveDest(itemDict);
5372
+ const childFirst = itemDict.get(PDFName3.of("First"));
5373
+ const children = childFirst ? walkLevel(childFirst) : [];
5374
+ const bm = {
5375
+ id: `bm-${generateRandomId5(6)}`,
5376
+ title,
5377
+ pageIndex,
5378
+ ...topPt !== void 0 ? { topOffsetPt: topPt, topPt } : {},
5379
+ ...children.length > 0 ? { children } : {}
5380
+ };
5381
+ list.push(bm);
5382
+ const nextRef = itemDict.get(PDFName3.of("Next"));
5383
+ if (!nextRef || nextRef === cur) break;
5384
+ cur = nextRef;
5385
+ }
5386
+ return list;
5387
+ };
5388
+ return walkLevel(outlinesDict.get(PDFName3.of("First")));
5389
+ }
5390
+ function extractLayersFromDoc(doc) {
5391
+ const ocProps = doc.context.lookupMaybe(doc.catalog.get(PDFName3.of("OCProperties")), PDFDict3);
5392
+ if (!ocProps) return [];
5393
+ const ocgsArr = doc.context.lookupMaybe(ocProps.get(PDFName3.of("OCGs")), PDFArray3);
5394
+ if (!ocgsArr || ocgsArr.size() === 0) return [];
5395
+ const defaultCfg = doc.context.lookupMaybe(ocProps.get(PDFName3.of("D")), PDFDict3);
5396
+ const offRefKeys = /* @__PURE__ */ new Set();
5397
+ const lockedRefKeys = /* @__PURE__ */ new Set();
5398
+ if (defaultCfg) {
5399
+ const offArr = doc.context.lookupMaybe(defaultCfg.get(PDFName3.of("OFF")), PDFArray3);
5400
+ if (offArr) {
5401
+ for (let i = 0; i < offArr.size(); i++) {
5402
+ const r = offArr.get(i);
5403
+ if (r instanceof PDFRef3) offRefKeys.add(`${r.objectNumber}:${r.generationNumber}`);
5404
+ }
5405
+ }
5406
+ const lockedArr = doc.context.lookupMaybe(defaultCfg.get(PDFName3.of("Locked")), PDFArray3);
5407
+ if (lockedArr) {
5408
+ for (let i = 0; i < lockedArr.size(); i++) {
5409
+ const r = lockedArr.get(i);
5410
+ if (r instanceof PDFRef3) lockedRefKeys.add(`${r.objectNumber}:${r.generationNumber}`);
5411
+ }
5412
+ }
5413
+ }
5414
+ const out = [];
5415
+ for (let i = 0; i < ocgsArr.size(); i++) {
5416
+ const entry = ocgsArr.get(i);
5417
+ const key = entry instanceof PDFRef3 ? `${entry.objectNumber}:${entry.generationNumber}` : "";
5418
+ const dict = entry instanceof PDFDict3 ? entry : doc.context.lookupMaybe(entry, PDFDict3);
5419
+ if (!dict) continue;
5420
+ const name = decodePdfTextValue(dict.get(PDFName3.of("Name"))) || `Layer ${i + 1}`;
5421
+ let printable = true;
5422
+ const usage = doc.context.lookupMaybe(dict.get(PDFName3.of("Usage")), PDFDict3);
5423
+ if (usage) {
5424
+ const printDict = doc.context.lookupMaybe(usage.get(PDFName3.of("Print")), PDFDict3);
5425
+ if (printDict && decodePdfTextValue(printDict.get(PDFName3.of("PrintState"))) === "OFF") {
5426
+ printable = false;
5427
+ }
5428
+ }
5429
+ out.push({
5430
+ id: `layer-${generateRandomId5(6)}`,
5431
+ name,
5432
+ visible: key ? !offRefKeys.has(key) : true,
5433
+ locked: key ? lockedRefKeys.has(key) : false,
5434
+ printable
5435
+ });
5436
+ }
5437
+ return out;
5438
+ }
5439
+ async function importPdfBytesToUnit(pdfBytes, options) {
5440
+ if (!hasPdfMagicHeader(pdfBytes)) {
5441
+ throw new Error("Invalid PDF binary: missing %PDF- header signature.");
5442
+ }
5443
+ const encryptionInspection = inspectPdfEncryption(pdfBytes);
5444
+ const decryptedBytes = await verifyAndDecryptPdfBytes(pdfBytes, options?.password);
5445
+ const unitTitle = options?.name ?? options?.title;
5446
+ const unit = await importAcroFormPdfToUnit(decryptedBytes, {
5447
+ unitId: options?.unitId,
5448
+ title: unitTitle
5449
+ });
5450
+ if (options?.fileName && unit.sourceDocumentRef) {
5451
+ unit.sourceDocumentRef.fileName = options.fileName;
5452
+ }
5453
+ try {
5454
+ const doc = await PDFDocument3.load(decryptedBytes, { updateMetadata: false });
5455
+ const parsedBookmarks = extractOutlinesBookmarksFromDoc(doc);
5456
+ if (parsedBookmarks.length > 0) {
5457
+ unit.bookmarks = Tools4.deepClone(parsedBookmarks);
5458
+ unit.metadata = {
5459
+ ...unit.metadata ?? {},
5460
+ bookmarks: Tools4.deepClone(parsedBookmarks)
5461
+ };
5462
+ }
5463
+ const parsedLayers = extractLayersFromDoc(doc);
5464
+ if (parsedLayers.length > 0) {
5465
+ unit.layers = Tools4.deepClone(parsedLayers);
5466
+ }
5467
+ if (unitTitle === void 0) {
5468
+ const docTitle = doc.getTitle();
5469
+ if (docTitle) {
5470
+ unit.name = docTitle;
5471
+ } else if (options?.fileName) {
5472
+ unit.name = options.fileName.replace(/\.pdf$/i, "");
5473
+ }
5474
+ }
5475
+ } catch {
5476
+ }
5477
+ if (encryptionInspection.encrypted) {
5478
+ unit.metadata = {
5479
+ ...unit.metadata ?? {},
5480
+ importedEncryptionInfo: {
5481
+ encrypted: true,
5482
+ requiresOpenPassword: encryptionInspection.requiresOpenPassword,
5483
+ keyLength: encryptionInspection.keyLength,
5484
+ permissions: { ...encryptionInspection.permissions }
5485
+ }
5486
+ };
5487
+ }
5488
+ if (options?.promoteNativeTextToElements) {
5489
+ const spansByPage = unit.editState.nativeTextSpansByPage ?? {};
5490
+ for (const pageId of unit.document.pageOrder) {
5491
+ const pageSpans = spansByPage[pageId] ?? [];
5492
+ if (!unit.editState.elementsByPage[pageId]) {
5493
+ unit.editState.elementsByPage[pageId] = {};
5494
+ }
5495
+ if (!unit.editState.elementOrderByPage[pageId]) {
5496
+ unit.editState.elementOrderByPage[pageId] = [];
5497
+ }
5498
+ for (const span of pageSpans) {
5499
+ if (span.suppressed) continue;
5500
+ span.suppressed = true;
5501
+ const elId = `el-${generateRandomId5(6)}`;
5502
+ const textEl = {
5503
+ id: elId,
5504
+ type: "text" /* TEXT */,
5505
+ name: "Imported Text",
5506
+ content: span.text,
5507
+ metadata: { promotedFromNativeSpanId: span.id },
5508
+ transform: {
5509
+ left: span.left,
5510
+ top: span.top,
5511
+ width: span.width,
5512
+ height: span.height,
5513
+ angle: 0
5514
+ },
5515
+ style: {
5516
+ fontFamily: "Inter, PingFang SC, Microsoft YaHei, sans-serif",
5517
+ fontSize: span.fontSize,
5518
+ fontWeight: "normal",
5519
+ color: "#1B1C1F",
5520
+ textAlign: "left",
5521
+ verticalAlign: "middle",
5522
+ lineHeight: 1.2,
5523
+ padding: 0
5524
+ }
5525
+ };
5526
+ unit.editState.elementsByPage[pageId][elId] = textEl;
5527
+ unit.editState.elementOrderByPage[pageId].push(elId);
5528
+ }
5529
+ }
5530
+ if (unit.metadata?.nativeTextSpansByPage) {
5531
+ unit.metadata.nativeTextSpansByPage = Tools4.deepClone(spansByPage);
5532
+ }
5533
+ }
5534
+ return unit;
5535
+ }
5536
+
5537
+ // src/exporter/pdf-to-pptx.ts
5538
+ var PPTX_EMU_PER_PT = 12700;
5539
+ function ptToPptxEmu(pt) {
5540
+ if (!Number.isFinite(pt)) return 0;
5541
+ return Math.max(0, Math.round(pt * PPTX_EMU_PER_PT));
5542
+ }
5543
+ var PPTX_CRC32_TABLE = (() => {
5544
+ const table = new Uint32Array(256);
5545
+ for (let n = 0; n < 256; n++) {
5546
+ let c = n;
5547
+ for (let k = 0; k < 8; k++) {
5548
+ c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
5549
+ }
5550
+ table[n] = c >>> 0;
5551
+ }
5552
+ return table;
5553
+ })();
5554
+ function computeCrc32(data) {
5555
+ let crc = 4294967295;
5556
+ for (let i = 0; i < data.length; i++) {
5557
+ crc = PPTX_CRC32_TABLE[(crc ^ data[i]) & 255] ^ crc >>> 8;
5558
+ }
5559
+ return (crc ^ 4294967295) >>> 0;
5560
+ }
5561
+ function buildPptxZipArchive(entries) {
5562
+ const enc = new TextEncoder();
5563
+ const localParts = [];
5564
+ const centralParts = [];
5565
+ let offset = 0;
5566
+ for (const entry of entries) {
5567
+ const nameBytes = enc.encode(entry.path);
5568
+ const data = entry.data;
5569
+ const crc = computeCrc32(data);
5570
+ const localHeader = new Uint8Array(30 + nameBytes.length);
5571
+ const lv = new DataView(localHeader.buffer);
5572
+ lv.setUint32(0, 67324752, true);
5573
+ lv.setUint16(4, 20, true);
5574
+ lv.setUint16(6, 2048, true);
5575
+ lv.setUint16(8, 0, true);
5576
+ lv.setUint16(10, 0, true);
5577
+ lv.setUint16(12, 33, true);
5578
+ lv.setUint32(14, crc, true);
5579
+ lv.setUint32(18, data.byteLength, true);
5580
+ lv.setUint32(22, data.byteLength, true);
5581
+ lv.setUint16(26, nameBytes.length, true);
5582
+ lv.setUint16(28, 0, true);
5583
+ localHeader.set(nameBytes, 30);
5584
+ const centralHeader = new Uint8Array(46 + nameBytes.length);
5585
+ const cv = new DataView(centralHeader.buffer);
5586
+ cv.setUint32(0, 33639248, true);
5587
+ cv.setUint16(4, 20, true);
5588
+ cv.setUint16(6, 20, true);
5589
+ cv.setUint16(8, 2048, true);
5590
+ cv.setUint16(10, 0, true);
5591
+ cv.setUint16(12, 0, true);
5592
+ cv.setUint16(14, 33, true);
5593
+ cv.setUint32(16, crc, true);
5594
+ cv.setUint32(20, data.byteLength, true);
5595
+ cv.setUint32(24, data.byteLength, true);
5596
+ cv.setUint16(28, nameBytes.length, true);
5597
+ cv.setUint16(30, 0, true);
5598
+ cv.setUint16(32, 0, true);
5599
+ cv.setUint16(34, 0, true);
5600
+ cv.setUint16(36, 0, true);
5601
+ cv.setUint32(38, 0, true);
5602
+ cv.setUint32(42, offset, true);
5603
+ centralHeader.set(nameBytes, 46);
5604
+ localParts.push(localHeader, data);
5605
+ centralParts.push(centralHeader);
5606
+ offset += localHeader.byteLength + data.byteLength;
5607
+ }
5608
+ const centralSize = centralParts.reduce((sum, part) => sum + part.byteLength, 0);
5609
+ const eocd = new Uint8Array(22);
5610
+ const ev = new DataView(eocd.buffer);
5611
+ ev.setUint32(0, 101010256, true);
5612
+ ev.setUint16(4, 0, true);
5613
+ ev.setUint16(6, 0, true);
5614
+ ev.setUint16(8, entries.length, true);
5615
+ ev.setUint16(10, entries.length, true);
5616
+ ev.setUint32(12, centralSize, true);
5617
+ ev.setUint32(16, offset, true);
5618
+ ev.setUint16(20, 0, true);
5619
+ const out = new Uint8Array(offset + centralSize + eocd.byteLength);
5620
+ let pos = 0;
5621
+ for (const part of localParts) {
5622
+ out.set(part, pos);
5623
+ pos += part.byteLength;
5624
+ }
5625
+ for (const part of centralParts) {
5626
+ out.set(part, pos);
5627
+ pos += part.byteLength;
5628
+ }
5629
+ out.set(eocd, pos);
5630
+ return out;
5631
+ }
5632
+ function escapeXml2(raw) {
5633
+ return raw.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
5634
+ }
5635
+ function toRgbHex6(color, fallback = "1B1C1F") {
5636
+ if (!color || color === "transparent" || color === "none") return null;
5637
+ const parsed = parsePdfColorWithAlpha(color);
5638
+ if (!parsed || parsed.a <= 0) return null;
5639
+ const toHex2 = (v) => Math.max(0, Math.min(255, Math.round(v * 255))).toString(16).padStart(2, "0").toUpperCase();
5640
+ const hex6 = `${toHex2(parsed.r)}${toHex2(parsed.g)}${toHex2(parsed.b)}`;
5641
+ const alphaPct = parsed.a < 0.999 ? Math.round(parsed.a * 1e5) : void 0;
5642
+ return { hex6: hex6 || fallback, alphaPct };
5643
+ }
5644
+ function buildSolidFillXml(color, extraOpacity = 1) {
5645
+ const c = toRgbHex6(color);
5646
+ if (!c) return "<a:noFill/>";
5647
+ const baseAlpha = c.alphaPct !== void 0 ? c.alphaPct / 1e5 : 1;
5648
+ const effectiveAlpha = Math.max(0, Math.min(1, baseAlpha * extraOpacity));
5649
+ const alphaTag = effectiveAlpha < 0.999 ? `<a:alpha val="${Math.round(effectiveAlpha * 1e5)}"/>` : "";
5650
+ return `<a:solidFill><a:srgbClr val="${c.hex6}">${alphaTag}</a:srgbClr></a:solidFill>`;
5651
+ }
5652
+ function buildLineXml(strokeColor, strokeWidthPt = 1, options) {
5653
+ if (!strokeColor || strokeColor === "none" || strokeWidthPt <= 0) {
5654
+ return "<a:ln><a:noFill/></a:ln>";
5655
+ }
5656
+ const c = toRgbHex6(strokeColor);
5657
+ if (!c) return "<a:ln><a:noFill/></a:ln>";
5658
+ const wEmu = Math.max(6350, ptToPptxEmu(strokeWidthPt));
5659
+ const baseAlpha = c.alphaPct !== void 0 ? c.alphaPct / 1e5 : 1;
5660
+ const effAlpha = Math.max(0, Math.min(1, baseAlpha * (options?.opacity ?? 1)));
5661
+ const alphaTag = effAlpha < 0.999 ? `<a:alpha val="${Math.round(effAlpha * 1e5)}"/>` : "";
5662
+ const dashTag = options?.dash ? '<a:prstDash val="dash"/>' : "";
5663
+ const headTag = options?.startArrow ? '<a:headEnd type="triangle" w="med" len="med"/>' : "";
5664
+ const tailTag = options?.endArrow ? '<a:tailEnd type="triangle" w="med" len="med"/>' : "";
5665
+ return `<a:ln w="${wEmu}"><a:solidFill><a:srgbClr val="${c.hex6}">${alphaTag}</a:srgbClr></a:solidFill>${dashTag}${headTag}${tailTag}</a:ln>`;
5666
+ }
5667
+ function buildXfrmXml(tagPrefix, leftPt, topPt, widthPt, heightPt, angleDeg, flipX, flipY) {
5668
+ const x = ptToPptxEmu(leftPt);
5669
+ const y = ptToPptxEmu(topPt);
5670
+ const cx = Math.max(12700, ptToPptxEmu(widthPt));
5671
+ const cy = Math.max(12700, ptToPptxEmu(heightPt));
5672
+ const attrs = [];
5673
+ const normAngle = ((angleDeg ?? 0) % 360 + 360) % 360;
5674
+ if (normAngle > 0.01) {
5675
+ attrs.push(`rot="${Math.round(normAngle * 6e4)}"`);
5676
+ }
5677
+ if (flipX) attrs.push('flipH="1"');
5678
+ if (flipY) attrs.push('flipV="1"');
5679
+ const attrSuffix = attrs.length > 0 ? ` ${attrs.join(" ")}` : "";
5680
+ return `<${tagPrefix}:xfrm${attrSuffix}><a:off x="${x}" y="${y}"/><a:ext cx="${cx}" cy="${cy}"/></${tagPrefix}:xfrm>`;
5681
+ }
5682
+ function decodeBase64ToBytes(b64) {
5683
+ const cleaned = b64.replace(/[\r\n\s]/g, "");
5684
+ if (typeof atob === "function") {
5685
+ const bin = atob(cleaned);
5686
+ const out2 = new Uint8Array(bin.length);
5687
+ for (let i = 0; i < bin.length; i++) {
5688
+ out2[i] = bin.charCodeAt(i);
5689
+ }
5690
+ return out2;
5691
+ }
5692
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
5693
+ const lookup = new Uint8Array(256);
5694
+ for (let i = 0; i < chars.length; i++) lookup[chars.charCodeAt(i)] = i;
5695
+ const padLen = cleaned.endsWith("==") ? 2 : cleaned.endsWith("=") ? 1 : 0;
5696
+ const byteLen = Math.max(0, Math.floor(cleaned.length * 3 / 4) - padLen);
5697
+ const out = new Uint8Array(byteLen);
5698
+ let p = 0;
5699
+ for (let i = 0; i < cleaned.length; i += 4) {
5700
+ const e1 = lookup[cleaned.charCodeAt(i)];
5701
+ const e2 = lookup[cleaned.charCodeAt(i + 1)];
5702
+ const e3 = lookup[cleaned.charCodeAt(i + 2)];
5703
+ const e4 = lookup[cleaned.charCodeAt(i + 3)];
5704
+ const triple = e1 << 18 | e2 << 12 | e3 << 6 | e4;
5705
+ if (p < byteLen) out[p++] = triple >> 16 & 255;
5706
+ if (p < byteLen) out[p++] = triple >> 8 & 255;
5707
+ if (p < byteLen) out[p++] = triple & 255;
5708
+ }
5709
+ return out;
5710
+ }
5711
+ function parseRasterImageDataUrl(dataUrl) {
5712
+ if (!dataUrl || !dataUrl.startsWith("data:image/")) return null;
5713
+ const commaIdx = dataUrl.indexOf(",");
5714
+ if (commaIdx < 0) return null;
5715
+ const header = dataUrl.slice(0, commaIdx).toLowerCase();
5716
+ if (!header.includes(";base64")) return null;
5717
+ let ext = null;
5718
+ if (header.startsWith("data:image/png")) {
5719
+ ext = "png";
5720
+ } else if (header.startsWith("data:image/jpeg") || header.startsWith("data:image/jpg")) {
5721
+ ext = "jpg";
5722
+ }
5723
+ if (!ext) return null;
5724
+ const bytes = decodeBase64ToBytes(dataUrl.slice(commaIdx + 1));
5725
+ if (bytes.byteLength === 0) return null;
5726
+ return { ext, bytes };
5727
+ }
5728
+ function mapTextAlignToDrawingMl(align) {
5729
+ if (align === "center") return "ctr";
5730
+ if (align === "right") return "r";
5731
+ if (align === "justify") return "just";
5732
+ return "l";
5733
+ }
5734
+ function mapVertAlignToDrawingMl(vAlign) {
5735
+ if (vAlign === "top") return "t";
5736
+ if (vAlign === "bottom") return "b";
5737
+ return "ctr";
5738
+ }
5739
+ function buildTextBoxShapeXml(params) {
5740
+ const fsPt = Math.max(4, params.style?.fontSize ?? 12);
5741
+ const sz = Math.round(fsPt * 100);
5742
+ const isBold = params.style?.fontWeight === "bold";
5743
+ const isItalic = Boolean(params.style?.italic);
5744
+ const isUnderline = Boolean(params.style?.underline);
5745
+ const textCol = toRgbHex6(params.style?.color, "1B1C1F")?.hex6 ?? "1B1C1F";
5746
+ const algn = mapTextAlignToDrawingMl(params.style?.textAlign);
5747
+ const anchor = mapVertAlignToDrawingMl(params.style?.verticalAlign);
5748
+ const padPt = params.style?.padding ?? (params.noWrap ? 0 : 4);
5749
+ const ins = ptToPptxEmu(padPt);
5750
+ const fillXml = params.style?.backgroundColor ? buildSolidFillXml(params.style.backgroundColor, params.opacity ?? 1) : "<a:noFill/>";
5751
+ const lineXml = params.style?.borderColor && (params.style?.borderWidth ?? 0) > 0 ? buildLineXml(params.style.borderColor, params.style.borderWidth ?? 1, {
5752
+ opacity: params.opacity ?? 1
5753
+ }) : "";
5754
+ const buildRunPr = (opts) => {
5755
+ const attrs = [
5756
+ 'lang="zh-CN"',
5757
+ 'altLang="en-US"',
5758
+ `sz="${opts.szVal}"`,
5759
+ ...opts.bold ? ['b="1"'] : [],
5760
+ ...opts.italic ? ['i="1"'] : [],
5761
+ ...opts.underline ? ['u="sng"'] : [],
5762
+ 'dirty="0"'
5763
+ ].join(" ");
5764
+ return `<a:rPr ${attrs}><a:solidFill><a:srgbClr val="${opts.hex6}"/></a:solidFill></a:rPr>`;
5765
+ };
5766
+ let paragraphsXml = "";
5767
+ if (params.richSpans && params.richSpans.length > 0) {
5768
+ const runsXml = params.richSpans.map((sp) => {
5769
+ const spSz = Math.round(Math.max(4, sp.fontSize ?? fsPt) * 100);
5770
+ const spHex = toRgbHex6(sp.color, textCol)?.hex6 ?? textCol;
5771
+ const rPr = buildRunPr({
5772
+ szVal: spSz,
5773
+ bold: sp.bold ?? isBold,
5774
+ italic: sp.italic ?? isItalic,
5775
+ underline: sp.underline ?? isUnderline,
5776
+ hex6: spHex
5777
+ });
5778
+ return `<a:r>${rPr}<a:t>${escapeXml2(sp.text)}</a:t></a:r>`;
5779
+ }).join("");
5780
+ paragraphsXml = `<a:p><a:pPr algn="${algn}"/>${runsXml}<a:endParaRPr lang="zh-CN" sz="${sz}"/></a:p>`;
5781
+ } else {
5782
+ const lines = (params.text ?? "").replace(/\r\n?/g, "\n").split("\n");
5783
+ const rPr = buildRunPr({
5784
+ szVal: sz,
5785
+ bold: isBold,
5786
+ italic: isItalic,
5787
+ underline: isUnderline,
5788
+ hex6: textCol
5789
+ });
5790
+ paragraphsXml = lines.map(
5791
+ (ln) => `<a:p><a:pPr algn="${algn}"/>${ln.length > 0 ? `<a:r>${rPr}<a:t>${escapeXml2(ln)}</a:t></a:r>` : ""}<a:endParaRPr lang="zh-CN" sz="${sz}"/></a:p>`
5792
+ ).join("");
5793
+ }
5794
+ return [
5795
+ "<p:sp>",
5796
+ `<p:nvSpPr><p:cNvPr id="${params.shapeId}" name="${escapeXml2(params.name)}"/><p:cNvSpPr txBox="1"/><p:nvPr/></p:nvSpPr>`,
5797
+ `<p:spPr>${buildXfrmXml(
5798
+ "a",
5799
+ params.leftPt,
5800
+ params.topPt,
5801
+ params.widthPt,
5802
+ params.heightPt,
5803
+ params.angleDeg,
5804
+ params.flipX,
5805
+ params.flipY
5806
+ )}<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>${fillXml}${lineXml}</p:spPr>`,
5807
+ `<p:txBody><a:bodyPr wrap="${params.noWrap ? "none" : "square"}" lIns="${ins}" tIns="${ins}" rIns="${ins}" bIns="${ins}" anchor="${anchor}"/><a:lstStyle/>${paragraphsXml}</p:txBody>`,
5808
+ "</p:sp>"
5809
+ ].join("");
5810
+ }
5811
+ function buildTableGraphicFrameXml(shapeId, el, sampleData) {
5812
+ const cols = el.columns?.length ? el.columns : [{ id: "col-1", header: "Column 1", field: "col1", widthRatio: 1 }];
5813
+ const totalRatio = cols.reduce((sum, c) => sum + Math.max(0.1, c.widthRatio || 1), 0) || 1;
5814
+ const tableWidthEmu = Math.max(12700, ptToPptxEmu(el.transform.width));
5815
+ const colWidthsEmu = cols.map(
5816
+ (c) => Math.max(12700, Math.round(Math.max(0.1, c.widthRatio || 1) / totalRatio * tableWidthEmu))
5817
+ );
5818
+ const showHead = el.showHead !== false;
5819
+ const headerH = ptToPptxEmu(el.headerHeight ?? 26);
5820
+ const rowH = ptToPptxEmu(el.rowHeight ?? 24);
5821
+ const rawRows = resolveDynamicTableRawRows(el, sampleData);
5822
+ const formattedRows = rawRows.map((r) => cols.map((col, ci) => formatPdfTableCell(r[ci], col)));
5823
+ const totalTableHeightEmu = Math.max(
5824
+ ptToPptxEmu(el.transform.height),
5825
+ (showHead ? headerH : 0) + Math.max(1, formattedRows.length) * rowH
5826
+ );
5827
+ const borderHex = toRgbHex6(el.borderColor ?? "#CBD5E1", "CBD5E1")?.hex6 ?? "CBD5E1";
5828
+ const borderWidthEmu = Math.max(6350, ptToPptxEmu(el.borderWidth ?? 0.75));
5829
+ const cellBordersXml = ["lnL", "lnR", "lnT", "lnB"].map(
5830
+ (tag) => `<a:${tag} w="${borderWidthEmu}" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:srgbClr val="${borderHex}"/></a:solidFill></a:${tag}>`
5831
+ ).join("");
5832
+ const buildCellXml = (text, opts) => {
5833
+ const sz = Math.round(Math.max(4, opts.fontSizePt) * 100);
5834
+ const algn = mapTextAlignToDrawingMl(opts.align);
5835
+ const bgHex = toRgbHex6(opts.bgColor)?.hex6;
5836
+ const fillXml = bgHex ? `<a:solidFill><a:srgbClr val="${bgHex}"/></a:solidFill>` : "<a:noFill/>";
5837
+ const rPr = `<a:rPr lang="zh-CN" altLang="en-US" sz="${sz}"${opts.bold ? ' b="1"' : ""} dirty="0"><a:solidFill><a:srgbClr val="${opts.textHex}"/></a:solidFill></a:rPr>`;
5838
+ return [
5839
+ "<a:tc>",
5840
+ `<a:txBody><a:bodyPr/><a:lstStyle/><a:p><a:pPr algn="${algn}"/>${text ? `<a:r>${rPr}<a:t>${escapeXml2(text)}</a:t></a:r>` : ""}<a:endParaRPr lang="zh-CN" sz="${sz}"/></a:p></a:txBody>`,
5841
+ `<a:tcPr marL="45720" marR="45720" marT="22860" marB="22860" anchor="ctr">${cellBordersXml}${fillXml}</a:tcPr>`,
5842
+ "</a:tc>"
5843
+ ].join("");
5844
+ };
5845
+ const trXmlParts = [];
5846
+ if (showHead) {
5847
+ const headFs = el.headerStyle?.fontSize ?? 10;
5848
+ const headHex = toRgbHex6(el.headerStyle?.color, "1B1C1F")?.hex6 ?? "1B1C1F";
5849
+ const headBg = el.headerStyle?.backgroundColor ?? "#F1F5F9";
5850
+ const headCells = cols.map(
5851
+ (col) => buildCellXml(col.header ?? "", {
5852
+ fontSizePt: headFs,
5853
+ bold: (el.headerStyle?.fontWeight ?? "bold") === "bold",
5854
+ textHex: headHex,
5855
+ bgColor: headBg,
5856
+ align: col.align ?? "left"
5857
+ })
5858
+ ).join("");
5859
+ trXmlParts.push(`<a:tr h="${headerH}">${headCells}</a:tr>`);
5860
+ }
5861
+ const bodyFs = el.bodyStyle?.fontSize ?? 10;
5862
+ const bodyHex = toRgbHex6(el.bodyStyle?.color, "334155")?.hex6 ?? "334155";
5863
+ const bodyBold = el.bodyStyle?.fontWeight === "bold";
5864
+ const stripeBg = el.zebraStripeColor ?? el.stripedColor;
5865
+ const effectiveBodyRows = formattedRows.length > 0 ? formattedRows : [cols.map(() => "")];
5866
+ effectiveBodyRows.forEach((row, rIdx) => {
5867
+ const rowBg = rIdx % 2 === 1 && stripeBg ? stripeBg : el.bodyStyle?.backgroundColor;
5868
+ const cellsXml = cols.map(
5869
+ (col, cIdx) => buildCellXml(row[cIdx] ?? "", {
5870
+ fontSizePt: bodyFs,
5871
+ bold: bodyBold,
5872
+ textHex: bodyHex,
5873
+ bgColor: rowBg,
5874
+ align: col.align ?? "left"
5875
+ })
5876
+ ).join("");
5877
+ trXmlParts.push(`<a:tr h="${rowH}">${cellsXml}</a:tr>`);
5878
+ });
5879
+ const gridColsXml = colWidthsEmu.map((w) => `<a:gridCol w="${w}"/>`).join("");
5880
+ return [
5881
+ "<p:graphicFrame>",
5882
+ `<p:nvGraphicFramePr><p:cNvPr id="${shapeId}" name="${escapeXml2(el.name || "Table")}"/><p:cNvGraphicFramePr><a:graphicFrameLocks noGrp="1"/></p:cNvGraphicFramePr><p:nvPr/></p:nvGraphicFramePr>`,
5883
+ `<p:xfrm><a:off x="${ptToPptxEmu(el.transform.left)}" y="${ptToPptxEmu(el.transform.top)}"/><a:ext cx="${tableWidthEmu}" cy="${totalTableHeightEmu}"/></p:xfrm>`,
5884
+ '<a:graphic><a:graphicData uri="http://schemas.openxmlformats.org/presentationml/2006/table">',
5885
+ `<a:tbl><a:tblPr firstRow="${showHead ? 1 : 0}" bandRow="1"/><a:tblGrid>${gridColsXml}</a:tblGrid>${trXmlParts.join("")}</a:tbl>`,
5886
+ "</a:graphicData></a:graphic>",
5887
+ "</p:graphicFrame>"
5888
+ ].join("");
5889
+ }
5890
+ function buildPictureXml(params) {
5891
+ return [
5892
+ "<p:pic>",
5893
+ `<p:nvPicPr><p:cNvPr id="${params.shapeId}" name="${escapeXml2(params.name)}"/><p:cNvPicPr><a:picLocks noChangeAspect="0"/></p:cNvPicPr><p:nvPr/></p:nvPicPr>`,
5894
+ `<p:blipFill><a:blip r:embed="${params.rId}"/><a:stretch><a:fillRect/></a:stretch></p:blipFill>`,
5895
+ `<p:spPr>${buildXfrmXml(
5896
+ "a",
5897
+ params.leftPt,
5898
+ params.topPt,
5899
+ params.widthPt,
5900
+ params.heightPt,
5901
+ params.angleDeg,
5902
+ params.flipX,
5903
+ params.flipY
5904
+ )}<a:prstGeom prst="rect"><a:avLst/></a:prstGeom></p:spPr>`,
5905
+ "</p:pic>"
5906
+ ].join("");
5907
+ }
5908
+ function buildVectorGeomShapeXml(params) {
5909
+ const fillXml = params.prst === "line" ? "" : buildSolidFillXml(params.fillColor, params.opacity ?? 1);
5910
+ const lineXml = buildLineXml(params.strokeColor, params.strokeWidthPt ?? 1, {
5911
+ dash: params.dash,
5912
+ startArrow: params.startArrow,
5913
+ endArrow: params.endArrow,
5914
+ opacity: params.opacity ?? 1
5915
+ });
5916
+ const txBody = params.labelText ? `<p:txBody><a:bodyPr anchor="ctr"/><a:lstStyle/><a:p><a:pPr algn="ctr"/><a:r><a:rPr lang="zh-CN" sz="900" b="1"><a:solidFill><a:srgbClr val="${toRgbHex6(params.labelColor, "FFFFFF")?.hex6 ?? "FFFFFF"}"/></a:solidFill></a:rPr><a:t>${escapeXml2(params.labelText)}</a:t></a:r></a:p></p:txBody>` : "";
5917
+ return [
5918
+ "<p:sp>",
5919
+ `<p:nvSpPr><p:cNvPr id="${params.shapeId}" name="${escapeXml2(params.name)}"/><p:cNvSpPr/><p:nvPr/></p:nvSpPr>`,
5920
+ `<p:spPr>${buildXfrmXml(
5921
+ "a",
5922
+ params.leftPt,
5923
+ params.topPt,
5924
+ params.widthPt,
5925
+ params.heightPt,
5926
+ params.angleDeg,
5927
+ params.flipX,
5928
+ params.flipY
5929
+ )}<a:prstGeom prst="${params.prst}"><a:avLst/></a:prstGeom>${fillXml}${lineXml}</p:spPr>`,
5930
+ txBody,
5931
+ "</p:sp>"
5932
+ ].join("");
5933
+ }
5934
+ function convertPdfUnitToPptxBytes(unitData) {
5935
+ const enc = new TextEncoder();
5936
+ const rawPageOrder = unitData.document.pageOrder ?? [];
5937
+ const pageIds = rawPageOrder.length > 0 ? rawPageOrder : ["__empty_slide_1__"];
5938
+ const firstPage = rawPageOrder[0] ? unitData.document.pages[rawPageOrder[0]] : void 0;
5939
+ const presentationSize = firstPage?.pageSize ?? unitData.document.pageSize ?? {
5940
+ width: 595.28,
5941
+ height: 841.89
5942
+ };
5943
+ const sldCxEmu = Math.min(51206400, Math.max(914400, ptToPptxEmu(presentationSize.width)));
5944
+ const sldCyEmu = Math.min(51206400, Math.max(914400, ptToPptxEmu(presentationSize.height)));
5945
+ const suppressedSet = new Set(unitData.editState.suppressedSourceIds ?? []);
5946
+ const layersById = new Map((unitData.layers ?? []).map((l) => [l.id, l]));
5947
+ const sampleData = unitData.metadata?.sampleData;
5948
+ const rawSpansByPage = unitData.metadata?.nativeTextSpansByPage ?? unitData.editState.nativeTextSpansByPage ?? {};
5949
+ const mediaFiles = [];
5950
+ const mediaIndexBySrc = /* @__PURE__ */ new Map();
5951
+ const registerMediaDataUrl = (src) => {
5952
+ if (!src) return null;
5953
+ const cachedIdx = mediaIndexBySrc.get(src);
5954
+ if (cachedIdx !== void 0) {
5955
+ const m = mediaFiles[cachedIdx];
5956
+ return { fileName: m.fileName, ext: m.ext };
5957
+ }
5958
+ const parsed = parseRasterImageDataUrl(src);
5959
+ if (!parsed) return null;
5960
+ const nextNumber = mediaFiles.length + 1;
5961
+ const fileName = `image${nextNumber}.${parsed.ext}`;
5962
+ mediaIndexBySrc.set(src, mediaFiles.length);
5963
+ mediaFiles.push({ fileName, ext: parsed.ext, bytes: parsed.bytes });
5964
+ return { fileName, ext: parsed.ext };
5965
+ };
5966
+ const slideXmlEntries = [];
5967
+ pageIds.forEach((pageId, pageIndex) => {
5968
+ const pageMeta = unitData.document.pages[pageId];
5969
+ const pageCtx = { pageNumber: pageIndex + 1, totalPages: pageIds.length };
5970
+ const shapeXmlParts = [];
5971
+ const slideMediaRels = [];
5972
+ let nextShapeId = 2;
5973
+ let nextRelId = 2;
5974
+ const spans = rawSpansByPage[pageId] ?? [];
5975
+ for (const sp of spans) {
5976
+ if (sp.suppressed || suppressedSet.has(sp.id) || !sp.text.trim()) continue;
5977
+ const fs = sp.fontSize || 11;
5978
+ shapeXmlParts.push(
5979
+ buildTextBoxShapeXml({
5980
+ shapeId: nextShapeId++,
5981
+ name: `NativeText ${sp.id}`,
5982
+ leftPt: sp.left,
5983
+ topPt: sp.top,
5984
+ widthPt: Math.max(12, sp.width),
5985
+ heightPt: Math.max(10, sp.height),
5986
+ text: sp.text,
5987
+ style: {
5988
+ fontSize: fs,
5989
+ fontWeight: fs >= 14 ? "bold" : "normal",
5990
+ color: "#1B1C1F",
5991
+ textAlign: "left",
5992
+ verticalAlign: "middle",
5993
+ padding: 0
5994
+ },
5995
+ noWrap: true
5996
+ })
5997
+ );
5998
+ }
5999
+ const elMap = unitData.editState.elementsByPage[pageId] ?? {};
6000
+ const elOrder = unitData.editState.elementOrderByPage[pageId] ?? Object.keys(elMap);
6001
+ for (const elId of elOrder) {
6002
+ const el = elMap[elId];
6003
+ if (!el || el.hidden) continue;
6004
+ if (el.layerId) {
6005
+ const layer = layersById.get(el.layerId);
6006
+ if (layer && layer.visible === false && layer.printable === false) continue;
6007
+ }
6008
+ const tr = el.transform;
6009
+ const flipX = Boolean(tr.flipX ?? el.flipX);
6010
+ const flipY = Boolean(tr.flipY ?? el.flipY);
6011
+ if (el.type === "text" /* TEXT */) {
6012
+ const resolvedText = resolveTemplateString(
6013
+ el.content ?? "",
6014
+ el.fieldKey || el.bindingField,
6015
+ sampleData,
6016
+ pageCtx
6017
+ );
6018
+ shapeXmlParts.push(
6019
+ buildTextBoxShapeXml({
6020
+ shapeId: nextShapeId++,
6021
+ name: el.name || `Text ${el.id}`,
6022
+ leftPt: tr.left,
6023
+ topPt: tr.top,
6024
+ widthPt: tr.width,
6025
+ heightPt: tr.height,
6026
+ angleDeg: tr.angle,
6027
+ flipX,
6028
+ flipY,
6029
+ text: resolvedText,
6030
+ style: el.style,
6031
+ richSpans: el.richSpans,
6032
+ opacity: el.opacity
6033
+ })
6034
+ );
6035
+ } else if (el.type === "list" /* LIST */) {
6036
+ const listLines = (el.items ?? []).map(
6037
+ (item, idx) => el.listType === "ordered" ? `${(el.startNumber ?? 1) + idx}. ${item}` : el.listType === "check" ? `[x] ${item}` : `\u2022 ${item}`
6038
+ );
6039
+ shapeXmlParts.push(
6040
+ buildTextBoxShapeXml({
6041
+ shapeId: nextShapeId++,
6042
+ name: el.name || `List ${el.id}`,
6043
+ leftPt: tr.left,
6044
+ topPt: tr.top,
6045
+ widthPt: tr.width,
6046
+ heightPt: tr.height,
6047
+ angleDeg: tr.angle,
6048
+ flipX,
6049
+ flipY,
6050
+ text: listLines.join("\n"),
6051
+ style: { verticalAlign: "top", ...el.style ?? {} },
6052
+ opacity: el.opacity
6053
+ })
6054
+ );
6055
+ } else if (el.type === "dateTime" /* DATE_TIME */) {
6056
+ const formattedDt = formatPdfDateTimeValue(el.value, el.format, el.dateKind, el.locale);
6057
+ shapeXmlParts.push(
6058
+ buildTextBoxShapeXml({
6059
+ shapeId: nextShapeId++,
6060
+ name: el.name || `DateTime ${el.id}`,
6061
+ leftPt: tr.left,
6062
+ topPt: tr.top,
6063
+ widthPt: tr.width,
6064
+ heightPt: tr.height,
6065
+ angleDeg: tr.angle,
6066
+ flipX,
6067
+ flipY,
6068
+ text: formattedDt || el.value || "",
6069
+ style: {
6070
+ fontSize: el.fontSize ?? el.style?.fontSize ?? 11,
6071
+ color: el.color ?? el.style?.color ?? "#1B1C1F",
6072
+ backgroundColor: el.backgroundColor ?? el.style?.backgroundColor,
6073
+ textAlign: el.align ?? el.style?.textAlign ?? "left",
6074
+ verticalAlign: "middle"
6075
+ },
6076
+ opacity: el.opacity
6077
+ })
6078
+ );
6079
+ } else if (el.type === "checkbox" /* CHECKBOX */ || el.type === "radioGroup" /* RADIO_GROUP */ || el.type === "select" /* SELECT */) {
6080
+ const widgetText = el.type === "checkbox" /* CHECKBOX */ ? `${el.checked ? "[X]" : "[ ]"} ${el.label || ""}`.trim() : el.value || "";
6081
+ shapeXmlParts.push(
6082
+ buildTextBoxShapeXml({
6083
+ shapeId: nextShapeId++,
6084
+ name: el.name || `Form ${el.id}`,
6085
+ leftPt: tr.left,
6086
+ topPt: tr.top,
6087
+ widthPt: tr.width,
6088
+ heightPt: tr.height,
6089
+ angleDeg: tr.angle,
6090
+ text: widgetText,
6091
+ style: el.style ?? { fontSize: 10.5, color: "#1B1C1F" }
6092
+ })
6093
+ );
6094
+ } else if (el.type === "table" /* TABLE */) {
6095
+ shapeXmlParts.push(buildTableGraphicFrameXml(nextShapeId++, el, sampleData));
6096
+ } else if (el.type === "shape" /* SHAPE */) {
6097
+ const prst = el.shapeType === "ellipse" ? "ellipse" : el.shapeType === "line" ? "line" : (el.borderRadius ?? 0) > 0 ? "roundRect" : "rect";
6098
+ shapeXmlParts.push(
6099
+ buildVectorGeomShapeXml({
6100
+ shapeId: nextShapeId++,
6101
+ name: el.name || `Shape ${el.id}`,
6102
+ prst,
6103
+ leftPt: tr.left,
6104
+ topPt: tr.top,
6105
+ widthPt: tr.width,
6106
+ heightPt: tr.height,
6107
+ angleDeg: tr.angle,
6108
+ flipX,
6109
+ flipY,
6110
+ fillColor: el.fillColor,
6111
+ strokeColor: el.strokeColor,
6112
+ strokeWidthPt: el.strokeWidth ?? 1,
6113
+ dash: Boolean(el.dashArray?.length),
6114
+ startArrow: el.startArrow,
6115
+ endArrow: el.endArrow,
6116
+ opacity: el.shapeType === "highlight" ? el.opacity ?? 0.38 : el.opacity ?? 1
6117
+ })
6118
+ );
6119
+ } else if (el.type === "line" /* LINE */) {
6120
+ shapeXmlParts.push(
6121
+ buildVectorGeomShapeXml({
6122
+ shapeId: nextShapeId++,
6123
+ name: el.name || `Line ${el.id}`,
6124
+ prst: "line",
6125
+ leftPt: tr.left,
6126
+ topPt: tr.top,
6127
+ widthPt: tr.width,
6128
+ heightPt: Math.max(1, tr.height),
6129
+ angleDeg: tr.angle,
6130
+ flipX,
6131
+ flipY,
6132
+ strokeColor: el.strokeColor ?? "#2563EB",
6133
+ strokeWidthPt: el.strokeWidth ?? 1.5,
6134
+ dash: Boolean(el.dashArray?.length),
6135
+ startArrow: el.startArrow,
6136
+ endArrow: el.endArrow,
6137
+ opacity: el.opacity ?? 1
6138
+ })
6139
+ );
6140
+ } else if (el.type === "ellipse" /* ELLIPSE */) {
6141
+ shapeXmlParts.push(
6142
+ buildVectorGeomShapeXml({
6143
+ shapeId: nextShapeId++,
6144
+ name: el.name || `Ellipse ${el.id}`,
6145
+ prst: "ellipse",
6146
+ leftPt: tr.left,
6147
+ topPt: tr.top,
6148
+ widthPt: tr.width,
6149
+ heightPt: tr.height,
6150
+ angleDeg: tr.angle,
6151
+ flipX,
6152
+ flipY,
6153
+ fillColor: el.fillColor,
6154
+ strokeColor: el.strokeColor ?? "#2563EB",
6155
+ strokeWidthPt: el.strokeWidth ?? 1.5,
6156
+ dash: Boolean(el.dashArray?.length),
6157
+ opacity: el.opacity ?? 1
6158
+ })
6159
+ );
6160
+ } else if (el.type === "redaction" /* REDACTION */) {
6161
+ shapeXmlParts.push(
6162
+ buildVectorGeomShapeXml({
6163
+ shapeId: nextShapeId++,
6164
+ name: el.name || `Redaction ${el.id}`,
6165
+ prst: "rect",
6166
+ leftPt: tr.left,
6167
+ topPt: tr.top,
6168
+ widthPt: tr.width,
6169
+ heightPt: tr.height,
6170
+ fillColor: el.fillColor ?? "#000000",
6171
+ strokeColor: el.fillColor ?? "#000000",
6172
+ strokeWidthPt: 1,
6173
+ labelText: el.overlayLabel ?? "[CONFIDENTIAL]",
6174
+ labelColor: "#FFFFFF"
6175
+ })
6176
+ );
6177
+ } else if (el.type === "stamp" /* STAMP */) {
6178
+ const stampLines = [
6179
+ el.primaryText,
6180
+ el.secondaryText,
6181
+ [el.signer, el.dateText].filter(Boolean).join(" \xB7 ")
6182
+ ].filter(Boolean);
6183
+ shapeXmlParts.push(
6184
+ buildTextBoxShapeXml({
6185
+ shapeId: nextShapeId++,
6186
+ name: el.name || `Stamp ${el.id}`,
6187
+ leftPt: tr.left,
6188
+ topPt: tr.top,
6189
+ widthPt: tr.width,
6190
+ heightPt: tr.height,
6191
+ angleDeg: tr.angle,
6192
+ text: stampLines.join("\n"),
6193
+ style: {
6194
+ fontSize: 10,
6195
+ fontWeight: "bold",
6196
+ color: el.color ?? "#DC2626",
6197
+ borderColor: el.color ?? "#DC2626",
6198
+ borderWidth: 1.5,
6199
+ textAlign: "center",
6200
+ verticalAlign: "middle"
6201
+ },
6202
+ opacity: el.opacity ?? 0.9
6203
+ })
6204
+ );
6205
+ } else if (el.type === "image" /* IMAGE */ || el.type === "signature" /* SIGNATURE */) {
6206
+ const rawSrc = el.type === "image" /* IMAGE */ ? el.src || (el.resourceId ? unitData.resourceBindings?.[el.resourceId]?.dataUri : void 0) : el.signatureDataUri;
6207
+ const registered = registerMediaDataUrl(rawSrc);
6208
+ if (registered) {
6209
+ const rId = `rId${nextRelId++}`;
6210
+ slideMediaRels.push({ rId, target: `../media/${registered.fileName}` });
6211
+ shapeXmlParts.push(
6212
+ buildPictureXml({
6213
+ shapeId: nextShapeId++,
6214
+ name: el.name || el.altText || `Picture ${el.id}`,
6215
+ rId,
6216
+ leftPt: tr.left,
6217
+ topPt: tr.top,
6218
+ widthPt: tr.width,
6219
+ heightPt: tr.height,
6220
+ angleDeg: tr.angle,
6221
+ flipX,
6222
+ flipY
6223
+ })
6224
+ );
6225
+ } else if (el.type === "signature" /* SIGNATURE */ && (el.signerName || el.label)) {
6226
+ shapeXmlParts.push(
6227
+ buildTextBoxShapeXml({
6228
+ shapeId: nextShapeId++,
6229
+ name: el.name || `Signature ${el.id}`,
6230
+ leftPt: tr.left,
6231
+ topPt: tr.top,
6232
+ widthPt: tr.width,
6233
+ heightPt: tr.height,
6234
+ text: el.signerName ? `Signed: ${el.signerName}` : el.label ?? "Signature",
6235
+ style: { fontSize: 10, color: "#31363F", borderColor: "#7D8698", borderWidth: 1 }
6236
+ })
6237
+ );
6238
+ }
6239
+ }
6240
+ }
6241
+ const bgHex = pageMeta?.backgroundColor && pageMeta.backgroundColor.toLowerCase() !== "#ffffff" ? toRgbHex6(pageMeta.backgroundColor)?.hex6 : void 0;
6242
+ const bgXml = bgHex ? `<p:bg><p:bgPr><a:solidFill><a:srgbClr val="${bgHex}"/></a:solidFill><a:effectLst/></p:bgPr></p:bg>` : "";
6243
+ const slideXml = [
6244
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',
6245
+ '<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">',
6246
+ `<p:cSld>${bgXml}<p:spTree>`,
6247
+ '<p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr>',
6248
+ '<p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr>',
6249
+ shapeXmlParts.join(""),
6250
+ "</p:spTree></p:cSld>",
6251
+ "<p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>",
6252
+ "</p:sld>"
6253
+ ].join("");
6254
+ const slideRelsXml = [
6255
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',
6256
+ '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">',
6257
+ '<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="../slideLayouts/slideLayout1.xml"/>',
6258
+ ...slideMediaRels.map(
6259
+ (rel) => `<Relationship Id="${rel.rId}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="${rel.target}"/>`
6260
+ ),
6261
+ "</Relationships>"
6262
+ ].join("");
6263
+ slideXmlEntries.push({ slideXml, slideRelsXml });
6264
+ });
6265
+ const slideCount = slideXmlEntries.length;
6266
+ const sldIdListXml = slideXmlEntries.map((_, idx) => `<p:sldId id="${256 + idx}" r:id="rId${idx + 2}"/>`).join("");
6267
+ const presentationXml = [
6268
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',
6269
+ '<p:presentation xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" saveSubsetFonts="1">',
6270
+ '<p:sldMasterIdLst><p:sldMasterId id="2147483648" r:id="rId1"/></p:sldMasterIdLst>',
6271
+ `<p:sldIdLst>${sldIdListXml}</p:sldIdLst>`,
6272
+ `<p:sldSz cx="${sldCxEmu}" cy="${sldCyEmu}"/>`,
6273
+ '<p:notesSz cx="6858000" cy="9144000"/>',
6274
+ "<p:defaultTextStyle/>",
6275
+ "</p:presentation>"
6276
+ ].join("");
6277
+ const presRelNextBase = slideCount + 2;
6278
+ const presentationRelsXml = [
6279
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',
6280
+ '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">',
6281
+ '<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" Target="slideMasters/slideMaster1.xml"/>',
6282
+ ...slideXmlEntries.map(
6283
+ (_, idx) => `<Relationship Id="rId${idx + 2}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/slide${idx + 1}.xml"/>`
6284
+ ),
6285
+ `<Relationship Id="rId${presRelNextBase}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps" Target="presProps.xml"/>`,
6286
+ `<Relationship Id="rId${presRelNextBase + 1}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps" Target="viewProps.xml"/>`,
6287
+ `<Relationship Id="rId${presRelNextBase + 2}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles" Target="tableStyles.xml"/>`,
6288
+ `<Relationship Id="rId${presRelNextBase + 3}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml"/>`,
6289
+ "</Relationships>"
6290
+ ].join("");
6291
+ const contentTypesXml = [
6292
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',
6293
+ '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">',
6294
+ '<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>',
6295
+ '<Default Extension="xml" ContentType="application/xml"/>',
6296
+ '<Default Extension="png" ContentType="image/png"/>',
6297
+ '<Default Extension="jpg" ContentType="image/jpeg"/>',
6298
+ '<Default Extension="jpeg" ContentType="image/jpeg"/>',
6299
+ '<Override PartName="/ppt/presentation.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"/>',
6300
+ '<Override PartName="/ppt/slideMasters/slideMaster1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml"/>',
6301
+ '<Override PartName="/ppt/slideLayouts/slideLayout1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/>',
6302
+ '<Override PartName="/ppt/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/>',
6303
+ '<Override PartName="/ppt/presProps.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.presProps+xml"/>',
6304
+ '<Override PartName="/ppt/viewProps.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml"/>',
6305
+ '<Override PartName="/ppt/tableStyles.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml"/>',
6306
+ '<Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>',
6307
+ '<Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/>',
6308
+ ...slideXmlEntries.map(
6309
+ (_, idx) => `<Override PartName="/ppt/slides/slide${idx + 1}.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slide+xml"/>`
6310
+ ),
6311
+ "</Types>"
6312
+ ].join("");
6313
+ const rootRelsXml = [
6314
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',
6315
+ '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">',
6316
+ '<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="ppt/presentation.xml"/>',
6317
+ '<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>',
6318
+ '<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>',
6319
+ "</Relationships>"
6320
+ ].join("");
6321
+ const slideMasterXml = [
6322
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',
6323
+ '<p:sldMaster xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">',
6324
+ '<p:cSld><p:bg><p:bgRef idx="1001"><a:schemeClr val="bg1"/></p:bgRef></p:bg><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr></p:spTree></p:cSld>',
6325
+ '<p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/>',
6326
+ '<p:sldLayoutIdLst><p:sldLayoutId id="2147483649" r:id="rId1"/></p:sldLayoutIdLst>',
6327
+ "</p:sldMaster>"
6328
+ ].join("");
6329
+ const slideMasterRelsXml = [
6330
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',
6331
+ '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">',
6332
+ '<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="../slideLayouts/slideLayout1.xml"/>',
6333
+ '<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="../theme/theme1.xml"/>',
6334
+ "</Relationships>"
6335
+ ].join("");
6336
+ const slideLayoutXml = [
6337
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',
6338
+ '<p:sldLayout xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" type="blank" preserve="1">',
6339
+ '<p:cSld name="Blank"><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr></p:spTree></p:cSld>',
6340
+ "<p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>",
6341
+ "</p:sldLayout>"
6342
+ ].join("");
6343
+ const slideLayoutRelsXml = [
6344
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',
6345
+ '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">',
6346
+ '<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" Target="../slideMasters/slideMaster1.xml"/>',
6347
+ "</Relationships>"
6348
+ ].join("");
6349
+ const themeXml = [
6350
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',
6351
+ '<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Univer PDF Theme">',
6352
+ "<a:themeElements>",
6353
+ '<a:clrScheme name="Standard"><a:dk1><a:srgbClr val="1B1C1F"/></a:dk1><a:lt1><a:srgbClr val="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="31363F"/></a:dk2><a:lt2><a:srgbClr val="F9FAFB"/></a:lt2><a:accent1><a:srgbClr val="2C53F1"/></a:accent1><a:accent2><a:srgbClr val="16A34A"/></a:accent2><a:accent3><a:srgbClr val="DC2626"/></a:accent3><a:accent4><a:srgbClr val="EA580C"/></a:accent4><a:accent5><a:srgbClr val="0D9488"/></a:accent5><a:accent6><a:srgbClr val="4F46E5"/></a:accent6><a:hlink><a:srgbClr val="2563EB"/></a:hlink><a:folHlink><a:srgbClr val="4F46E5"/></a:folHlink></a:clrScheme>',
6354
+ '<a:fontScheme name="Standard"><a:majorFont><a:latin typeface="Calibri"/><a:ea typeface="PingFang SC"/><a:cs typeface=""/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface="PingFang SC"/><a:cs typeface=""/></a:minorFont></a:fontScheme>',
6355
+ '<a:fmtScheme name="Standard"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:fillStyleLst><a:lnStyleLst><a:ln w="9525"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln><a:ln w="19050"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln><a:ln w="25400"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:bgFillStyleLst></a:fmtScheme>',
6356
+ "</a:themeElements>",
6357
+ "</a:theme>"
6358
+ ].join("");
6359
+ const presPropsXml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><p:presentationPr xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"/>';
6360
+ const viewPropsXml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><p:viewPr xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"/>';
6361
+ const tableStylesXml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><a:tblStyleLst xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" def="{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}"/>';
6362
+ const docTitle = escapeXml2(unitData.name || "Converted Presentation");
6363
+ const coreXml = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:title>${docTitle}</dc:title><dc:creator>Univer PDFs</dc:creator></cp:coreProperties>`;
6364
+ const appXml = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"><Application>Univer PDFs</Application><Slides>${slideCount}</Slides></Properties>`;
6365
+ const entries = [
6366
+ { path: "[Content_Types].xml", data: enc.encode(contentTypesXml) },
6367
+ { path: "_rels/.rels", data: enc.encode(rootRelsXml) },
6368
+ { path: "docProps/core.xml", data: enc.encode(coreXml) },
6369
+ { path: "docProps/app.xml", data: enc.encode(appXml) },
6370
+ { path: "ppt/presentation.xml", data: enc.encode(presentationXml) },
6371
+ { path: "ppt/_rels/presentation.xml.rels", data: enc.encode(presentationRelsXml) },
6372
+ { path: "ppt/presProps.xml", data: enc.encode(presPropsXml) },
6373
+ { path: "ppt/viewProps.xml", data: enc.encode(viewPropsXml) },
6374
+ { path: "ppt/tableStyles.xml", data: enc.encode(tableStylesXml) },
6375
+ { path: "ppt/slideMasters/slideMaster1.xml", data: enc.encode(slideMasterXml) },
6376
+ { path: "ppt/slideMasters/_rels/slideMaster1.xml.rels", data: enc.encode(slideMasterRelsXml) },
6377
+ { path: "ppt/slideLayouts/slideLayout1.xml", data: enc.encode(slideLayoutXml) },
6378
+ { path: "ppt/slideLayouts/_rels/slideLayout1.xml.rels", data: enc.encode(slideLayoutRelsXml) },
6379
+ { path: "ppt/theme/theme1.xml", data: enc.encode(themeXml) }
6380
+ ];
6381
+ slideXmlEntries.forEach((s, idx) => {
6382
+ entries.push({
6383
+ path: `ppt/slides/slide${idx + 1}.xml`,
6384
+ data: enc.encode(s.slideXml)
6385
+ });
6386
+ entries.push({
6387
+ path: `ppt/slides/_rels/slide${idx + 1}.xml.rels`,
6388
+ data: enc.encode(s.slideRelsXml)
6389
+ });
6390
+ });
6391
+ for (const media of mediaFiles) {
6392
+ entries.push({
6393
+ path: `ppt/media/${media.fileName}`,
6394
+ data: media.bytes
6395
+ });
6396
+ }
6397
+ return buildPptxZipArchive(entries);
6398
+ }
6399
+ async function convertPdfBytesToPptxBytes(pdfBytes, options) {
6400
+ const unit = await importPdfBytesToUnit(pdfBytes, {
6401
+ password: options?.password
6402
+ });
6403
+ return convertPdfUnitToPptxBytes(unit);
6404
+ }
6405
+
6406
+ // src/exporter/pdf-convert-and-compliance.ts
4990
6407
  function collectOrderedPageFragments(unit, pageId, pageIndex) {
4991
6408
  const suppressed = new Set(unit.editState.suppressedSourceIds ?? []);
4992
6409
  const layersById = new Map((unit.layers ?? []).map((l) => [l.id, l]));
@@ -5332,7 +6749,7 @@ function exportPdfToDocxSnapshot(unit) {
5332
6749
  const sectionIndex = dataStream.length;
5333
6750
  dataStream += "\n";
5334
6751
  return {
5335
- id: `doc-${unit.id || generateRandomId5(6)}`,
6752
+ id: `doc-${unit.id || generateRandomId6(6)}`,
5336
6753
  title: word.title,
5337
6754
  body: {
5338
6755
  dataStream,
@@ -5388,7 +6805,7 @@ function exportPdfToWorkbookSnapshot(unit) {
5388
6805
  };
5389
6806
  });
5390
6807
  return {
5391
- id: `wb-${unit.id || generateRandomId5(6)}`,
6808
+ id: `wb-${unit.id || generateRandomId6(6)}`,
5392
6809
  name: converted.name,
5393
6810
  appVersion: "1.6.204",
5394
6811
  sheetOrder,
@@ -5603,13 +7020,13 @@ async function applyOcrToUnitPage(unit, pageIndex, mode, adapter) {
5603
7020
  widthMm: ptToMm(pSize.width),
5604
7021
  heightMm: ptToMm(pSize.height),
5605
7022
  sourceDataUri: unit.sourceDocumentRef?.dataUri,
5606
- snapshot: Tools4.deepClone(unit)
7023
+ snapshot: Tools5.deepClone(unit)
5607
7024
  });
5608
- const next = Tools4.deepClone(unit);
7025
+ const next = Tools5.deepClone(unit);
5609
7026
  if (!next.editState.elementsByPage[pageId]) next.editState.elementsByPage[pageId] = {};
5610
7027
  if (!next.editState.elementOrderByPage[pageId]) next.editState.elementOrderByPage[pageId] = [];
5611
7028
  if (mode === "searchable") {
5612
- const rawMap = Tools4.deepClone(
7029
+ const rawMap = Tools5.deepClone(
5613
7030
  next.metadata?.nativeTextSpansByPage ?? next.editState.nativeTextSpansByPage ?? {}
5614
7031
  );
5615
7032
  if (!rawMap[pageId]) rawMap[pageId] = [];
@@ -5617,7 +7034,7 @@ async function applyOcrToUnitPage(unit, pageIndex, mode, adapter) {
5617
7034
  if (!blk.text?.trim()) continue;
5618
7035
  const heightPt = Math.max(8, mmToPt(blk.heightMm || 5));
5619
7036
  const span = {
5620
- id: `ocr-span-${generateRandomId5(6)}`,
7037
+ id: `ocr-span-${generateRandomId6(6)}`,
5621
7038
  pageId,
5622
7039
  pageIndex,
5623
7040
  text: blk.text.trim(),
@@ -5631,15 +7048,15 @@ async function applyOcrToUnitPage(unit, pageIndex, mode, adapter) {
5631
7048
  };
5632
7049
  rawMap[pageId].push(span);
5633
7050
  }
5634
- next.editState.nativeTextSpansByPage = Tools4.deepClone(rawMap);
7051
+ next.editState.nativeTextSpansByPage = Tools5.deepClone(rawMap);
5635
7052
  next.metadata = {
5636
7053
  ...next.metadata ?? {},
5637
- nativeTextSpansByPage: Tools4.deepClone(rawMap)
7054
+ nativeTextSpansByPage: Tools5.deepClone(rawMap)
5638
7055
  };
5639
7056
  } else {
5640
7057
  for (const blk of blocks) {
5641
7058
  if (!blk.text?.trim()) continue;
5642
- const elId = `ocr-el-${generateRandomId5(6)}`;
7059
+ const elId = `ocr-el-${generateRandomId6(6)}`;
5643
7060
  const heightPt = Math.max(12, mmToPt(blk.heightMm || 6));
5644
7061
  const fontSize = Math.round(Math.max(8, Math.min(24, heightPt * 0.72)) * 10) / 10;
5645
7062
  next.editState.elementsByPage[pageId][elId] = {
@@ -5677,7 +7094,7 @@ function sanitizePdfUnit(unit, options) {
5677
7094
  const stripAuthorHistory = options?.stripAuthorHistory !== false;
5678
7095
  const stripScripts = options?.stripScripts !== false;
5679
7096
  const stripSampleData = Boolean(options?.stripSampleData);
5680
- const next = Tools4.deepClone(unit);
7097
+ const next = Tools5.deepClone(unit);
5681
7098
  if (stripAttachments) {
5682
7099
  delete next.attachments;
5683
7100
  }
@@ -5713,7 +7130,7 @@ function sanitizePdfUnit(unit, options) {
5713
7130
  for (const pid of Object.keys(spansObj)) {
5714
7131
  spansObj[pid] = (spansObj[pid] ?? []).filter((s) => !s.suppressed && !suppressedSet.has(s.id));
5715
7132
  }
5716
- next.editState.nativeTextSpansByPage = Tools4.deepClone(spansObj);
7133
+ next.editState.nativeTextSpansByPage = Tools5.deepClone(spansObj);
5717
7134
  }
5718
7135
  next.metadata = cleanMeta;
5719
7136
  for (const pid of next.document.pageOrder) {
@@ -5756,7 +7173,7 @@ function optimizePdfUnit(unit, options) {
5756
7173
  const dedup = options?.deduplicateResources !== false;
5757
7174
  const pruneRes = options?.pruneUnusedResources !== false;
5758
7175
  const prunePages = options?.pruneOrphanedPages !== false;
5759
- const next = Tools4.deepClone(unit);
7176
+ const next = Tools5.deepClone(unit);
5760
7177
  const validPageSet = new Set(next.document.pageOrder);
5761
7178
  if (prunePages) {
5762
7179
  for (const pid of Object.keys(next.document.pages)) {
@@ -5830,10 +7247,10 @@ function optimizePdfUnit(unit, options) {
5830
7247
  return next;
5831
7248
  }
5832
7249
  function applyRedactRegexOnUnit(unit, pattern, flags = "gi", overlayLabel = "[REDACTED]", fillColor = "#000000") {
5833
- const next = Tools4.deepClone(unit);
7250
+ const next = Tools5.deepClone(unit);
5834
7251
  const safeFlags = flags.includes("g") ? flags : `${flags}g`;
5835
7252
  const re = new RegExp(pattern, safeFlags);
5836
- const rawSpansMap = Tools4.deepClone(
7253
+ const rawSpansMap = Tools5.deepClone(
5837
7254
  next.metadata?.nativeTextSpansByPage ?? next.editState.nativeTextSpansByPage ?? {}
5838
7255
  );
5839
7256
  const suppressed = new Set(next.editState.suppressedSourceIds ?? []);
@@ -5846,7 +7263,7 @@ function applyRedactRegexOnUnit(unit, pattern, flags = "gi", overlayLabel = "[RE
5846
7263
  if (el.hidden || el.type !== "text" /* TEXT */) continue;
5847
7264
  if (re.test(el.content)) {
5848
7265
  re.lastIndex = 0;
5849
- const redId = `redact-${generateRandomId5(6)}`;
7266
+ const redId = `redact-${generateRandomId6(6)}`;
5850
7267
  pageMap[redId] = {
5851
7268
  id: redId,
5852
7269
  type: "redaction" /* REDACTION */,
@@ -5863,7 +7280,7 @@ function applyRedactRegexOnUnit(unit, pattern, flags = "gi", overlayLabel = "[RE
5863
7280
  if (span.suppressed || suppressed.has(span.id)) continue;
5864
7281
  if (re.test(span.text)) {
5865
7282
  re.lastIndex = 0;
5866
- const redId = `redact-${generateRandomId5(6)}`;
7283
+ const redId = `redact-${generateRandomId6(6)}`;
5867
7284
  pageMap[redId] = {
5868
7285
  id: redId,
5869
7286
  type: "redaction" /* REDACTION */,
@@ -5886,7 +7303,7 @@ function applyRedactRegexOnUnit(unit, pattern, flags = "gi", overlayLabel = "[RE
5886
7303
  return next;
5887
7304
  }
5888
7305
  function flattenFormsOnUnit(unit) {
5889
- const next = Tools4.deepClone(unit);
7306
+ const next = Tools5.deepClone(unit);
5890
7307
  for (const pid of next.document.pageOrder) {
5891
7308
  const map = next.editState.elementsByPage[pid] ?? {};
5892
7309
  for (const [id, el] of Object.entries(map)) {
@@ -5923,7 +7340,7 @@ async function runPdfBatchPipeline(files, actions, baseExportOptions) {
5923
7340
  for (const file of files) {
5924
7341
  let workingUnit;
5925
7342
  if (file.unit) {
5926
- workingUnit = Tools4.deepClone(file.unit);
7343
+ workingUnit = Tools5.deepClone(file.unit);
5927
7344
  } else if (file.pdfBytes) {
5928
7345
  workingUnit = await importAcroFormPdfToUnit(file.pdfBytes, { title: file.name });
5929
7346
  } else {
@@ -6031,26 +7448,26 @@ function bytesToBase64Pure(bytes) {
6031
7448
  return btoa(bin);
6032
7449
  }
6033
7450
  async function extractAttachmentsFromPdfBytes(pdfBytes) {
6034
- const doc = await PDFDocument3.load(pdfBytes, { ignoreEncryption: true });
6035
- const namesDict = doc.context.lookupMaybe(doc.catalog.get(PDFName3.of("Names")), PDFDict3);
7451
+ const doc = await PDFDocument4.load(pdfBytes, { ignoreEncryption: true });
7452
+ const namesDict = doc.context.lookupMaybe(doc.catalog.get(PDFName4.of("Names")), PDFDict4);
6036
7453
  if (!namesDict) return [];
6037
- const efTree = doc.context.lookupMaybe(namesDict.get(PDFName3.of("EmbeddedFiles")), PDFDict3);
7454
+ const efTree = doc.context.lookupMaybe(namesDict.get(PDFName4.of("EmbeddedFiles")), PDFDict4);
6038
7455
  if (!efTree) return [];
6039
7456
  const out = [];
6040
7457
  const collectFromNode = (node) => {
6041
- const namesArr = doc.context.lookupMaybe(node.get(PDFName3.of("Names")), PDFArray3);
7458
+ const namesArr = doc.context.lookupMaybe(node.get(PDFName4.of("Names")), PDFArray4);
6042
7459
  if (namesArr) {
6043
7460
  for (let i = 0; i + 1 < namesArr.size(); i += 2) {
6044
7461
  const keyObj = namesArr.get(i);
6045
- const fsDict = doc.context.lookupMaybe(namesArr.get(i + 1), PDFDict3);
7462
+ const fsDict = doc.context.lookupMaybe(namesArr.get(i + 1), PDFDict4);
6046
7463
  if (!fsDict) continue;
6047
- const ufObj = fsDict.get(PDFName3.of("UF")) ?? fsDict.get(PDFName3.of("F")) ?? keyObj;
6048
- const fileName = ufObj instanceof PDFHexString3 || ufObj instanceof PDFString3 ? ufObj.decodeText() : String(ufObj);
6049
- const descObj = fsDict.get(PDFName3.of("Desc"));
6050
- const description = descObj instanceof PDFHexString3 || descObj instanceof PDFString3 ? descObj.decodeText() : void 0;
6051
- const efDict = doc.context.lookupMaybe(fsDict.get(PDFName3.of("EF")), PDFDict3);
6052
- const streamEntry = efDict?.get(PDFName3.of("UF")) ?? efDict?.get(PDFName3.of("F"));
6053
- const resolvedStream = streamEntry instanceof PDFRef3 ? doc.context.lookup(streamEntry) : streamEntry;
7464
+ const ufObj = fsDict.get(PDFName4.of("UF")) ?? fsDict.get(PDFName4.of("F")) ?? keyObj;
7465
+ const fileName = ufObj instanceof PDFHexString4 || ufObj instanceof PDFString4 ? ufObj.decodeText() : String(ufObj);
7466
+ const descObj = fsDict.get(PDFName4.of("Desc"));
7467
+ const description = descObj instanceof PDFHexString4 || descObj instanceof PDFString4 ? descObj.decodeText() : void 0;
7468
+ const efDict = doc.context.lookupMaybe(fsDict.get(PDFName4.of("EF")), PDFDict4);
7469
+ const streamEntry = efDict?.get(PDFName4.of("UF")) ?? efDict?.get(PDFName4.of("F"));
7470
+ const resolvedStream = streamEntry instanceof PDFRef4 ? doc.context.lookup(streamEntry) : streamEntry;
6054
7471
  if (!(resolvedStream instanceof PDFRawStream2)) continue;
6055
7472
  const rawStream = resolvedStream;
6056
7473
  let decoded;
@@ -6060,10 +7477,10 @@ async function extractAttachmentsFromPdfBytes(pdfBytes) {
6060
7477
  } catch {
6061
7478
  decoded = rawStream.contents;
6062
7479
  }
6063
- const subObj = rawStream.dict.get(PDFName3.of("Subtype"));
6064
- const mimeType = subObj instanceof PDFName3 ? subObj.decodeText().replace(/#2F/gi, "/") : "application/octet-stream";
7480
+ const subObj = rawStream.dict.get(PDFName4.of("Subtype"));
7481
+ const mimeType = subObj instanceof PDFName4 ? subObj.decodeText().replace(/#2F/gi, "/") : "application/octet-stream";
6065
7482
  out.push({
6066
- id: `att-${generateRandomId5(6)}`,
7483
+ id: `att-${generateRandomId6(6)}`,
6067
7484
  fileName,
6068
7485
  mimeType,
6069
7486
  dataBase64: bytesToBase64Pure(decoded),
@@ -6071,10 +7488,10 @@ async function extractAttachmentsFromPdfBytes(pdfBytes) {
6071
7488
  });
6072
7489
  }
6073
7490
  }
6074
- const kidsArr = doc.context.lookupMaybe(node.get(PDFName3.of("Kids")), PDFArray3);
7491
+ const kidsArr = doc.context.lookupMaybe(node.get(PDFName4.of("Kids")), PDFArray4);
6075
7492
  if (kidsArr) {
6076
7493
  for (let k = 0; k < kidsArr.size(); k++) {
6077
- const child = doc.context.lookupMaybe(kidsArr.get(k), PDFDict3);
7494
+ const child = doc.context.lookupMaybe(kidsArr.get(k), PDFDict4);
6078
7495
  if (child) collectFromNode(child);
6079
7496
  }
6080
7497
  }
@@ -6112,7 +7529,7 @@ function signPdfUnitWithDigest(unit, signerInfo) {
6112
7529
  if (!signerName) {
6113
7530
  throw new Error("[UniverPdfs] signPdfUnitWithDigest requires a non-empty signerName.");
6114
7531
  }
6115
- const next = Tools4.deepClone(unit);
7532
+ const next = Tools5.deepClone(unit);
6116
7533
  const signedAt = signerInfo.signedAt || (/* @__PURE__ */ new Date()).toISOString();
6117
7534
  const contentDigestHex = computeCanonicalUnitContentDigestHex(next);
6118
7535
  const partialEnv = {
@@ -6133,10 +7550,10 @@ function signPdfUnitWithDigest(unit, signerInfo) {
6133
7550
  ...partialEnv,
6134
7551
  envelopeDigestHex: computeSignatureEnvelopeDigestHex(partialEnv)
6135
7552
  };
6136
- next.signatureEnvelope = Tools4.deepClone(envelope);
7553
+ next.signatureEnvelope = Tools5.deepClone(envelope);
6137
7554
  next.metadata = {
6138
7555
  ...next.metadata ?? {},
6139
- signatureEnvelope: Tools4.deepClone(envelope)
7556
+ signatureEnvelope: Tools5.deepClone(envelope)
6140
7557
  };
6141
7558
  next.rev = (next.rev || 1) + 1;
6142
7559
  return next;
@@ -6205,7 +7622,7 @@ function matchPaperPresetMm(wMm, hMm, tolMm = 1.5) {
6205
7622
  }
6206
7623
  async function inspectPdfBytePageSizes(pdfBytes, options) {
6207
7624
  const loadOpts = options?.password ? { password: options.password } : { ignoreEncryption: true };
6208
- const doc = await PDFDocument3.load(pdfBytes, loadOpts);
7625
+ const doc = await PDFDocument4.load(pdfBytes, loadOpts);
6209
7626
  const pages = doc.getPages();
6210
7627
  return pages.map((page, pageIndex) => {
6211
7628
  const sz = page.getSize();
@@ -6433,7 +7850,7 @@ function isPngSignature(bytes) {
6433
7850
  return bytes.length >= 8 && bytes[0] === 137 && bytes[1] === 80 && bytes[2] === 78 && bytes[3] === 71;
6434
7851
  }
6435
7852
  async function convertImagesToPdfBytes(images, options) {
6436
- const pdfDoc = await PDFDocument3.create();
7853
+ const pdfDoc = await PDFDocument4.create();
6437
7854
  const sizeSpec = resolveConverterPageSizePt(options?.pageSize ?? "A4");
6438
7855
  const marginPt = mmToPt(Math.max(0, options?.marginMm ?? 0));
6439
7856
  if (!images.length) {
@@ -6876,7 +8293,7 @@ async function convertMarkdownToPdfBytes(markdown, options) {
6876
8293
  }
6877
8294
 
6878
8295
  // src/exporter/pdf-fidelity-samples.ts
6879
- import { Tools as Tools5 } from "@univerjs/core";
8296
+ import { Tools as Tools6 } from "@univerjs/core";
6880
8297
  function buildA4Snapshot(id, name, elements, margins = [40, 40, 40, 40]) {
6881
8298
  const base = createDefaultPdfUnitData({ id, name });
6882
8299
  const pageId = "page-1";
@@ -7345,7 +8762,7 @@ function createPdfBrowserFidelitySamples() {
7345
8762
  }
7346
8763
  }
7347
8764
  ]);
7348
- const s6MissingGlyphs = Tools5.deepClone(s1ShortCjk);
8765
+ const s6MissingGlyphs = Tools6.deepClone(s1ShortCjk);
7349
8766
  s6MissingGlyphs.id = "s6-missing-glyphs";
7350
8767
  s6MissingGlyphs.name = "S6 \u7F3A\u5B57\u4E0E\u5B57\u4F53\u5F02\u5E38\u8BCA\u65AD";
7351
8768
  s6MissingGlyphs.editState.elementsByPage["page-1"]["s6-missing-note"] = {
@@ -7364,7 +8781,7 @@ function createPdfBrowserFidelitySamples() {
7364
8781
  }
7365
8782
  };
7366
8783
  s6MissingGlyphs.editState.elementOrderByPage["page-1"].push("s6-missing-note");
7367
- const s7DefaultNoFont = Tools5.deepClone(s1ShortCjk);
8784
+ const s7DefaultNoFont = Tools6.deepClone(s1ShortCjk);
7368
8785
  s7DefaultNoFont.id = "s7-default-no-font";
7369
8786
  s7DefaultNoFont.name = "S7 \u9ED8\u8BA4\u672A\u4F20\u5B57\u4F53\u5149\u6805\u517C\u5BB9\u6A21\u5F0F";
7370
8787
  return {
@@ -7624,10 +9041,10 @@ import {
7624
9041
  CanceledError,
7625
9042
  createIdentifier as createIdentifier2,
7626
9043
  Disposable as Disposable2,
7627
- generateRandomId as generateRandomId6,
9044
+ generateRandomId as generateRandomId7,
7628
9045
  IUniverInstanceService as IUniverInstanceService4,
7629
9046
  Optional,
7630
- Tools as Tools6,
9047
+ Tools as Tools7,
7631
9048
  UniverInstanceType as UniverInstanceType4
7632
9049
  } from "@univerjs/core";
7633
9050
  import { BehaviorSubject as BehaviorSubject2, Subject } from "rxjs";
@@ -7683,7 +9100,7 @@ function createHttpSilentPrintAdapter(config) {
7683
9100
  payload = null;
7684
9101
  }
7685
9102
  return {
7686
- jobId: String(payload?.jobId || payload?.id || `print-${generateRandomId6(8)}`),
9103
+ jobId: String(payload?.jobId || payload?.id || `print-${generateRandomId7(8)}`),
7687
9104
  driver: String(payload?.driver || driver),
7688
9105
  byteLength: pdfBytes.byteLength,
7689
9106
  printedAt: Number(payload?.printedAt || Date.now())
@@ -7766,7 +9183,7 @@ function decodeBase64Strict(b64Input) {
7766
9183
  }
7767
9184
  return out;
7768
9185
  }
7769
- function hasPdfMagicHeader(bytes) {
9186
+ function hasPdfMagicHeader2(bytes) {
7770
9187
  if (bytes.byteLength < 8) return false;
7771
9188
  const scanLimit = Math.min(1024, bytes.byteLength - 5);
7772
9189
  for (let i = 0; i <= scanLimit; i++) {
@@ -7803,74 +9220,74 @@ function countJsInActionDict(actionDict, doc, PDFArrayCtor, PDFDictCtor, PDFName
7803
9220
  return count;
7804
9221
  }
7805
9222
  function inspectPdfDocumentImportWarnings(doc, pdfLib) {
7806
- const { PDFArray: PDFArray4, PDFDict: PDFDict4, PDFName: PDFName4 } = pdfLib;
9223
+ const { PDFArray: PDFArray5, PDFDict: PDFDict5, PDFName: PDFName5 } = pdfLib;
7807
9224
  const warnings = [];
7808
9225
  let acroFieldCount = 0;
7809
- const acroFormDict = doc.catalog.lookupMaybe(PDFName4.of("AcroForm"), PDFDict4);
9226
+ const acroFormDict = doc.catalog.lookupMaybe(PDFName5.of("AcroForm"), PDFDict5);
7810
9227
  if (acroFormDict) {
7811
9228
  try {
7812
9229
  acroFieldCount = doc.getForm().getFields().length;
7813
9230
  } catch {
7814
- const fieldsArr = acroFormDict.lookupMaybe(PDFName4.of("Fields"), PDFArray4);
9231
+ const fieldsArr = acroFormDict.lookupMaybe(PDFName5.of("Fields"), PDFArray5);
7815
9232
  if (fieldsArr) {
7816
9233
  acroFieldCount = fieldsArr.size();
7817
9234
  }
7818
9235
  }
7819
9236
  }
7820
9237
  let jsCount = 0;
7821
- const namesDict = doc.catalog.lookupMaybe(PDFName4.of("Names"), PDFDict4);
7822
- const jsNameTree = namesDict?.lookupMaybe(PDFName4.of("JavaScript"), PDFDict4);
9238
+ const namesDict = doc.catalog.lookupMaybe(PDFName5.of("Names"), PDFDict5);
9239
+ const jsNameTree = namesDict?.lookupMaybe(PDFName5.of("JavaScript"), PDFDict5);
7823
9240
  if (jsNameTree) {
7824
- const namesArr = jsNameTree.lookupMaybe(PDFName4.of("Names"), PDFArray4);
9241
+ const namesArr = jsNameTree.lookupMaybe(PDFName5.of("Names"), PDFArray5);
7825
9242
  jsCount += namesArr ? Math.max(1, Math.floor(namesArr.size() / 2)) : 1;
7826
9243
  }
7827
- const openAction = doc.catalog.lookupMaybe(PDFName4.of("OpenAction"), PDFDict4);
9244
+ const openAction = doc.catalog.lookupMaybe(PDFName5.of("OpenAction"), PDFDict5);
7828
9245
  if (openAction) {
7829
- jsCount += countJsInActionDict(openAction, doc, PDFArray4, PDFDict4, PDFName4);
9246
+ jsCount += countJsInActionDict(openAction, doc, PDFArray5, PDFDict5, PDFName5);
7830
9247
  }
7831
- const catalogAA = doc.catalog.lookupMaybe(PDFName4.of("AA"), PDFDict4);
9248
+ const catalogAA = doc.catalog.lookupMaybe(PDFName5.of("AA"), PDFDict5);
7832
9249
  if (catalogAA) {
7833
9250
  for (const [, actionRef] of catalogAA.entries()) {
7834
- const act = doc.context.lookupMaybe(actionRef, PDFDict4);
9251
+ const act = doc.context.lookupMaybe(actionRef, PDFDict5);
7835
9252
  if (act) {
7836
- jsCount += countJsInActionDict(act, doc, PDFArray4, PDFDict4, PDFName4);
9253
+ jsCount += countJsInActionDict(act, doc, PDFArray5, PDFDict5, PDFName5);
7837
9254
  }
7838
9255
  }
7839
9256
  }
7840
9257
  let activeAnnotationCount = 0;
7841
9258
  let orphanWidgetCount = 0;
7842
9259
  for (const page of doc.getPages()) {
7843
- const pageAA = page.node.lookupMaybe(PDFName4.of("AA"), PDFDict4);
9260
+ const pageAA = page.node.lookupMaybe(PDFName5.of("AA"), PDFDict5);
7844
9261
  if (pageAA) {
7845
9262
  for (const [, actionRef] of pageAA.entries()) {
7846
- const act = doc.context.lookupMaybe(actionRef, PDFDict4);
9263
+ const act = doc.context.lookupMaybe(actionRef, PDFDict5);
7847
9264
  if (act) {
7848
- jsCount += countJsInActionDict(act, doc, PDFArray4, PDFDict4, PDFName4);
9265
+ jsCount += countJsInActionDict(act, doc, PDFArray5, PDFDict5, PDFName5);
7849
9266
  }
7850
9267
  }
7851
9268
  }
7852
9269
  const annots = page.node.Annots();
7853
- if (annots instanceof PDFArray4) {
9270
+ if (annots instanceof PDFArray5) {
7854
9271
  for (let i = 0; i < annots.size(); i++) {
7855
- const annot = annots.lookupMaybe(i, PDFDict4);
9272
+ const annot = annots.lookupMaybe(i, PDFDict5);
7856
9273
  if (!annot) continue;
7857
- const subtypeObj = annot.get(PDFName4.of("Subtype"));
9274
+ const subtypeObj = annot.get(PDFName5.of("Subtype"));
7858
9275
  const subtype = subtypeObj ? subtypeObj.toString() : "";
7859
9276
  if (subtype === "/Widget") {
7860
9277
  orphanWidgetCount += 1;
7861
9278
  } else if (subtype !== "/Popup") {
7862
9279
  activeAnnotationCount += 1;
7863
9280
  }
7864
- const annotAction = annot.lookupMaybe(PDFName4.of("A"), PDFDict4);
9281
+ const annotAction = annot.lookupMaybe(PDFName5.of("A"), PDFDict5);
7865
9282
  if (annotAction) {
7866
- jsCount += countJsInActionDict(annotAction, doc, PDFArray4, PDFDict4, PDFName4);
9283
+ jsCount += countJsInActionDict(annotAction, doc, PDFArray5, PDFDict5, PDFName5);
7867
9284
  }
7868
- const annotAA = annot.lookupMaybe(PDFName4.of("AA"), PDFDict4);
9285
+ const annotAA = annot.lookupMaybe(PDFName5.of("AA"), PDFDict5);
7869
9286
  if (annotAA) {
7870
9287
  for (const [, actionRef] of annotAA.entries()) {
7871
- const act = doc.context.lookupMaybe(actionRef, PDFDict4);
9288
+ const act = doc.context.lookupMaybe(actionRef, PDFDict5);
7872
9289
  if (act) {
7873
- jsCount += countJsInActionDict(act, doc, PDFArray4, PDFDict4, PDFName4);
9290
+ jsCount += countJsInActionDict(act, doc, PDFArray5, PDFDict5, PDFName5);
7874
9291
  }
7875
9292
  }
7876
9293
  }
@@ -7925,23 +9342,23 @@ function normalizePdfImportWarnings(raw) {
7925
9342
  return normalized;
7926
9343
  }
7927
9344
  function buildOverlayImportCandidateSnapshot(baseSnapshot, outcome) {
7928
- const prevSnapshot = Tools6.deepClone(baseSnapshot);
9345
+ const prevSnapshot = Tools7.deepClone(baseSnapshot);
7929
9346
  const existingOrder = prevSnapshot.document?.pageOrder ?? [];
7930
9347
  const pageSizes = outcome.pageSizes ?? [];
7931
9348
  const totalPages = Math.max(1, pageSizes.length || outcome.sourceDocumentRef.pageCount || 1);
7932
9349
  const nextPages = {};
7933
9350
  const nextPageOrder = [];
7934
- const nextElementsByPage = Tools6.deepClone(prevSnapshot.editState?.elementsByPage ?? {});
7935
- const nextElementOrderByPage = Tools6.deepClone(prevSnapshot.editState?.elementOrderByPage ?? {});
9351
+ const nextElementsByPage = Tools7.deepClone(prevSnapshot.editState?.elementsByPage ?? {});
9352
+ const nextElementOrderByPage = Tools7.deepClone(prevSnapshot.editState?.elementOrderByPage ?? {});
7936
9353
  for (let i = 0; i < totalPages; i++) {
7937
- const pid = existingOrder[i] || `page-${generateRandomId6(6)}`;
9354
+ const pid = existingOrder[i] || `page-${generateRandomId7(6)}`;
7938
9355
  nextPageOrder.push(pid);
7939
9356
  const resolvedSize = pageSizes[i] ?? pageSizes[0] ?? prevSnapshot.document.pageSize;
7940
9357
  nextPages[pid] = {
7941
9358
  id: pid,
7942
9359
  title: `Page ${i + 1}`,
7943
9360
  sourcePageNumber: i + 1,
7944
- pageSize: Tools6.deepClone(resolvedSize),
9361
+ pageSize: Tools7.deepClone(resolvedSize),
7945
9362
  backgroundColor: "#ffffff"
7946
9363
  };
7947
9364
  if (!nextElementsByPage[pid]) nextElementsByPage[pid] = {};
@@ -7949,10 +9366,10 @@ function buildOverlayImportCandidateSnapshot(baseSnapshot, outcome) {
7949
9366
  }
7950
9367
  return {
7951
9368
  ...prevSnapshot,
7952
- sourceDocumentRef: Tools6.deepClone(outcome.sourceDocumentRef),
9369
+ sourceDocumentRef: Tools7.deepClone(outcome.sourceDocumentRef),
7953
9370
  document: {
7954
9371
  ...prevSnapshot.document,
7955
- pageSize: Tools6.deepClone(pageSizes[0] ?? prevSnapshot.document.pageSize),
9372
+ pageSize: Tools7.deepClone(pageSizes[0] ?? prevSnapshot.document.pageSize),
7956
9373
  pages: nextPages,
7957
9374
  pageOrder: nextPageOrder
7958
9375
  },
@@ -7973,8 +9390,8 @@ function normalizeAdapterImportResult(raw) {
7973
9390
  return {
7974
9391
  outcome: {
7975
9392
  mode: "overlay",
7976
- sourceDocumentRef: Tools6.deepClone(record.sourceDocumentRef),
7977
- pageSizes: Tools6.deepClone(record.pageSizes ?? []),
9393
+ sourceDocumentRef: Tools7.deepClone(record.sourceDocumentRef),
9394
+ pageSizes: Tools7.deepClone(record.pageSizes ?? []),
7978
9395
  ...warnings.length > 0 ? { warnings } : {}
7979
9396
  },
7980
9397
  warnings
@@ -7982,7 +9399,7 @@ function normalizeAdapterImportResult(raw) {
7982
9399
  }
7983
9400
  if (record.mode === "snapshot") {
7984
9401
  const warnings = normalizePdfImportWarnings(record.warnings);
7985
- const clonedSnapshot = Tools6.deepClone(record.snapshot);
9402
+ const clonedSnapshot = Tools7.deepClone(record.snapshot);
7986
9403
  return {
7987
9404
  outcome: {
7988
9405
  mode: "snapshot",
@@ -7994,7 +9411,7 @@ function normalizeAdapterImportResult(raw) {
7994
9411
  }
7995
9412
  if (record.snapshot && typeof record.snapshot === "object") {
7996
9413
  const warnings = normalizePdfImportWarnings(record.warnings);
7997
- const clonedSnapshot = Tools6.deepClone(record.snapshot);
9414
+ const clonedSnapshot = Tools7.deepClone(record.snapshot);
7998
9415
  return {
7999
9416
  outcome: {
8000
9417
  mode: "snapshot",
@@ -8006,7 +9423,7 @@ function normalizeAdapterImportResult(raw) {
8006
9423
  }
8007
9424
  if ("schema" in record || "document" in record) {
8008
9425
  const warnings = normalizePdfImportWarnings(record.warnings);
8009
- const clonedSnapshot = Tools6.deepClone(record);
9426
+ const clonedSnapshot = Tools7.deepClone(record);
8010
9427
  delete clonedSnapshot.warnings;
8011
9428
  return {
8012
9429
  outcome: {
@@ -8127,19 +9544,31 @@ async function importPdfSource(source, options) {
8127
9544
  } else {
8128
9545
  throw new PdfImportError("INVALID_PDF_HEADER", "Unsupported PDF input source.");
8129
9546
  }
8130
- if (!hasPdfMagicHeader(bytes)) {
9547
+ if (!hasPdfMagicHeader2(bytes)) {
8131
9548
  throw new PdfImportError(
8132
9549
  "INVALID_PDF_HEADER",
8133
9550
  "Invalid PDF binary: missing %PDF- header signature."
8134
9551
  );
8135
9552
  }
8136
9553
  throwIfSignalAborted(options?.signal);
8137
- const { PDFArray: PDFArray4, PDFDict: PDFDict4, PDFDocument: PDFDocument4, PDFName: PDFName4 } = await import("pdf-lib");
9554
+ const { PDFArray: PDFArray5, PDFDict: PDFDict5, PDFDocument: PDFDocument5, PDFName: PDFName5 } = await import("pdf-lib");
8138
9555
  throwIfSignalAborted(options?.signal);
8139
9556
  let pageSizes = [];
8140
9557
  let warnings = [];
9558
+ const encInspection = inspectPdfEncryption(bytes);
9559
+ if (encInspection.encrypted) {
9560
+ try {
9561
+ bytes = await verifyAndDecryptPdfBytes(bytes, options?.password);
9562
+ } catch (secErr) {
9563
+ if (secErr instanceof PdfSecurityError) {
9564
+ if (secErr.code === "PDF_PASSWORD_REQUIRED" || secErr.code === "PDF_INVALID_PASSWORD") {
9565
+ throw new PdfImportError("ENCRYPTED_PDF_PASSWORD_REQUIRED", secErr.message);
9566
+ }
9567
+ }
9568
+ }
9569
+ }
8141
9570
  try {
8142
- const doc = await PDFDocument4.load(bytes);
9571
+ const doc = await PDFDocument5.load(bytes);
8143
9572
  if (doc.isEncrypted && !options?.password) {
8144
9573
  throw new PdfImportError(
8145
9574
  "ENCRYPTED_PDF_PASSWORD_REQUIRED",
@@ -8154,7 +9583,7 @@ async function importPdfSource(source, options) {
8154
9583
  const { width, height } = p.getSize();
8155
9584
  return { width, height, preset: "CUSTOM" };
8156
9585
  });
8157
- warnings = inspectPdfDocumentImportWarnings(doc, { PDFArray: PDFArray4, PDFDict: PDFDict4, PDFName: PDFName4 });
9586
+ warnings = inspectPdfDocumentImportWarnings(doc, { PDFArray: PDFArray5, PDFDict: PDFDict5, PDFName: PDFName5 });
8158
9587
  } catch (err) {
8159
9588
  if (err instanceof PdfImportError) {
8160
9589
  throw err;
@@ -8213,7 +9642,7 @@ async function importPdfSource(source, options) {
8213
9642
  }
8214
9643
  if (!verifiedByPdfjs) {
8215
9644
  try {
8216
- const doc = await PDFDocument4.load(bytes, { ignoreEncryption: true });
9645
+ const doc = await PDFDocument5.load(bytes, { ignoreEncryption: true });
8217
9646
  const pages = doc.getPages();
8218
9647
  if (pages.length === 0) {
8219
9648
  throw new PdfImportError("CORRUPT_PDF", "PDF document contains zero pages.");
@@ -8222,7 +9651,7 @@ async function importPdfSource(source, options) {
8222
9651
  const { width, height } = p.getSize();
8223
9652
  return { width, height, preset: "CUSTOM" };
8224
9653
  });
8225
- warnings = inspectPdfDocumentImportWarnings(doc, { PDFArray: PDFArray4, PDFDict: PDFDict4, PDFName: PDFName4 });
9654
+ warnings = inspectPdfDocumentImportWarnings(doc, { PDFArray: PDFArray5, PDFDict: PDFDict5, PDFName: PDFName5 });
8226
9655
  } catch (fallbackErr) {
8227
9656
  if (fallbackErr instanceof PdfImportError) throw fallbackErr;
8228
9657
  throw new PdfImportError(
@@ -8242,7 +9671,7 @@ async function importPdfSource(source, options) {
8242
9671
  mode: "overlay",
8243
9672
  bytes,
8244
9673
  sourceDocumentRef: {
8245
- id: `src-${generateRandomId6(6)}`,
9674
+ id: `src-${generateRandomId7(6)}`,
8246
9675
  fileName,
8247
9676
  mimeType: "application/pdf",
8248
9677
  dataUri,
@@ -8493,7 +9922,7 @@ var PdfIoService = class extends Disposable2 {
8493
9922
  }
8494
9923
  _resolveBaseSnapshotForImport(context) {
8495
9924
  if (context?.snapshot) {
8496
- const cloned = Tools6.deepClone(context.snapshot);
9925
+ const cloned = Tools7.deepClone(context.snapshot);
8497
9926
  return {
8498
9927
  unitId: context.unitId || cloned.id,
8499
9928
  baseSnapshot: cloned
@@ -8554,7 +9983,7 @@ var PdfIoService = class extends Disposable2 {
8554
9983
  rawResult = await raceWithAbortSignal(
8555
9984
  adapter.importPdf(file, {
8556
9985
  unitId,
8557
- snapshot: Tools6.deepClone(baseSnapshot),
9986
+ snapshot: Tools7.deepClone(baseSnapshot),
8558
9987
  ...signal ? { signal } : {},
8559
9988
  defaultImport
8560
9989
  }),
@@ -8585,7 +10014,7 @@ var PdfIoService = class extends Disposable2 {
8585
10014
  }
8586
10015
  throwIfSignalAborted(signal);
8587
10016
  const { outcome, warnings } = normalizeAdapterImportResult(rawResult);
8588
- const candidateSnapshot = outcome.mode === "snapshot" ? Tools6.deepClone(outcome.snapshot) : buildOverlayImportCandidateSnapshot(baseSnapshot, outcome);
10017
+ const candidateSnapshot = outcome.mode === "snapshot" ? Tools7.deepClone(outcome.snapshot) : buildOverlayImportCandidateSnapshot(baseSnapshot, outcome);
8589
10018
  throwIfSignalAborted(signal);
8590
10019
  return {
8591
10020
  snapshot: candidateSnapshot,
@@ -8860,10 +10289,14 @@ var UniverPdfsPlugin = class extends Plugin {
8860
10289
  SetPdfHeaderFooterConfigCommand,
8861
10290
  SetPdfWatermarkConfigCommand,
8862
10291
  SetPdfAttachmentsCommand,
10292
+ SetPdfSecurityConfigCommand,
8863
10293
  AddPdfLayerCommand,
8864
10294
  UpdatePdfLayerCommand,
8865
10295
  RemovePdfLayerCommand,
8866
10296
  AssignPdfElementLayerCommand,
10297
+ AddPdfAnnotationReplyCommand,
10298
+ DeletePdfAnnotationReplyCommand,
10299
+ SetPdfAnnotationReviewStatusCommand,
8867
10300
  ReplacePdfSnapshotCommand,
8868
10301
  SavePdfVersionCommand,
8869
10302
  RestorePdfVersionCommand
@@ -8881,6 +10314,7 @@ UniverPdfsPlugin = __decorateClass([
8881
10314
  export {
8882
10315
  ASPECT_RATIO_LOCKED_BARCODE_TYPES,
8883
10316
  Absolute,
10317
+ AddPdfAnnotationReplyCommand,
8884
10318
  AddPdfElementCommand,
8885
10319
  AddPdfElementMutation,
8886
10320
  AddPdfLayerCommand,
@@ -8896,6 +10330,7 @@ export {
8896
10330
  DEFAULT_PDF_CJK_FONT_FILES,
8897
10331
  DEFAULT_PDF_CJK_FONT_PACKAGE,
8898
10332
  DEFAULT_PDF_CJK_FONT_VERSION,
10333
+ DeletePdfAnnotationReplyCommand,
8899
10334
  DeleteSelectedPdfElementsCommand,
8900
10335
  DistributeSelectedPdfElementsCommand,
8901
10336
  Document,
@@ -8917,8 +10352,12 @@ export {
8917
10352
  PDF_JSX_ELEMENT_SYMBOL,
8918
10353
  PDF_JSX_FRAGMENT_SYMBOL,
8919
10354
  PDF_PAGE_PRESETS,
10355
+ PDF_PASSWORD_PADDING,
8920
10356
  PDF_S1_S7_FIDELITY_EXPECTATIONS,
10357
+ PDF_STANDARD_STAMP_PRESETS,
10358
+ PDF_STANDARD_STAMP_PRESET_MAP,
8921
10359
  PDF_TABLE_THEME_PRESETS,
10360
+ PPTX_EMU_PER_PT,
8922
10361
  PT_PER_MM,
8923
10362
  Page,
8924
10363
  PageBreak,
@@ -8931,6 +10370,7 @@ export {
8931
10370
  PdfListKind,
8932
10371
  PdfListPresetId,
8933
10372
  PdfRenderError,
10373
+ PdfSecurityError,
8934
10374
  PdfSelectionService,
8935
10375
  PdfTableBorderStyle,
8936
10376
  PdfTableCellVerticalAlign,
@@ -8952,6 +10392,7 @@ export {
8952
10392
  RotatePdfPageCommand,
8953
10393
  Row,
8954
10394
  SavePdfVersionCommand,
10395
+ SetPdfAnnotationReviewStatusCommand,
8955
10396
  SetPdfAttachmentsCommand,
8956
10397
  SetPdfBatesConfigCommand,
8957
10398
  SetPdfBookmarksCommand,
@@ -8959,6 +10400,7 @@ export {
8959
10400
  SetPdfNativeTextSpansCommand,
8960
10401
  SetPdfPageCropBoxCommand,
8961
10402
  SetPdfPageSizeCommand,
10403
+ SetPdfSecurityConfigCommand,
8962
10404
  SetPdfWatermarkConfigCommand,
8963
10405
  Spacer,
8964
10406
  Stack,
@@ -8978,10 +10420,14 @@ export {
8978
10420
  UpdatePdfUnitPropsCommand,
8979
10421
  UpdatePdfUnitPropsMutation,
8980
10422
  applyOcrToUnitPage,
10423
+ applyPdfSecurityToDocument,
8981
10424
  autoDetectFormFieldsOnPage,
8982
10425
  buildMinimalTestTrueTypeFont,
10426
+ buildObjectEncryptionKey,
8983
10427
  buildOverlayImportCandidateSnapshot,
10428
+ buildPdfApprovalStampSvg,
8984
10429
  buildPdfTemplateFromOcrFields,
10430
+ bytesToHex,
8985
10431
  calculatePdfTableRowCapacity,
8986
10432
  canonicalJsonStringify,
8987
10433
  clearPdfFontUrlCache,
@@ -9000,28 +10446,37 @@ export {
9000
10446
  computeExifTransformMatrix,
9001
10447
  computeExpandedTextHeightMm,
9002
10448
  computeExpandedTextHeightPt,
10449
+ computeFileEncryptionKeyFromPadded,
9003
10450
  computeFontUrlCacheKey,
9004
10451
  computeImageFitPlacement,
10452
+ computeOwnerPasswordValue,
9005
10453
  computePasteCascadeOffset,
9006
10454
  computePdfPayloadDigest,
9007
10455
  computePdfTableSummaryRow,
9008
10456
  computeSmartSnapWithEqualGap,
10457
+ computeUserPasswordValue,
9009
10458
  convertImagesToPdfBytes,
9010
10459
  convertMarkdownToPdfBytes,
9011
10460
  convertMarkdownToPdfUnit,
9012
10461
  convertPdfBytesToCsv,
9013
10462
  convertPdfBytesToDocxBytes,
10463
+ convertPdfBytesToPptxBytes,
9014
10464
  convertPdfToSheetStructure,
9015
10465
  convertPdfToWordStructure,
9016
10466
  convertPdfUnitToCsv,
10467
+ convertPdfUnitToPptxBytes,
9017
10468
  createDefaultElement,
9018
10469
  createDefaultPdfUnitData,
9019
10470
  createHttpSilentPrintAdapter,
9020
10471
  createPdfAbortError,
10472
+ createPdfApprovalStampElement,
10473
+ createPdfApprovalStampSvgElement,
9021
10474
  createPdfBrowserFidelityExpectations,
9022
10475
  createPdfBrowserFidelitySamples,
9023
10476
  createPdfCjkFontSources,
9024
10477
  createPdfJsxNode,
10478
+ decodePdfPermissionFlags,
10479
+ decryptPdfBytes,
9025
10480
  detectCJKCharacters,
9026
10481
  detectCJKInPdfInputs,
9027
10482
  detectCJKInPdfTemplate,
@@ -9042,9 +10497,11 @@ export {
9042
10497
  encodeJapanPost,
9043
10498
  encodeNw7,
9044
10499
  encodePdf417,
10500
+ encodePdfPermissionFlags,
9045
10501
  encodeQrCodeMatrix,
9046
10502
  encodeUpcA,
9047
10503
  encodeUpcE,
10504
+ encryptPdfBytes,
9048
10505
  evaluatePdfFormExpression,
9049
10506
  evaluatePdfJsxElement,
9050
10507
  evaluateSafeTemplateExpression,
@@ -9056,6 +10513,7 @@ export {
9056
10513
  exportPdfBytes,
9057
10514
  exportPdfToDocxSnapshot,
9058
10515
  exportPdfToWorkbookSnapshot,
10516
+ exportPdfUnitToBytes,
9059
10517
  exportPdfWithTarget,
9060
10518
  exportSignedPdfWithAuditSeal,
9061
10519
  exportToPdfmeTemplate,
@@ -9064,24 +10522,30 @@ export {
9064
10522
  extractJsxTextContent,
9065
10523
  extractNativeTextSpansFromPdfBytes,
9066
10524
  extractPdfFormValues,
10525
+ extractSvgTextDescriptors,
9067
10526
  fillPdfFormValues,
9068
10527
  flattenJsxChildrenToNodes,
9069
10528
  formatBatesNumber,
9070
10529
  formatGs1HumanReadable,
9071
10530
  formatPdfDateTimeValue,
10531
+ formatPdfPageIndicesLabel,
9072
10532
  formatPdfTableCell,
9073
10533
  fromPdfmeTemplate,
9074
10534
  generatePdfTemplateByPrompt,
9075
10535
  getDefaultDateTimeFormat,
10536
+ getPdfStandardStampPreset,
9076
10537
  getRegisteredOcrAdapter,
9077
10538
  getTrueTypeMappedCodePoints,
10539
+ hexToBytes,
9078
10540
  importAcroFormPdfToUnit,
9079
10541
  importFormDataFromFdf,
9080
10542
  importFormDataFromXfdf,
9081
10543
  importFromPdfmeTemplate,
10544
+ importPdfBytesToUnit,
9082
10545
  importPdfSource,
9083
10546
  insertPdfPagesBytes,
9084
10547
  inspectPdfBytePageSizes,
10548
+ inspectPdfEncryption,
9085
10549
  inspectPdfExportCapabilities,
9086
10550
  inspectTrueTypeFont,
9087
10551
  isAspectRatioLockedBarcodeType,
@@ -9089,10 +10553,12 @@ export {
9089
10553
  isExifDimensionsSwapped,
9090
10554
  isFontUrlSafeToFetch,
9091
10555
  isPdfJsxNode,
10556
+ isPdfSecurityActive,
9092
10557
  jsx,
9093
10558
  jsxDEV,
9094
10559
  jsxs,
9095
10560
  mayBeJson,
10561
+ md5Bytes,
9096
10562
  mergePdfBytes,
9097
10563
  mmToPt,
9098
10564
  movePdfPageBytes,
@@ -9103,6 +10569,7 @@ export {
9103
10569
  optimizePdfUnit,
9104
10570
  organizePdfBytes,
9105
10571
  overlayDiagnosticGridOnPdfBytes,
10572
+ padPdfPassword,
9106
10573
  paginatePdfListItems,
9107
10574
  paginatePdfTableRows,
9108
10575
  parseGs1ApplicationIdentifiers,
@@ -9111,10 +10578,13 @@ export {
9111
10578
  parsePdfColorWithAlpha,
9112
10579
  parsePdfContentStreamTextOps,
9113
10580
  parsePdfPageRange,
10581
+ parsePdfPageRangeSpec,
9114
10582
  parseSafeKeyValueRecord,
9115
10583
  parseSvgToVectorCommands,
9116
10584
  parseSvgTransformAttr,
9117
10585
  ptToMm,
10586
+ ptToPptxEmu,
10587
+ rc4Bytes,
9118
10588
  readJpegExifOrientation,
9119
10589
  recalculatePdfFormFields,
9120
10590
  rectsIntersect,
@@ -9139,6 +10609,7 @@ export {
9139
10609
  resolveMultiVariableText,
9140
10610
  resolvePaddingMm,
9141
10611
  resolvePageSizeMm,
10612
+ resolvePdfCropBoxPt,
9142
10613
  resolvePolygonNormalizedPoints,
9143
10614
  resolveTemplateString,
9144
10615
  rgbToCmyk,
@@ -9154,6 +10625,8 @@ export {
9154
10625
  exportSignedPdfWithAuditSeal as signPdfWithAuditDigest,
9155
10626
  smoothSignatureStrokeQuadratic,
9156
10627
  splitPdfBytes,
10628
+ splitPdfBytesByRanges,
10629
+ splitPdfUnitByRanges,
9157
10630
  stripPdfPageNativeTextInRects,
9158
10631
  subsetTrueTypeFont,
9159
10632
  svgToDataUri,
@@ -9165,6 +10638,7 @@ export {
9165
10638
  validatePdfInputContract,
9166
10639
  validatePdfTemplateSchema,
9167
10640
  validatePdfTemplateVariables,
10641
+ verifyAndDecryptPdfBytes,
9168
10642
  verifyPdfAuditSeal as verifyPdfAuditDigest,
9169
10643
  verifyPdfAuditSeal,
9170
10644
  verifyPdfUnitSignature,