@yudaocode/univer-pdfs 0.0.0-stage → 1.6.204

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.
@@ -0,0 +1,2025 @@
1
+ import { I as IPdfUnitData, a as IPdfDocument, b as IPdfPage, c as IPdfPageSize, d as IPdfPageElement, e as IPdfLayer, f as IPdfSourceDocumentRef, g as IPdfResourceBinding, h as IPdfUnitMetadata, i as IPdfAttachment, j as IPdfSecurityPermissions, k as IPdfSignatureEnvelope, P as PdfElementType, l as IPdfTextStyle, m as PdfPageRotation, n as IPdfBatesConfig, o as IPdfBookmarkItem, p as IPdfHeaderFooterConfig, q as IPdfNativeTextSpan, r as IPdfCropBox, s as IPdfWatermarkConfig, t as IPdfDocumentData, u as IPdfTextElement, v as PdfDateTimeKind, w as IPdfCircleMarkElement, x as IPdfListElement, y as IPdfRichTextSpan, z as PdfColorSpaceType, A as IPdfExportOptions, B as PDF_PAGE_PRESETS, C as PdfBatesPosition, D as IPdfSignerInfo, E as IPdfjsAssetsConfig, F as PdfDisplayUnit, G as PdfInteractionMode, H as IPdfVersionSnapshot } from './jsx-dev-runtime-5tXCUq4v.js';
2
+ export { J as Fragment, K as ICjkDetectionSummary, L as IComputeDynamicFontSizeParams, M as IDetectedPaperPreset, N as IDiagnosePdfFontsOptions, O as IDiagnosticGridOverlayOptions, Q as IExportJsxToPdfOptions, R as IInputsCjkReport, S as IJsxAbsoluteProps, T as IJsxBarcodeProps, U as IJsxBoxProps, V as IJsxContainerStyleProps, W as IJsxDocumentProps, X as IJsxHeaderFooterProps, Y as IJsxImageProps, Z as IJsxLineProps, _ as IJsxListProps, $ as IJsxMultiVariableTextProps, a0 as IJsxPageBreakProps, a1 as IJsxPageProps, a2 as IJsxQrCodeProps, a3 as IJsxRowProps, a4 as IJsxShapeProps, a5 as IJsxSpacerProps, a6 as IJsxStackProps, a7 as IJsxStaticProps, a8 as IJsxSvgProps, a9 as IJsxTableColumnSpec, aa as IJsxTableProps, ab as IJsxTextProps, ac as IPdfAnnotationElement, ad as IPdfAnnotationReply, ae as IPdfBarcodeElement, af as IPdfCheckboxElement, ag as IPdfDatasetField, ah as IPdfDatasetSchema, ai as IPdfDateTimeElement, aj as IPdfDocumentMetadata, ak as IPdfDurableEditState, al as IPdfDynamicFontSizeConfig, am as IPdfElement, an as IPdfElementBase, ao as IPdfElementTransform, ap as IPdfEllipseElement, aq as IPdfExportCapabilitiesReport, ar as IPdfFieldContractHint, as as IPdfFontDiagnosisReport, at as IPdfFontDiagnosticIssue, au as IPdfFontDoctorInputEntry, av as IPdfImageCrop, aw as IPdfImageElement, ax as IPdfInkElement, ay as IPdfInkPoint, az as IPdfInputContractValidationResult, aA as IPdfInputContractViolation, aB as IPdfJsxNode, aC as IPdfLineElement, aD as IPdfPageElementBase, aE as IPdfParagraphBlock, aF as IPdfPolygonElement, aG as IPdfPolygonPoint, aH as IPdfQrCodeElement, aI as IPdfRadioGroupElement, aJ as IPdfRedactionElement, aK as IPdfSchemaDiagnosticIssue, aL as IPdfSelectElement, aM as IPdfShapeElement, aN as IPdfSignatureElement, aO as IPdfStampElement, aP as IPdfSvgElement, aQ as IPdfTableBorderWidths, aR as IPdfTableCellStyle, aS as IPdfTableColumn, aT as IPdfTableElement, aU as IPdfTableMerge, aV as IPdfTablePageChunk, aW as IPdfTableThemePreset, aX as IPdfTemplateSchemaValidationResult, aY as IPdfVariableValidationResult, aZ as IPdfmeBlankPdf, a_ as IPdfmeSchemaItem, a$ as IPdfmeTemplate, b0 as IRenderJsxOptions, b1 as ITemplateCjkReport, b2 as IValidatePdfTemplateSchemaOptions, b3 as JSX, b4 as PAGE_SIZE_PRESETS_MM, b5 as PDF_JSX_ELEMENT_SYMBOL, b6 as PDF_JSX_FRAGMENT_SYMBOL, b7 as PDF_TABLE_THEME_PRESETS, b8 as PT_PER_MM, b9 as PdfAnnotationStatus, ba as PdfAnnotationType, bb as PdfBarcodeFormat, bc as PdfCjkScriptBlock, bd as PdfCjkTextMode, be as PdfDynamicFontFitMode, bf as PdfImageSourceType, bg as PdfJsxChild, bh as PdfJsxComponent, bi as PdfJsxIntrinsicKind, bj as PdfJsxPaddingSpec, bk as PdfListKind, bl as PdfListPresetId, bm as PdfPaperPresetName, bn as PdfTableBorderStyle, bo as PdfTableCellVerticalAlign, bp as PdfTextAnchor, bq as PdfTextFormatMode, br as PdfTextOverflowMode, bs as UNIVER_PDF_SCHEMA, bt as UNIVER_PDF_SCHEMA_VERSION, bu as collectPdfInputContractHints, bv as computeAutoFitFontSize, bw as computeDynamicFontSize, bx as computePdfTableSummaryRow, by as createPdfJsxNode, bz as detectCJKCharacters, bA as detectCJKInPdfInputs, bB as detectCJKInPdfTemplate, bC as detectPaperSizePreset, bD as diagnosePdfFonts, bE as evaluatePdfJsxElement, bF as exportBatchPdfBytes, bG as exportCalibrationGridPdfBytes, bH as exportPdfBytes, bI as exportToPdfmeTemplate, bJ as extractAcroFormValuesFromPdfBytes, bK as extractJsxTextContent, bL as extractPdfFormValues, bM as fillPdfFormValues, bN as flattenJsxChildrenToNodes, bO as formatBatesNumber, bP as formatPdfTableCell, bQ as fromPdfmeTemplate, bR as importFromPdfmeTemplate, bS as inspectPdfExportCapabilities, bT as isFontUrlSafeToFetch, bU as isPdfJsxNode, bV as jsx, bW as jsxDEV, bX as jsxs, bY as mmToPt, bZ as normalizeBarcodePayloadForFormat, b_ as normalizeImageCrop, b$ as overlayDiagnosticGridOnPdfBytes, c0 as paginatePdfTableRows, c1 as ptToMm, c2 as renderBarcodeDataUrl, c3 as renderQrCodeDataUrl, c4 as resolveDynamicTableRawRows, c5 as resolvePaddingMm, c6 as resolvePageSizeMm, c7 as resolvePolygonNormalizedPoints, c8 as resolveTemplateString, c9 as toPdfmeTemplate, ca as validatePdfInputContract, cb as validatePdfTemplateSchema, cc as validatePdfTemplateVariables } from './jsx-dev-runtime-5tXCUq4v.js';
3
+ import * as _univerjs_core from '@univerjs/core';
4
+ import { UnitModel, UniverInstanceType, ICommand, IMutation, IDisposable, Disposable, Plugin, Injector, IUniverInstanceService, ICommandService } from '@univerjs/core';
5
+ import { Observable } from 'rxjs';
6
+ import * as pdf_lib from 'pdf-lib';
7
+ import { PDFDocument, PDFDict, PDFPage } from 'pdf-lib';
8
+ export { Absolute, Barcode, Box, Document, Ellipse, Footer, Header, Image, Line, List, MultiVariableText, Page, PageBreak, QrCode, Rectangle, Row, Spacer, Stack, Static, Svg, Table, Text, exportJsxToPdfBytes, renderJsxToPdfUnit, renderJsxToPdfmeTemplate } from './jsx/index.js';
9
+
10
+ interface IPdfOcrFieldInput {
11
+ label: string;
12
+ value?: string;
13
+ /** Optional bounding box in millimeters `[leftMm, topMm, widthMm, heightMm]` */
14
+ bboxMm?: [number, number, number, number];
15
+ }
16
+ /**
17
+ * Pluggable AI Copilot SPI for PDF Receipt / Waybill / Voucher Template Generation & OCR Layout Reconstruction.
18
+ */
19
+ interface IPdfAiCopilotAdapter {
20
+ name?: string;
21
+ /** Generates a millimeter-aligned `IPdfUnitData` template from a natural language prompt */
22
+ generateTemplateFromPrompt?: (prompt: string) => Promise<IPdfUnitData>;
23
+ /** Reconstructs an editable `IPdfUnitData` template from OCR-detected field boxes */
24
+ recognizeReceiptLayout?: (fields: IPdfOcrFieldInput[]) => Promise<IPdfUnitData>;
25
+ }
26
+ /**
27
+ * Built-in Smart Millimeter Layout Engine:
28
+ * Parses natural-language receipt / waybill / needle-printer voucher prompts and produces a
29
+ * millimeter-aligned `IPdfUnitData` containing header `TEXT`, `DATAMATRIX` / `CODE128` `BARCODE`,
30
+ * dynamic `TABLE`, `CHECKBOX`, and official `STAMP` seal with sample dataset bindings.
31
+ */
32
+ declare function generatePdfTemplateByPrompt(prompt: string): IPdfUnitData;
33
+ /**
34
+ * Reconstructs a millimeter-aligned `IPdfUnitData` template from OCR-recognized receipt/ticket fields.
35
+ */
36
+ declare function buildPdfTemplateFromOcrFields(fields: IPdfOcrFieldInput[], options?: {
37
+ name?: string;
38
+ widthMm?: number;
39
+ heightMm?: number;
40
+ }): IPdfUnitData;
41
+
42
+ declare function createDefaultPdfUnitData(partial?: Partial<IPdfUnitData>): IPdfUnitData;
43
+ interface IPdfUnitPropsPatch {
44
+ name?: string;
45
+ pageSize?: IPdfPageSize;
46
+ sourceDocumentRef?: IPdfSourceDocumentRef | null;
47
+ resourceBindings?: Record<string, IPdfResourceBinding>;
48
+ replaceResourceBindings?: boolean;
49
+ metadata?: IPdfUnitMetadata;
50
+ replaceMetadata?: boolean;
51
+ document?: IPdfDocument;
52
+ editState?: IPdfUnitData['editState'];
53
+ layers?: IPdfLayer[] | null;
54
+ attachments?: IPdfAttachment[] | null;
55
+ securityPermissions?: IPdfSecurityPermissions | null;
56
+ signatureEnvelope?: IPdfSignatureEnvelope | null;
57
+ pdfACompliant?: boolean | null;
58
+ accessibilityTagged?: boolean | null;
59
+ }
60
+ declare class PdfUnitModel extends UnitModel<IPdfUnitData, UniverInstanceType.UNIVER_PDF> {
61
+ readonly type = UniverInstanceType.UNIVER_PDF;
62
+ private _snapshot;
63
+ private readonly _name$;
64
+ readonly name$: Observable<string>;
65
+ private readonly _snapshotChanged$;
66
+ readonly snapshotChanged$: Observable<IPdfUnitData>;
67
+ constructor(snapshot?: Partial<IPdfUnitData>);
68
+ dispose(): void;
69
+ getUnitId(): string;
70
+ setName(name: string): void;
71
+ getName(): string;
72
+ getSnapshot(): IPdfUnitData;
73
+ /**
74
+ * Returns immutable baseline document structure (matching Univer PDFs public API `pdf.getDocument()`).
75
+ */
76
+ getDocument(): IPdfDocument;
77
+ /**
78
+ * Compiles and returns a deep-cloned durable `IPdfUnitData` snapshot (matching `pdf.save()`).
79
+ */
80
+ save(): IPdfUnitData;
81
+ getRev(): number;
82
+ incrementRev(): void;
83
+ setRev(rev: number): void;
84
+ getPageOrder(): string[];
85
+ getPage(pageId: string): IPdfPage | undefined;
86
+ getEffectivePageSize(pageId?: string): IPdfPageSize;
87
+ getPageElementsOrdered(pageId: string): IPdfPageElement[];
88
+ getElement(pageId: string, elementId: string): IPdfPageElement | undefined;
89
+ getElementsByPage(pageId: string): Record<string, IPdfPageElement>;
90
+ getElementOrderByPage(pageId: string): string[];
91
+ getLayers(): IPdfLayer[];
92
+ isElementLocked(el: IPdfPageElement): boolean;
93
+ /** Internal synchronous mutators invoked exclusively by IMutation handlers */
94
+ __addElement(pageId: string, element: IPdfPageElement, index?: number): void;
95
+ __updateElements(pageId: string, updates: Array<{
96
+ id: string;
97
+ element: IPdfPageElement;
98
+ }>): void;
99
+ __removeElements(pageId: string, elementIds: string[]): void;
100
+ __setElementOrder(pageId: string, order: string[]): void;
101
+ __addPage(page: IPdfPage, index?: number, elements?: Record<string, IPdfPageElement>, elementOrder?: string[]): void;
102
+ __removePage(pageId: string): void;
103
+ __setPageOrder(pageOrder: string[]): void;
104
+ __updatePage(pageId: string, page: IPdfPage): void;
105
+ __updateUnitProps(patch: IPdfUnitPropsPatch | undefined | null): boolean;
106
+ private _notifyChange;
107
+ }
108
+
109
+ declare function createDefaultElement(type: PdfElementType, partial?: Partial<IPdfPageElement>): IPdfPageElement;
110
+ interface IAddPdfElementCommandParams {
111
+ unitId?: string;
112
+ pageId?: string;
113
+ elementType?: PdfElementType;
114
+ element?: Partial<IPdfPageElement>;
115
+ index?: number;
116
+ }
117
+ declare const AddPdfElementCommand: ICommand<IAddPdfElementCommandParams>;
118
+ interface IUpdatePdfElementsCommandParams {
119
+ unitId?: string;
120
+ pageId?: string;
121
+ updates: Array<{
122
+ id: string;
123
+ patch?: Partial<IPdfPageElement>;
124
+ element?: IPdfPageElement;
125
+ }>;
126
+ }
127
+ declare const UpdatePdfElementsCommand: ICommand<IUpdatePdfElementsCommandParams>;
128
+ interface IDeleteSelectedPdfElementsCommandParams {
129
+ unitId?: string;
130
+ pageId?: string;
131
+ elementIds?: string[];
132
+ }
133
+ declare const DeleteSelectedPdfElementsCommand: ICommand<IDeleteSelectedPdfElementsCommandParams>;
134
+ declare const DuplicateSelectedPdfElementsCommand: ICommand<{
135
+ unitId?: string;
136
+ pageId?: string;
137
+ }>;
138
+ type PdfAlignMode = 'left' | 'center' | 'right' | 'top' | 'middle' | 'bottom' | 'distribute-h' | 'distribute-v';
139
+ declare const AlignSelectedPdfElementsCommand: ICommand<{
140
+ mode: PdfAlignMode;
141
+ }>;
142
+ type PdfDistributeDirection = 'horizontal' | 'vertical';
143
+ interface IDistributeSelectedPdfElementsCommandParams {
144
+ unitId?: string;
145
+ pageId?: string;
146
+ direction: PdfDistributeDirection;
147
+ elementIds?: string[];
148
+ }
149
+ declare const DistributeSelectedPdfElementsCommand: ICommand<IDistributeSelectedPdfElementsCommandParams>;
150
+ type PdfLayerOrderMode = 'front' | 'back' | 'forward' | 'backward';
151
+ declare const ReorderPdfLayerCommand: ICommand<{
152
+ mode: PdfLayerOrderMode;
153
+ elementId?: string;
154
+ unitId?: string;
155
+ pageId?: string;
156
+ }>;
157
+ declare const AddPdfPageCommand: ICommand<{
158
+ unitId?: string;
159
+ afterPageId?: string;
160
+ index?: number;
161
+ page?: Partial<IPdfPage>;
162
+ onCreated?: (created: IPdfPage) => void;
163
+ }>;
164
+ declare const RemovePdfPageCommand: ICommand<{
165
+ unitId?: string;
166
+ pageId?: string;
167
+ }>;
168
+ declare const ReorderPdfPagesCommand: ICommand<{
169
+ unitId?: string;
170
+ pageOrder: string[];
171
+ }>;
172
+ interface IRotatePdfPageCommandParams {
173
+ unitId?: string;
174
+ pageId?: string;
175
+ rotation: PdfPageRotation;
176
+ }
177
+ declare const RotatePdfPageCommand: ICommand<IRotatePdfPageCommandParams>;
178
+ interface ISetPdfPageCropBoxCommandParams {
179
+ unitId?: string;
180
+ pageId?: string;
181
+ cropBox?: IPdfCropBox;
182
+ }
183
+ declare const SetPdfPageCropBoxCommand: ICommand<ISetPdfPageCropBoxCommandParams>;
184
+ declare const SetPdfPageSizeCommand: ICommand<{
185
+ unitId?: string;
186
+ pageSize: IPdfPageSize;
187
+ }>;
188
+ interface IImportPdfSourceCommandParams {
189
+ unitId?: string;
190
+ sourceDocumentRef: IPdfSourceDocumentRef;
191
+ pageSizes: IPdfPageSize[];
192
+ }
193
+ declare const ImportPdfSourceCommand: ICommand<IImportPdfSourceCommandParams>;
194
+ declare const ReplacePdfSnapshotCommand: ICommand<{
195
+ unitId?: string;
196
+ snapshot: IPdfUnitData;
197
+ }>;
198
+ declare const SavePdfVersionCommand: ICommand<{
199
+ unitId?: string;
200
+ label?: string;
201
+ }>;
202
+ declare const RestorePdfVersionCommand: ICommand<{
203
+ unitId?: string;
204
+ versionId: string;
205
+ }>;
206
+ interface ISetPdfNativeTextSpansCommandParams {
207
+ unitId?: string;
208
+ sourceDocumentRef?: IPdfSourceDocumentRef;
209
+ pageSizes?: IPdfPageSize[];
210
+ targetPageIds?: string[];
211
+ nativeTextSpansByPage: Record<string, IPdfNativeTextSpan[]>;
212
+ }
213
+ declare const SetPdfNativeTextSpansCommand: ICommand<ISetPdfNativeTextSpansCommandParams>;
214
+ interface IReplacePdfNativeTextCommandParams {
215
+ unitId?: string;
216
+ spanId: string;
217
+ newText: string;
218
+ style?: Partial<IPdfTextStyle>;
219
+ newElementId?: string;
220
+ }
221
+ declare const ReplacePdfNativeTextCommand: ICommand<IReplacePdfNativeTextCommandParams>;
222
+ interface IFindAndReplacePdfTextCommandParams {
223
+ unitId?: string;
224
+ query: string;
225
+ replacement: string;
226
+ matchCase?: boolean;
227
+ includeNativeText?: boolean;
228
+ onResult?: (replacedCount: number) => void;
229
+ }
230
+ declare const FindAndReplacePdfTextCommand: ICommand<IFindAndReplacePdfTextCommandParams>;
231
+ interface ISetPdfBookmarksCommandParams {
232
+ unitId?: string;
233
+ bookmarks: IPdfBookmarkItem[];
234
+ }
235
+ declare const SetPdfBookmarksCommand: ICommand<ISetPdfBookmarksCommandParams>;
236
+ interface ISetPdfBatesConfigCommandParams {
237
+ unitId?: string;
238
+ batesConfig?: IPdfBatesConfig;
239
+ }
240
+ declare const SetPdfBatesConfigCommand: ICommand<ISetPdfBatesConfigCommandParams>;
241
+ interface IAddPdfLayerCommandParams {
242
+ unitId?: string;
243
+ layer: Partial<IPdfLayer> & {
244
+ name: string;
245
+ };
246
+ onCreated?: (created: IPdfLayer) => void;
247
+ }
248
+ declare const AddPdfLayerCommand: ICommand<IAddPdfLayerCommandParams>;
249
+ interface IUpdatePdfLayerCommandParams {
250
+ unitId?: string;
251
+ layerId: string;
252
+ patch: Partial<Omit<IPdfLayer, 'id'>>;
253
+ }
254
+ declare const UpdatePdfLayerCommand: ICommand<IUpdatePdfLayerCommandParams>;
255
+ interface IRemovePdfLayerCommandParams {
256
+ unitId?: string;
257
+ layerId: string;
258
+ }
259
+ declare const RemovePdfLayerCommand: ICommand<IRemovePdfLayerCommandParams>;
260
+ interface IAssignPdfElementLayerCommandParams {
261
+ unitId?: string;
262
+ pageId?: string;
263
+ elementIds: string[];
264
+ layerId?: string;
265
+ }
266
+ declare const AssignPdfElementLayerCommand: ICommand<IAssignPdfElementLayerCommandParams>;
267
+ interface ISetPdfHeaderFooterConfigCommandParams {
268
+ unitId?: string;
269
+ headerFooterConfig?: IPdfHeaderFooterConfig;
270
+ }
271
+ declare const SetPdfHeaderFooterConfigCommand: ICommand<ISetPdfHeaderFooterConfigCommandParams>;
272
+ interface ISetPdfWatermarkConfigCommandParams {
273
+ unitId?: string;
274
+ watermarkConfig?: IPdfWatermarkConfig;
275
+ }
276
+ declare const SetPdfWatermarkConfigCommand: ICommand<ISetPdfWatermarkConfigCommandParams>;
277
+ interface ISetPdfAttachmentsCommandParams {
278
+ unitId?: string;
279
+ attachments: IPdfAttachment[];
280
+ }
281
+ declare const SetPdfAttachmentsCommand: ICommand<ISetPdfAttachmentsCommandParams>;
282
+ interface IUpdatePdfPagePropsCommandParams {
283
+ unitId?: string;
284
+ pageId?: string;
285
+ patch: Partial<Omit<IPdfPage, 'id'>>;
286
+ }
287
+ declare const UpdatePdfPagePropsCommand: ICommand<IUpdatePdfPagePropsCommandParams>;
288
+ interface IUpdatePdfUnitPropsCommandParams {
289
+ unitId?: string;
290
+ patch?: IPdfUnitPropsPatch;
291
+ /** Legacy fallback alias when `patch` is omitted */
292
+ props?: IPdfUnitPropsPatch;
293
+ }
294
+ declare const UpdatePdfUnitPropsCommand: ICommand<IUpdatePdfUnitPropsCommandParams>;
295
+
296
+ interface IAddPdfElementMutationParams {
297
+ unitId: string;
298
+ pageId: string;
299
+ element: IPdfPageElement;
300
+ index?: number;
301
+ }
302
+ declare const AddPdfElementMutation: IMutation<IAddPdfElementMutationParams>;
303
+ interface IUpdatePdfElementsMutationParams {
304
+ unitId: string;
305
+ pageId: string;
306
+ updates: Array<{
307
+ id: string;
308
+ element: IPdfPageElement;
309
+ }>;
310
+ }
311
+ declare const UpdatePdfElementsMutation: IMutation<IUpdatePdfElementsMutationParams>;
312
+ interface IRemovePdfElementsMutationParams {
313
+ unitId: string;
314
+ pageId: string;
315
+ elementIds: string[];
316
+ }
317
+ declare const RemovePdfElementsMutation: IMutation<IRemovePdfElementsMutationParams>;
318
+ interface IReorderPdfElementOrderMutationParams {
319
+ unitId: string;
320
+ pageId: string;
321
+ order: string[];
322
+ }
323
+ declare const ReorderPdfElementOrderMutation: IMutation<IReorderPdfElementOrderMutationParams>;
324
+ interface IAddPdfPageMutationParams {
325
+ unitId: string;
326
+ page: IPdfPage;
327
+ index?: number;
328
+ elements?: Record<string, IPdfPageElement>;
329
+ elementOrder?: string[];
330
+ }
331
+ declare const AddPdfPageMutation: IMutation<IAddPdfPageMutationParams>;
332
+ interface IRemovePdfPageMutationParams {
333
+ unitId: string;
334
+ pageId: string;
335
+ }
336
+ declare const RemovePdfPageMutation: IMutation<IRemovePdfPageMutationParams>;
337
+ interface IReorderPdfPagesMutationParams {
338
+ unitId: string;
339
+ pageOrder: string[];
340
+ }
341
+ declare const ReorderPdfPagesMutation: IMutation<IReorderPdfPagesMutationParams>;
342
+ interface IUpdatePdfPageMutationParams {
343
+ unitId: string;
344
+ pageId: string;
345
+ page: IPdfPage;
346
+ }
347
+ declare const UpdatePdfPageMutation: IMutation<IUpdatePdfPageMutationParams>;
348
+ interface IUpdatePdfUnitPropsMutationParams {
349
+ unitId: string;
350
+ patch?: IPdfUnitPropsPatch;
351
+ /** Legacy fallback alias when `patch` is omitted */
352
+ props?: IPdfUnitPropsPatch;
353
+ }
354
+ declare const UpdatePdfUnitPropsMutation: IMutation<IUpdatePdfUnitPropsMutationParams>;
355
+
356
+ /**
357
+ * Pure TypeScript 2D & Industrial Barcode Encoders (`GS1_128`, `DATAMATRIX` ECC 200, `PDF417`).
358
+ * Zero Node.js native dependencies (`fs`, `zlib`, `path`), working identically in Browser and headless Node/Workers.
359
+ */
360
+ interface IBarcodeBarRun {
361
+ /** Module X offset from left (0-based) */
362
+ x: number;
363
+ /** Consecutive dark module count */
364
+ w: number;
365
+ }
366
+ interface IGs1128EncodedResult {
367
+ raw: string;
368
+ humanReadable: string;
369
+ modules: boolean[];
370
+ runs: IBarcodeBarRun[];
371
+ widthModules: number;
372
+ }
373
+ interface IDataMatrixEncodedResult {
374
+ rows: number;
375
+ cols: number;
376
+ matrix: boolean[][];
377
+ }
378
+ interface IGs1DataMatrixEncodedResult extends IDataMatrixEncodedResult {
379
+ humanReadable: string;
380
+ dataCodewords: number[];
381
+ }
382
+ interface IPdf417EncodedResult {
383
+ rows: number;
384
+ dataCols: number;
385
+ securityLevel: number;
386
+ widthModules: number;
387
+ moduleRows: boolean[][];
388
+ rowRuns: IBarcodeBarRun[][];
389
+ }
390
+ declare function svgToDataUri(svg: string): string;
391
+ interface IGs1Segment {
392
+ ai: string;
393
+ value: string;
394
+ isFixedLength: boolean;
395
+ }
396
+ declare function parseGs1ApplicationIdentifiers(raw: string): IGs1Segment[];
397
+ declare function formatGs1HumanReadable(raw: string): string;
398
+ declare function encodeGs1128(raw: string): IGs1128EncodedResult;
399
+ declare function renderGs1128Svg(raw: string, options?: {
400
+ displayValue?: boolean;
401
+ foregroundColor?: string;
402
+ backgroundColor?: string;
403
+ height?: number;
404
+ }): string;
405
+ declare function renderGs1128SvgDataUrl(raw: string, options?: {
406
+ displayValue?: boolean;
407
+ foregroundColor?: string;
408
+ backgroundColor?: string;
409
+ height?: number;
410
+ }): string;
411
+ declare function encodeDataMatrix(text: string): IDataMatrixEncodedResult;
412
+ /**
413
+ * Encodes GS1 DataMatrix (ISO/IEC 16022 ECC 200 with leading `FNC1` codeword `232`
414
+ * and `FNC1` variable-length Application Identifier separators).
415
+ */
416
+ declare function encodeGs1DataMatrix(raw: string): IGs1DataMatrixEncodedResult;
417
+ declare function renderDataMatrixSvg(text: string, options?: {
418
+ foregroundColor?: string;
419
+ backgroundColor?: string;
420
+ quietZone?: number;
421
+ }): string;
422
+ declare function renderDataMatrixSvgDataUrl(text: string, options?: {
423
+ foregroundColor?: string;
424
+ backgroundColor?: string;
425
+ }): string;
426
+ declare function renderGs1DataMatrixSvg(raw: string, options?: {
427
+ foregroundColor?: string;
428
+ backgroundColor?: string;
429
+ quietZone?: number;
430
+ }): string;
431
+ declare function renderGs1DataMatrixSvgDataUrl(raw: string, options?: {
432
+ foregroundColor?: string;
433
+ backgroundColor?: string;
434
+ }): string;
435
+ declare function encodePdf417(text: string, options?: {
436
+ columns?: number;
437
+ securityLevel?: number;
438
+ }): IPdf417EncodedResult;
439
+ declare function renderPdf417Svg(text: string, options?: {
440
+ foregroundColor?: string;
441
+ backgroundColor?: string;
442
+ columns?: number;
443
+ securityLevel?: number;
444
+ rowHeight?: number;
445
+ }): string;
446
+ declare function renderPdf417SvgDataUrl(text: string, options?: {
447
+ foregroundColor?: string;
448
+ backgroundColor?: string;
449
+ columns?: number;
450
+ securityLevel?: number;
451
+ }): string;
452
+
453
+ declare const PDF_DIFF_COLORS: {
454
+ readonly added: "#16A34A";
455
+ readonly removed: "#DC2626";
456
+ readonly modified: "#2C53F1";
457
+ readonly moved: "#2C53F1";
458
+ };
459
+ interface IPdfElementDiffItem {
460
+ pageIndex: number;
461
+ id: string;
462
+ status: 'added' | 'removed' | 'modified' | 'moved';
463
+ summary: string;
464
+ color: string;
465
+ }
466
+ interface IPdfTextDiffItem {
467
+ pageIndex: number;
468
+ before: string;
469
+ after: string;
470
+ xMm: number;
471
+ yMm: number;
472
+ status: 'added' | 'removed' | 'modified';
473
+ color?: string;
474
+ }
475
+ interface IPdfComparisonResult {
476
+ identical: boolean;
477
+ pageCountBefore: number;
478
+ pageCountAfter: number;
479
+ pageCountChanged: boolean;
480
+ addedPages: number[];
481
+ removedPages: number[];
482
+ elementDiffs: IPdfElementDiffItem[];
483
+ textDiffs: IPdfTextDiffItem[];
484
+ }
485
+ interface IPdfFormFieldIssue {
486
+ pageIndex: number;
487
+ pageId: string;
488
+ elementId: string;
489
+ fieldName: string;
490
+ reason: 'required' | 'pattern';
491
+ message: string;
492
+ }
493
+ interface IPdfFormValidationResult {
494
+ valid: boolean;
495
+ issues: IPdfFormFieldIssue[];
496
+ }
497
+ /**
498
+ * Compares two `IPdfDocumentData` snapshots page-by-page across both overlay elements and native text spans.
499
+ */
500
+ declare function comparePdfUnits(beforeUnit: IPdfDocumentData, afterUnit: IPdfDocumentData): IPdfComparisonResult;
501
+ /**
502
+ * Compares two raw PDF binaries (`Uint8Array`) page-by-page across extracted native text spans and AcroForm widgets.
503
+ */
504
+ declare function comparePdfBytes(beforePdfBytes: Uint8Array, afterPdfBytes: Uint8Array): Promise<IPdfComparisonResult>;
505
+ /**
506
+ * Parses an existing interactive AcroForm PDF (`Uint8Array`), converting `/AcroForm` `/Fields` &
507
+ * page `/Annots` `/Subtype /Widget` (`/FT /Tx`, `/FT /Btn`, `/FT /Ch`, `/FT /Sig`) bottom-up `/Rect`
508
+ * points into top-down millimeter-aligned editable Univer PDF elements while keeping `pdfBytes` as `basePdf`.
509
+ */
510
+ declare function importAcroFormPdfToUnit(pdfBytes: Uint8Array, options?: {
511
+ unitId?: string;
512
+ title?: string;
513
+ }): Promise<IPdfDocumentData>;
514
+ /**
515
+ * Analyzes native text spans (and static label elements) on `pageIndex` for trailing `:` / `:` labels,
516
+ * `____` underlines, `[ ]` checkboxes, and signature prompts, returning aligned interactive form elements.
517
+ */
518
+ declare function detectFormFieldsFromPageSpans(unit: IPdfDocumentData, pageIndex: number): IPdfPageElement[];
519
+ /**
520
+ * Analyzes native text labels ending with `:` / `:` or `____` underlines on `pageIndex`
521
+ * and returns a cloned `IPdfDocumentData` populated with aligned interactive form fields.
522
+ */
523
+ declare function autoDetectFormFieldsOnPage(unit: IPdfDocumentData, pageIndex: number): IPdfDocumentData;
524
+ /**
525
+ * Safe recursive-descent arithmetic evaluator for PDF form `calcExpression` formulas (zero `eval`).
526
+ */
527
+ declare function evaluatePdfFormExpression(expression: string, fieldNumbers: Record<string, number>): number;
528
+ /**
529
+ * Evaluates `calcExpression` across all named PDF form fields (multi-pass dependency convergence)
530
+ * and formats results according to optional `valueFormat` & `decimals`.
531
+ */
532
+ declare function recalculatePdfFormFields(unit: IPdfDocumentData): IPdfDocumentData;
533
+ /**
534
+ * Validates `required` and `validationPattern` constraints across all interactive PDF form fields.
535
+ */
536
+ declare function validatePdfFormFields(unit: IPdfDocumentData): IPdfFormValidationResult;
537
+ /**
538
+ * Exports all interactive form field values from `unit` to standard Adobe XFDF XML (`http://ns.adobe.com/xfdf/`).
539
+ */
540
+ declare function exportFormDataToXfdf(unit: IPdfDocumentData): string;
541
+ /**
542
+ * Parses standard Adobe XFDF XML (supporting flat & nested `<field name="..."><value>...</value></field>`)
543
+ * and populates form values into a cloned `IPdfDocumentData` (triggering `recalculatePdfFormFields` automatically).
544
+ */
545
+ declare function importFormDataFromXfdf(unit: IPdfDocumentData, xfdfXml: string): IPdfDocumentData;
546
+ /**
547
+ * Exports all interactive form field values from `unit` to standard Adobe FDF 1.2 format (`%FDF-1.2`).
548
+ */
549
+ declare function exportFormDataToFdf(unit: IPdfDocumentData): string;
550
+ /**
551
+ * Imports form field values from standard Adobe FDF 1.2 text into a cloned `IPdfDocumentData`.
552
+ */
553
+ declare function importFormDataFromFdf(unit: IPdfDocumentData, fdfContent: string): IPdfDocumentData;
554
+
555
+ type PdfMat = [number, number, number, number, number, number];
556
+ interface IParsedStreamTextOp {
557
+ text: string;
558
+ left: number;
559
+ top: number;
560
+ width: number;
561
+ height: number;
562
+ fontSize: number;
563
+ /** Byte range in the page's concatenated content stream (when top-level) */
564
+ streamStartOffset?: number;
565
+ streamEndOffset?: number;
566
+ }
567
+ declare function parsePdfContentStreamTextOps(doc: PDFDocument, streamBytes: Uint8Array, resourcesDict: PDFDict | undefined, mediaBox: {
568
+ x: number;
569
+ y: number;
570
+ width: number;
571
+ height: number;
572
+ }, initialCtm?: PdfMat, isTopLevelStream?: boolean, depth?: number): IParsedStreamTextOp[];
573
+ /**
574
+ * Extracts native text spans (`IPdfNativeTextSpan[]`) from raw PDF bytes (`Uint8Array`),
575
+ * keyed by `pageId` (`pageIds[pageIndex] ?? 'page-${pageIndex + 1}'`).
576
+ *
577
+ * Uses a pure-TypeScript PDF content-stream parser (`BT ... ET`, `Tm`/`Td`/`TD`, `Tf`, `Tj`/`TJ`,
578
+ * literal `(...)`, hex `<...>`, UTF-16BE, and `/ToUnicode` CMap decoding) and seamlessly merges/falls back
579
+ * with `pdfjs-dist` `page.getTextContent()` when available in browser environments.
580
+ */
581
+ declare function extractNativeTextSpansFromPdfBytes(pdfBytes: Uint8Array, pageIds?: string[]): Promise<Record<string, IPdfNativeTextSpan[]>>;
582
+ declare function rectsIntersect(a: {
583
+ left: number;
584
+ top: number;
585
+ width: number;
586
+ height: number;
587
+ }, b: {
588
+ left: number;
589
+ top: number;
590
+ width: number;
591
+ height: number;
592
+ }): boolean;
593
+ /**
594
+ * Permanently strips top-level `Tj`/`TJ`/`'`/`"` text operations in a copied `PDFPage`'s content stream
595
+ * whose rendered bounding box intersects any redaction rectangle or matches a suppressed native text span.
596
+ */
597
+ declare function stripPdfPageNativeTextInRects(doc: PDFDocument, page: PDFPage, stripRects: Array<{
598
+ left: number;
599
+ top: number;
600
+ width: number;
601
+ height: number;
602
+ }>): number;
603
+ /**
604
+ * Merges multiple PDF binaries (`Uint8Array[]`) in sequence into a single standard PDF binary.
605
+ */
606
+ declare function mergePdfBytes(pdfList: Uint8Array[]): Promise<Uint8Array>;
607
+ /**
608
+ * Splits a PDF binary (`Uint8Array`) into multiple PDF binaries according to 1-based inclusive page ranges.
609
+ */
610
+ declare function splitPdfBytes(pdfBytes: Uint8Array, ranges: Array<{
611
+ startPage: number;
612
+ endPage: number;
613
+ }>): Promise<Uint8Array[]>;
614
+ /**
615
+ * Parses a human-readable 1-based page range expression (e.g. `"1-3, 5, 8-"`, `"all"`, `"*"`)
616
+ * against `totalPages` and returns deduplicated 1-based page numbers in specified order.
617
+ */
618
+ declare function parsePdfPageRange(rangeExpr: string, totalPages: number): number[];
619
+ /**
620
+ * Removes 1-based pages (`"2, 4-5"` or `[2, 4, 5]`) from a PDF binary and returns the new PDF bytes.
621
+ */
622
+ declare function removePdfPagesBytes(pdfBytes: Uint8Array, pagesToRemove: string | number[]): Promise<Uint8Array>;
623
+ /**
624
+ * Inserts pages from `insertPdfBytes` into `basePdfBytes` at 0-based `atPageIndex` (defaults to appending at the end).
625
+ */
626
+ declare function insertPdfPagesBytes(basePdfBytes: Uint8Array, insertPdfBytes: Uint8Array, atPageIndex?: number, sourcePages?: string | number[]): Promise<Uint8Array>;
627
+ /**
628
+ * Rotates specified 1-based pages (or all pages when omitted) in a PDF binary by `angleDeg` (`90 | 180 | 270 | -90 | 0`).
629
+ * By default adds `angleDeg` to existing page rotation (`relative !== false`), or sets absolute rotation when `relative: false`.
630
+ */
631
+ declare function rotatePdfPagesBytes(pdfBytes: Uint8Array, angleDeg: 0 | 90 | 180 | 270 | -90, pages?: string | number[], options?: {
632
+ relative?: boolean;
633
+ }): Promise<Uint8Array>;
634
+ /**
635
+ * Moves a single 1-based page from `fromPage` to `toPage` in a PDF binary.
636
+ */
637
+ declare function movePdfPageBytes(pdfBytes: Uint8Array, fromPage: number, toPage: number): Promise<Uint8Array>;
638
+ type IPdfOrganizePageSpec = number | {
639
+ /** 1-based page number from source PDF */
640
+ pageNumber: number;
641
+ /** Absolute clockwise rotation override (`0 | 90 | 180 | 270`) */
642
+ rotation?: 0 | 90 | 180 | 270;
643
+ /** Relative clockwise rotation delta (`90 | 180 | 270 | -90`) */
644
+ addRotation?: number;
645
+ };
646
+ type IPdfOrganizeAction = {
647
+ type: 'remove';
648
+ pages: string | number[];
649
+ } | {
650
+ type: 'rotate';
651
+ angle: 0 | 90 | 180 | 270 | -90;
652
+ pages?: string | number[];
653
+ relative?: boolean;
654
+ } | {
655
+ type: 'move';
656
+ fromPage: number;
657
+ toPage: number;
658
+ } | {
659
+ type: 'duplicate';
660
+ pageNumber: number;
661
+ insertAfter?: boolean;
662
+ };
663
+ /**
664
+ * Reorganizes a PDF binary in a single atomic pass (reordering, duplicating, deleting, and rotating pages)
665
+ * via either a declarative 1-based page plan (`[3, 1, { pageNumber: 2, rotation: 90 }]`) or sequential actions.
666
+ */
667
+ declare function organizePdfBytes(pdfBytes: Uint8Array, planOrOptions: IPdfOrganizePageSpec[] | {
668
+ pages?: IPdfOrganizePageSpec[];
669
+ actions?: IPdfOrganizeAction[];
670
+ }): Promise<Uint8Array>;
671
+
672
+ /** Exact 4-arc cubic Bezier circular/elliptical approximation constant `4 * (sqrt(2) - 1) / 3` */
673
+ declare const CIRCLE_MARK_BEZIER_KAPPA = 0.5522847498;
674
+ interface ICircleMarkBezierEllipse {
675
+ cx: number;
676
+ cy: number;
677
+ rx: number;
678
+ ry: number;
679
+ strokeWidthPt: number;
680
+ start: [number, number];
681
+ /** Four `[x1, y1, x2, y2, x3, y3]` cubic Bezier arc segments counter-clockwise around center */
682
+ segments: [
683
+ [
684
+ number,
685
+ number,
686
+ number,
687
+ number,
688
+ number,
689
+ number
690
+ ],
691
+ [
692
+ number,
693
+ number,
694
+ number,
695
+ number,
696
+ number,
697
+ number
698
+ ],
699
+ [
700
+ number,
701
+ number,
702
+ number,
703
+ number,
704
+ number,
705
+ number
706
+ ],
707
+ [
708
+ number,
709
+ number,
710
+ number,
711
+ number,
712
+ number,
713
+ number
714
+ ]
715
+ ];
716
+ }
717
+ declare function isCircleMarkChecked(element: Pick<IPdfCircleMarkElement, 'checked' | 'content'>, boundValue?: unknown): boolean;
718
+ declare function toggleCircleMarkState(element: Pick<IPdfCircleMarkElement, 'checked' | 'content'>): {
719
+ checked: boolean;
720
+ content: 'true' | 'false';
721
+ };
722
+ /**
723
+ * Computes a true 4-arc cubic Bezier ellipse (`kappa = 0.5522847498`) inset by `strokeWidthPt / 2`
724
+ * in PDF page bottom-left coordinates `(x, y, width, height)`.
725
+ */
726
+ declare function computeCircleMarkBezierEllipse(box: {
727
+ x: number;
728
+ y: number;
729
+ width: number;
730
+ height: number;
731
+ }, strokeWidthMm?: number): ICircleMarkBezierEllipse;
732
+ interface ITemplateVariableMatch {
733
+ name: string;
734
+ rawToken: string;
735
+ start: number;
736
+ end: number;
737
+ syntax: 'brace' | 'dollar' | 'hash';
738
+ }
739
+ /**
740
+ * Fast O(1)-amortized boundary precheck for JSON object strings without regex substring pinning.
741
+ */
742
+ declare function mayBeJson(raw: unknown): raw is string;
743
+ /**
744
+ * Linear O(n) non-backtracking scanner for `{var}`, `${var}`, and `#{var}` placeholders.
745
+ * Skips double-brace page tokens (`{{page}}`, `{{totalPages}}`) and never backtracks on unclosed `{`.
746
+ */
747
+ declare function visitTemplateVariables(template: string, visitor?: (match: ITemplateVariableMatch) => void): ITemplateVariableMatch[];
748
+ /**
749
+ * Safely parses a JSON key-value string or plain record into a prototype-pollution-free
750
+ * null-prototype lookup map (`__proto__`, `constructor`, `prototype` stripped at all levels).
751
+ */
752
+ declare function parseSafeKeyValueRecord(rawInput: unknown, fallbackData?: Record<string, unknown>): Record<string, unknown>;
753
+ declare function safeLookupVariablePath(dict: Record<string, unknown>, path: string): unknown;
754
+ /**
755
+ * Zero-`eval` safe recursive-descent expression evaluator supporting variable paths,
756
+ * `+ - * / %`, `== != > >= < <= && ||`, ternary `? :`, string concatenation, and
757
+ * `Math.round / floor / ceil / min / max / abs` with full prototype-pollution protection.
758
+ */
759
+ declare function evaluateSafeTemplateExpression(rawExpr: string, dict: Record<string, unknown>): {
760
+ ok: boolean;
761
+ value: unknown;
762
+ };
763
+ /**
764
+ * Linear O(n) non-backtracking scanner for `{expr}`, `${expr}`, and `#{expr}` tokens
765
+ * (both simple variable paths and safe arithmetic/ternary expressions).
766
+ */
767
+ declare function scanTemplateExpressionTokens(template: string): ITemplateVariableMatch[];
768
+ /**
769
+ * Substitutes `{var}`, `${var}`, `#{var}`, and safe expressions (`{price * qty}`, `{a > b ? 'Y' : 'N'}`)
770
+ * in `template` using either a JSON-encoded key-value string (`{"name":"Alice"}`) or a record object,
771
+ * with O(n) scanning, zero `eval`, and prototype-pollution protection.
772
+ */
773
+ declare function resolveMultiVariableText(template: string, rawInput: unknown, fallbackData?: Record<string, unknown>): string;
774
+ declare function wrapPdfTextLines(text: string, innerWidthPt: number, fontSizePt?: number, bold?: boolean, characterSpacingPt?: number): string[];
775
+ declare function computeExpandedTextHeightPt(element: Pick<IPdfTextElement, 'transform' | 'style' | 'columns' | 'columnGapPt' | 'overflow'>, resolvedText: string): number;
776
+ /**
777
+ * Computes expanded height in millimeters (`mm`) for an `overflow: 'expand'` text element
778
+ * so all wrapped lines fit without shrinking font size.
779
+ */
780
+ declare function computeExpandedTextHeightMm(element: Pick<IPdfTextElement, 'transform' | 'style' | 'columns' | 'columnGapPt' | 'overflow'>, resolvedText: string): number;
781
+ interface IDynamicLayoutItemInput {
782
+ id: string;
783
+ topMm: number;
784
+ heightMm: number;
785
+ expandedHeightMm?: number;
786
+ lineHeightMm?: number;
787
+ splittable?: boolean;
788
+ }
789
+ interface IDynamicLayoutPlacement {
790
+ id: string;
791
+ origTopMm: number;
792
+ origHeightMm: number;
793
+ layoutTopMm: number;
794
+ layoutHeightMm: number;
795
+ layoutBottomMm: number;
796
+ shiftYMm: number;
797
+ lineHeightMm?: number;
798
+ splittable: boolean;
799
+ }
800
+ interface IDynamicLayoutSplitRange {
801
+ pageIndex: number;
802
+ startYMm: number;
803
+ endYMm: number;
804
+ heightMm: number;
805
+ elementIds: string[];
806
+ placements: IDynamicLayoutPlacement[];
807
+ }
808
+ interface IDynamicLayoutSplitOptions {
809
+ marginTopMm?: number;
810
+ marginBottomMm?: number;
811
+ resolvedTextsById?: Record<string, string>;
812
+ }
813
+ /**
814
+ * Computes vertical dynamic layout shifts and clean cross-page split ranges (`[startYMm, endYMm]`)
815
+ * when `overflow: 'expand'` elements expand beyond their initial template box or page height.
816
+ */
817
+ declare function computeDynamicLayoutSplitRanges(items: ReadonlyArray<IDynamicLayoutItemInput | IPdfPageElement>, pageHeightMm: number, optionsOrPadding?: IDynamicLayoutSplitOptions | [number, number, number, number]): IDynamicLayoutSplitRange[];
818
+ declare function getDefaultDateTimeFormat(dateKind?: PdfDateTimeKind): string;
819
+ /**
820
+ * Formats ISO dates, timestamps, or `HH:mm` strings according to `format`
821
+ * (supporting both `YYYY/MM/DD HH:mm:ss` and `yyyy/MM/dd HH:mm:ss` tokens).
822
+ */
823
+ declare function formatPdfDateTimeValue(raw: string, format?: string, dateKind?: PdfDateTimeKind, locale?: string): string;
824
+ /**
825
+ * Normalizes a date/time value for HTML `<input type="date" | "time" | "datetime-local">`.
826
+ */
827
+ declare function toHtmlDateTimeInputValue(raw: string, dateKind: PdfDateTimeKind): string;
828
+ type PdfExifOrientation = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
829
+ type PdfExifMatrixTuple = [number, number, number, number, number, number];
830
+ /**
831
+ * Parses JPEG APP1 (`0xFFE1`) `Exif\0\0` TIFF IFD0 tag `0x0112` in both little-endian (`II`)
832
+ * and big-endian (`MM`) byte orders, returning EXIF orientation `1..8` (`1` when absent/non-JPEG).
833
+ */
834
+ declare function readJpegExifOrientation(jpegBytes: Uint8Array): PdfExifOrientation;
835
+ declare function isExifDimensionsSwapped(orientation: PdfExifOrientation): boolean;
836
+ /**
837
+ * Computes the PDF 6-element affine transformation matrix `[a, b, c, d, e, f]` (`cm` operator)
838
+ * mapping a unit `[0, 1] x [0, 1]` PDF Image XObject upright onto target rectangle `(x, y, width, height)`.
839
+ */
840
+ declare function computeExifTransformMatrix(orientation: PdfExifOrientation): PdfExifMatrixTuple;
841
+ declare function computeExifTransformMatrix(orientation: PdfExifOrientation, width: number, height: number): PdfExifMatrixTuple;
842
+ declare function computeExifTransformMatrix(orientation: PdfExifOrientation, x: number, y: number, width: number, height: number): PdfExifMatrixTuple;
843
+ declare function parseInlineMarkdownToSpans(rawText: string): IPdfRichTextSpan[];
844
+ interface IParsedPdfColor {
845
+ r: number;
846
+ g: number;
847
+ b: number;
848
+ a: number;
849
+ c: number;
850
+ m: number;
851
+ y: number;
852
+ k: number;
853
+ sourceSpace: 'rgb' | 'cmyk';
854
+ }
855
+ declare function rgbToCmyk(r: number, g: number, b: number): {
856
+ c: number;
857
+ m: number;
858
+ y: number;
859
+ k: number;
860
+ };
861
+ declare function cmykToRgb(c: number, m: number, y: number, k: number): {
862
+ r: number;
863
+ g: number;
864
+ b: number;
865
+ };
866
+ /**
867
+ * Parses `#RGB`, `#RGBA`, `#RRGGBB`, `#RRGGBBAA`, `rgb(...)`, `rgba(...)`, `cmyk(...)`, and common named SVG colors
868
+ * into normalized `[0..1]` RGB + alpha + CMYK components.
869
+ */
870
+ declare function parsePdfColorWithAlpha(raw?: string): IParsedPdfColor | null;
871
+ interface IPdfListPageChunk {
872
+ chunkIndex: number;
873
+ startIndex: number;
874
+ items: string[];
875
+ }
876
+ declare function paginatePdfListItems(el: Pick<IPdfListElement, 'items' | 'listType' | 'style' | 'transform'>, resolvedItems: string[], pageHeightPt: number, marginTopPt?: number, marginBottomPt?: number): IPdfListPageChunk[];
877
+ interface ISnapGuideLine {
878
+ axis: 'x' | 'y';
879
+ posPt: number;
880
+ kind?: 'align' | 'gap';
881
+ gapStartPt?: number;
882
+ gapEndPt?: number;
883
+ crossPosPt?: number;
884
+ gapValuePt?: number;
885
+ }
886
+ interface ISmartSnapBox {
887
+ id: string;
888
+ left: number;
889
+ top: number;
890
+ width: number;
891
+ height: number;
892
+ }
893
+ interface IComputeSmartSnapParams {
894
+ stationaryBoxes: ReadonlyArray<ISmartSnapBox>;
895
+ candidateLeft: number;
896
+ candidateTop: number;
897
+ width: number;
898
+ height: number;
899
+ pageWidth: number;
900
+ pageHeight: number;
901
+ snapEnabled?: boolean;
902
+ thresholdPt?: number;
903
+ }
904
+ /**
905
+ * Computes magnetic edge/center alignment snap guides AND equal-spacing distribution guides
906
+ * (`gap(A, B) === gap(B, C)` along both horizontal and vertical axes).
907
+ */
908
+ declare function computeSmartSnapWithEqualGap(params: IComputeSmartSnapParams): {
909
+ left: number;
910
+ top: number;
911
+ guides: ISnapGuideLine[];
912
+ };
913
+ /**
914
+ * Computes cascade paste offset `(14 * pasteStep, 14 * pasteStep)` in points so repeated
915
+ * `Ctrl+V` pastes stagger cleanly without stacking on top of each other.
916
+ */
917
+ declare function computePasteCascadeOffset(pasteStep: number, baseStepPt?: number): {
918
+ dx: number;
919
+ dy: number;
920
+ };
921
+ type SignatureQuadraticSegment = {
922
+ type: 'M';
923
+ x: number;
924
+ y: number;
925
+ } | {
926
+ type: 'L';
927
+ x: number;
928
+ y: number;
929
+ } | {
930
+ type: 'Q';
931
+ cx: number;
932
+ cy: number;
933
+ x: number;
934
+ y: number;
935
+ };
936
+ /**
937
+ * Converts a raw pointer stroke into midpoint-interpolated quadratic Bezier segments
938
+ * for silky-smooth handwritten signature rendering on HTML5 `<canvas>`.
939
+ */
940
+ declare function smoothSignatureStrokeQuadratic(points: ReadonlyArray<{
941
+ x: number;
942
+ y: number;
943
+ }>): SignatureQuadraticSegment[];
944
+
945
+ type SvgMat2D = [number, number, number, number, number, number];
946
+ interface IImageFitPlacement {
947
+ drawX: number;
948
+ drawY: number;
949
+ drawWidth: number;
950
+ drawHeight: number;
951
+ clipX: number;
952
+ clipY: number;
953
+ clipWidth: number;
954
+ clipHeight: number;
955
+ needsClip: boolean;
956
+ }
957
+ declare function parseObjectPositionRatios(objectPosition?: string): {
958
+ ax: number;
959
+ ayTop: number;
960
+ };
961
+ /**
962
+ * Computes exact PDF bottom-left `(drawX, drawY, drawWidth, drawHeight)` and clip requirement
963
+ * for `IMAGE` `fit` (`'contain' | 'cover' | 'fill'`) + 9-way `objectPosition`.
964
+ */
965
+ declare function computeImageFitPlacement(box: {
966
+ x: number;
967
+ y: number;
968
+ width: number;
969
+ height: number;
970
+ }, intrinsicWidth: number, intrinsicHeight: number, fit?: 'contain' | 'cover' | 'fill', objectPosition?: string): IImageFitPlacement;
971
+ /**
972
+ * Computes a PDF center-pivot transformation matrix `[a, b, c, d, e, f]` around `(x + width/2, y + height/2)`
973
+ * for clockwise `angleDeg` rotation and optional `flipX` / `flipY` mirroring.
974
+ * Returns `null` when the transform is identity.
975
+ */
976
+ declare function computeElementCenterTransformMatrix(box: {
977
+ x: number;
978
+ y: number;
979
+ width: number;
980
+ height: number;
981
+ }, angleDeg?: number, flipX?: boolean, flipY?: boolean): SvgMat2D | null;
982
+ declare function toPdfLibColor(parsed: Pick<IParsedPdfColor, 'r' | 'g' | 'b'> & Partial<IParsedPdfColor>, colorType?: PdfColorSpaceType): pdf_lib.CMYK | pdf_lib.RGB;
983
+ declare function parseSvgTransformAttr(raw?: string): SvgMat2D;
984
+ interface IParsedSvgVectorDrawOp {
985
+ tag: string;
986
+ pathData: string;
987
+ fill?: IParsedPdfColor | null;
988
+ stroke?: IParsedPdfColor | null;
989
+ strokeWidthPt: number;
990
+ fillOpacity: number;
991
+ strokeOpacity: number;
992
+ dashArray?: number[];
993
+ }
994
+ /**
995
+ * Parses an `<svg>` XML string into transformed vector path drawing operations scaled into `(boxWidthPt, boxHeightPt)`.
996
+ */
997
+ declare function parseSvgToVectorCommands(svgXml: string, boxWidthPt: number, boxHeightPt: number, baseOpacity?: number): IParsedSvgVectorDrawOp[];
998
+ /**
999
+ * Renders a Clean-Room vector `<svg>` element onto a `pdf-lib` `PDFPage` using `drawSvgPath` and clip operators.
1000
+ */
1001
+ declare function drawVectorSvgOnPdfPage(pdfPage: PDFPage, pageHeight: number, left: number, top: number, width: number, height: number, svgXml: string, opacity?: number, colorType?: PdfColorSpaceType): number;
1002
+
1003
+ /**
1004
+ * Pure-TypeScript synchronous FIPS 180-4 SHA-256 digest (`Uint8Array`),
1005
+ * operating in any browser, worker, or server JS runtime with zero Node `crypto` imports.
1006
+ */
1007
+ declare function sha256BytesSync(input: Uint8Array | string): Uint8Array;
1008
+ /**
1009
+ * Pure-TypeScript synchronous lowercase hex SHA-256 digest.
1010
+ */
1011
+ declare function sha256HexSync(input: Uint8Array | string): string;
1012
+ /**
1013
+ * Asynchronous SHA-256 hex digest using standard WebCrypto `SubtleCrypto` when available,
1014
+ * falling back seamlessly to `sha256HexSync` in restricted runtimes.
1015
+ */
1016
+ declare function sha256Hex(input: Uint8Array | string): Promise<string>;
1017
+ /**
1018
+ * Deterministic key-sorted JSON serializer ensuring canonical digest stability regardless of property insertion order.
1019
+ */
1020
+ declare function canonicalJsonStringify(value: unknown): string;
1021
+ interface IPdfAuditSealOptions {
1022
+ signer: string;
1023
+ reason?: string;
1024
+ organization?: string;
1025
+ signedAt?: string;
1026
+ /** Stamps a subtle tamper-evident verification footer/badge across exported pages (default `true`) */
1027
+ stampAuditFooter?: boolean;
1028
+ exportOptions?: IPdfExportOptions;
1029
+ }
1030
+ interface IPdfSignedAuditResult {
1031
+ pdfBytes: Uint8Array;
1032
+ digestHex: string;
1033
+ signedAt: string;
1034
+ }
1035
+ interface IPdfAuditVerificationResult {
1036
+ signed: boolean;
1037
+ validSignatureStructure: boolean;
1038
+ signer?: string;
1039
+ organization?: string;
1040
+ reason?: string;
1041
+ signedAt?: string;
1042
+ digestHex?: string;
1043
+ }
1044
+ /**
1045
+ * Exports a PDF binary sealed with a deterministic SHA-256 cryptographic audit digest
1046
+ * over the canonical template snapshot, bound data, rendered page streams, and signer metadata.
1047
+ */
1048
+ declare function exportSignedPdfWithAuditSeal(unitData: IPdfUnitData, data: Record<string, unknown> | undefined, sealOptions: IPdfAuditSealOptions): Promise<IPdfSignedAuditResult>;
1049
+ /**
1050
+ * Parses an exported PDF binary via `PDFDocument.load`, inspects the embedded `/UniverAuditSeal`
1051
+ * metadata dictionary & subject digest, and cryptographically verifies page content stream integrity.
1052
+ */
1053
+ declare function verifyPdfAuditSeal(pdfBytes: Uint8Array): Promise<IPdfAuditVerificationResult>;
1054
+
1055
+ /**
1056
+ * Canonical 12 barcode symbologies supported across schema templates and PDF export.
1057
+ */
1058
+ declare const BARCODE_TYPES: readonly ["qrcode", "japanpost", "ean13", "ean8", "code39", "code128", "nw7", "itf14", "upca", "upce", "gs1datamatrix", "pdf417"];
1059
+ type PdfCanonicalBarcodeType = (typeof BARCODE_TYPES)[number] | 'datamatrix' | 'gs1-128';
1060
+ /**
1061
+ * Matrix and stacked 2D barcode types whose module aspect ratio must remain locked
1062
+ * (centered and letterboxed inside the element bounding box rather than stretched).
1063
+ */
1064
+ declare const ASPECT_RATIO_LOCKED_BARCODE_TYPES: readonly ["qrcode", "datamatrix", "gs1datamatrix", "pdf417"];
1065
+ type AspectRatioLockedBarcodeType = (typeof ASPECT_RATIO_LOCKED_BARCODE_TYPES)[number];
1066
+ interface IBarcodeLayoutBox {
1067
+ x: number;
1068
+ y: number;
1069
+ width: number;
1070
+ height: number;
1071
+ letterboxed: boolean;
1072
+ scaleX: number;
1073
+ scaleY: number;
1074
+ }
1075
+ interface INw7EncodedResult {
1076
+ raw: string;
1077
+ framedPayload: string;
1078
+ humanReadable: string;
1079
+ /** 7-element (4 bars, 3 spaces) module widths per character in `framedPayload` */
1080
+ elementWidthsPerChar: number[][];
1081
+ modules: boolean[];
1082
+ runs: IBarcodeBarRun[];
1083
+ widthModules: number;
1084
+ }
1085
+ type JapanPostBarState = 'long' | 'ascender' | 'descender' | 'tracker';
1086
+ interface IJapanPostBar {
1087
+ index: number;
1088
+ xModule: number;
1089
+ widthModules: number;
1090
+ state: JapanPostBarState;
1091
+ /** Normalized vertical offset from top of bar track (`0` for long/ascender, `1/3` for descender/tracker) */
1092
+ topRatio: number;
1093
+ /** Normalized bar height fraction relative to full bar height (`1`, `2/3`, `2/3`, `1/3`) */
1094
+ heightRatio: number;
1095
+ }
1096
+ interface IJapanPostEncodedResult {
1097
+ raw: string;
1098
+ normalizedInput: string;
1099
+ dataSymbols: string[];
1100
+ /** Modulo-19 check value (`0..18`) such that `(sum + checkValue) % 19 === 0` */
1101
+ checkValue: number;
1102
+ /** Japan Post table symbol at `checkValue` (`'0'..'9' | '-' | 'CC1'..'CC8'`) */
1103
+ checkSymbol: string;
1104
+ /** 1-based check code index label (`'CC1'..'CC19'`) */
1105
+ checkCode: string;
1106
+ bars: IJapanPostBar[];
1107
+ widthModules: number;
1108
+ }
1109
+ interface ILinear1dEncodedResult {
1110
+ format: PdfCanonicalBarcodeType;
1111
+ raw: string;
1112
+ humanReadable: string;
1113
+ modules: boolean[];
1114
+ runs: IBarcodeBarRun[];
1115
+ widthModules: number;
1116
+ }
1117
+ type IUnifiedBarcodeEncoded = {
1118
+ kind: 'matrix';
1119
+ format: 'qrcode' | 'datamatrix' | 'gs1datamatrix';
1120
+ rows: number;
1121
+ cols: number;
1122
+ matrix: boolean[][];
1123
+ quietZone: number;
1124
+ intrinsicWidth: number;
1125
+ intrinsicHeight: number;
1126
+ humanReadable?: string;
1127
+ dataCodewords?: number[];
1128
+ } | {
1129
+ kind: 'stacked2d';
1130
+ format: 'pdf417';
1131
+ encoded: IPdf417EncodedResult;
1132
+ rowModuleHeight: number;
1133
+ intrinsicWidth: number;
1134
+ intrinsicHeight: number;
1135
+ } | {
1136
+ kind: '4state';
1137
+ format: 'japanpost';
1138
+ encoded: IJapanPostEncodedResult;
1139
+ intrinsicWidth: number;
1140
+ intrinsicHeight: number;
1141
+ } | {
1142
+ kind: '1d';
1143
+ format: Exclude<PdfCanonicalBarcodeType, 'qrcode' | 'datamatrix' | 'gs1datamatrix' | 'pdf417' | 'japanpost'>;
1144
+ humanReadable: string;
1145
+ modules: boolean[];
1146
+ runs: IBarcodeBarRun[];
1147
+ widthModules: number;
1148
+ intrinsicWidth: number;
1149
+ intrinsicHeight: number;
1150
+ };
1151
+ /**
1152
+ * Normalizes case and separator variations (including `'codabar'` -> `'nw7'`,
1153
+ * `'gs1_datamatrix'` -> `'gs1datamatrix'`, `'upc'` -> `'upca'`) into a canonical barcode type.
1154
+ */
1155
+ declare function normalizeBarcodeFormatType(format?: string): PdfCanonicalBarcodeType;
1156
+ declare function isAspectRatioLockedBarcodeType(format?: string): boolean;
1157
+ /**
1158
+ * Computes the rendered target box for a barcode:
1159
+ * - For `ASPECT_RATIO_LOCKED_BARCODE_TYPES` (`qrcode`, `datamatrix`, `gs1datamatrix`, `pdf417`):
1160
+ * centers and letterboxes at intrinsic aspect ratio so 2D modules are never distorted.
1161
+ * - For 1D & postal symbologies: stretches horizontally across the element bounding box.
1162
+ */
1163
+ declare function computeBarcodeLayoutBox(container: {
1164
+ x: number;
1165
+ y: number;
1166
+ width: number;
1167
+ height: number;
1168
+ }, format: string | undefined, intrinsic: {
1169
+ width: number;
1170
+ height: number;
1171
+ }): IBarcodeLayoutBox;
1172
+ /**
1173
+ * Encodes a string in NW-7 (Codabar) 7-element symbology (`4 bars, 3 spaces`),
1174
+ * automatically framing with `'A'` start and `'A'` stop characters when omitted.
1175
+ */
1176
+ declare function encodeNw7(raw: string): INw7EncodedResult;
1177
+ declare const encodeCodabar: typeof encodeNw7;
1178
+ /**
1179
+ * Encodes a Japanese postal + block/building address string into a genuine 67-bar
1180
+ * Japan Post 4-state Customer Barcode with automatic modulo-19 check character.
1181
+ */
1182
+ declare function encodeJapanPost(raw: string): IJapanPostEncodedResult;
1183
+ declare function encodeCode128(raw: string): ILinear1dEncodedResult;
1184
+ declare function encodeCode39(raw: string): ILinear1dEncodedResult;
1185
+ declare function encodeEan13(raw: string): ILinear1dEncodedResult;
1186
+ declare function encodeUpcA(raw: string): ILinear1dEncodedResult;
1187
+ declare function encodeEan8(raw: string): ILinear1dEncodedResult;
1188
+ declare function encodeUpcE(raw: string): ILinear1dEncodedResult;
1189
+ declare function encodeItf14(raw: string): ILinear1dEncodedResult;
1190
+ declare function encodeQrCodeMatrix(raw: string): IDataMatrixEncodedResult;
1191
+ /**
1192
+ * Unified pure-TS encoder covering all 12 `BARCODE_TYPES` plus `codabar`, `datamatrix`, and `gs1-128`.
1193
+ */
1194
+ declare function encodeBarcodeByFormat(format: string | undefined, raw: string): IUnifiedBarcodeEncoded;
1195
+ declare function renderBarcodeSvgByFormat(format: string | undefined, raw: string, options?: {
1196
+ displayValue?: boolean;
1197
+ foregroundColor?: string;
1198
+ textColor?: string;
1199
+ backgroundColor?: string;
1200
+ height?: number;
1201
+ }): string;
1202
+ declare function renderBarcodeSvgDataUrlByFormat(format: string | undefined, raw: string, options?: {
1203
+ displayValue?: boolean;
1204
+ foregroundColor?: string;
1205
+ textColor?: string;
1206
+ backgroundColor?: string;
1207
+ height?: number;
1208
+ }): string;
1209
+
1210
+ type IPdfWordBlock = {
1211
+ type: 'heading' | 'paragraph';
1212
+ text: string;
1213
+ fontSize: number;
1214
+ bold?: boolean;
1215
+ pageIndex: number;
1216
+ topPt: number;
1217
+ } | {
1218
+ type: 'list';
1219
+ ordered: boolean;
1220
+ items: string[];
1221
+ pageIndex: number;
1222
+ topPt: number;
1223
+ } | {
1224
+ type: 'table';
1225
+ headers: string[];
1226
+ rows: string[][];
1227
+ pageIndex: number;
1228
+ topPt: number;
1229
+ } | {
1230
+ type: 'image';
1231
+ altText: string;
1232
+ widthPt: number;
1233
+ heightPt: number;
1234
+ src?: string;
1235
+ pageIndex: number;
1236
+ topPt: number;
1237
+ };
1238
+ interface IPdfWordConvertedPage {
1239
+ pageIndex: number;
1240
+ pageId: string;
1241
+ blocks: IPdfWordBlock[];
1242
+ }
1243
+ interface IPdfWordConvertedStructure {
1244
+ title: string;
1245
+ pages: IPdfWordConvertedPage[];
1246
+ blocks: IPdfWordBlock[];
1247
+ }
1248
+ interface IPdfSheetConvertedTable {
1249
+ sheetName: string;
1250
+ pageIndex: number;
1251
+ rows: string[][];
1252
+ columnCount: number;
1253
+ }
1254
+ interface IPdfSheetConvertedStructure {
1255
+ name: string;
1256
+ sheets: IPdfSheetConvertedTable[];
1257
+ }
1258
+ interface IPdfDocxDocumentSnapshot {
1259
+ id: string;
1260
+ title: string;
1261
+ body: {
1262
+ dataStream: string;
1263
+ textRuns: Array<{
1264
+ st: number;
1265
+ ed: number;
1266
+ ts?: {
1267
+ fs?: number;
1268
+ bl?: 0 | 1;
1269
+ };
1270
+ }>;
1271
+ paragraphs: Array<{
1272
+ startIndex: number;
1273
+ paragraphStyle?: {
1274
+ headingId?: string;
1275
+ };
1276
+ }>;
1277
+ sectionBreaks: Array<{
1278
+ startIndex: number;
1279
+ }>;
1280
+ tables?: Array<{
1281
+ rows: string[][];
1282
+ headers: string[];
1283
+ }>;
1284
+ };
1285
+ documentStyle: {
1286
+ pageSize: {
1287
+ width: number;
1288
+ height: number;
1289
+ };
1290
+ marginTop: number;
1291
+ marginBottom: number;
1292
+ marginLeft: number;
1293
+ marginRight: number;
1294
+ };
1295
+ }
1296
+ interface IPdfWorkbookCell {
1297
+ v: string | number;
1298
+ t: 1 | 2;
1299
+ s?: string;
1300
+ }
1301
+ interface IPdfWorkbookSnapshot {
1302
+ id: string;
1303
+ name: string;
1304
+ appVersion: string;
1305
+ sheetOrder: string[];
1306
+ styles: Record<string, {
1307
+ bl?: 0 | 1;
1308
+ bg?: {
1309
+ rgb: string;
1310
+ };
1311
+ }>;
1312
+ sheets: Record<string, {
1313
+ id: string;
1314
+ name: string;
1315
+ rowCount: number;
1316
+ columnCount: number;
1317
+ cellData: Record<number, Record<number, IPdfWorkbookCell>>;
1318
+ }>;
1319
+ }
1320
+ /**
1321
+ * Extracts native text spans + overlay `TEXT` / `TABLE` / `LIST` / `IMAGE` elements sorted top-to-bottom
1322
+ * and clusters aligned horizontal baselines & X-columns into structured Word paragraphs, headings, tables, lists, and images.
1323
+ */
1324
+ declare function convertPdfToWordStructure(unit: IPdfDocumentData): IPdfWordConvertedStructure;
1325
+ /**
1326
+ * Converts a PDF unit into structured Sheet rows & columns per page (aligning X-column intervals & explicit `TABLE` elements).
1327
+ */
1328
+ declare function convertPdfToSheetStructure(unit: IPdfDocumentData): IPdfSheetConvertedStructure;
1329
+ /**
1330
+ * Exports an `IPdfDocumentData` unit into a `.docx`-compatible Univer `IDocumentData`-shaped JSON snapshot.
1331
+ */
1332
+ declare function exportPdfToDocxSnapshot(unit: IPdfDocumentData): IPdfDocxDocumentSnapshot;
1333
+ /**
1334
+ * Exports an `IPdfDocumentData` unit into an `.xlsx`-compatible Univer `IWorkbookData`-shaped JSON snapshot.
1335
+ */
1336
+ declare function exportPdfToWorkbookSnapshot(unit: IPdfDocumentData): IPdfWorkbookSnapshot;
1337
+ /**
1338
+ * Pure-TS `.docx` OpenXML ZIP archive generator from either raw `Uint8Array` PDF bytes or an `IPdfDocumentData` unit.
1339
+ */
1340
+ declare function convertPdfBytesToDocxBytes(input: Uint8Array | IPdfDocumentData): Promise<Uint8Array>;
1341
+ /**
1342
+ * Synchronous RFC 4180 CSV serializer from an `IPdfDocumentData` unit.
1343
+ */
1344
+ declare function convertPdfUnitToCsv(unit: IPdfDocumentData): string;
1345
+ /**
1346
+ * Converts either raw `Uint8Array` PDF bytes or an `IPdfDocumentData` unit into RFC 4180 CSV text.
1347
+ */
1348
+ declare function convertPdfBytesToCsv(input: Uint8Array | IPdfDocumentData): Promise<string>;
1349
+ interface IPdfOcrRecognizedBlock {
1350
+ text: string;
1351
+ xMm: number;
1352
+ yMm: number;
1353
+ widthMm: number;
1354
+ heightMm: number;
1355
+ confidence: number;
1356
+ }
1357
+ interface IPdfOcrPageInfo {
1358
+ unitId: string;
1359
+ pageId: string;
1360
+ pageIndex: number;
1361
+ widthMm: number;
1362
+ heightMm: number;
1363
+ sourceDataUri?: string;
1364
+ snapshot: IPdfDocumentData;
1365
+ }
1366
+ interface IPdfOcrAdapter {
1367
+ name?: string;
1368
+ recognizePage: (pageInfo: IPdfOcrPageInfo) => Promise<IPdfOcrRecognizedBlock[]> | IPdfOcrRecognizedBlock[];
1369
+ }
1370
+ /**
1371
+ * Registers a pluggable OCR recognition adapter (e.g. Tesseract.js / PaddleOCR / Cloud Vision bridge).
1372
+ */
1373
+ declare function registerOcrAdapter(adapter: IPdfOcrAdapter): void;
1374
+ declare function getRegisteredOcrAdapter(): IPdfOcrAdapter | null;
1375
+ /**
1376
+ * Applies OCR recognition on `pageIndex` using `adapter` (or the registered global `IPdfOcrAdapter`),
1377
+ * injecting either searchable invisible `3 Tr` spans (`'searchable'`) or editable `TEXT` boxes (`'editable'`).
1378
+ */
1379
+ declare function applyOcrToUnitPage(unit: IPdfDocumentData, pageIndex: number, mode: 'searchable' | 'editable', adapter?: IPdfOcrAdapter): Promise<{
1380
+ unit: IPdfDocumentData;
1381
+ blocks: IPdfOcrRecognizedBlock[];
1382
+ }>;
1383
+ interface IPdfSanitizeOptions {
1384
+ stripComments?: boolean;
1385
+ stripAttachments?: boolean;
1386
+ stripAuthorHistory?: boolean;
1387
+ stripScripts?: boolean;
1388
+ stripSampleData?: boolean;
1389
+ }
1390
+ /**
1391
+ * Permanently strips hidden metadata, author history, review annotations/comments,
1392
+ * embedded scripts (`javascript:` URLs & `<script>` SVG nodes), and sensitive file attachments.
1393
+ */
1394
+ declare function sanitizePdfUnit(unit: IPdfDocumentData, options?: IPdfSanitizeOptions): IPdfDocumentData;
1395
+ interface IPdfOptimizeUnitOptions {
1396
+ deduplicateResources?: boolean;
1397
+ pruneUnusedResources?: boolean;
1398
+ pruneOrphanedPages?: boolean;
1399
+ }
1400
+ /**
1401
+ * Optimizes an `IPdfDocumentData` unit by deduplicating inline image Data URIs into shared
1402
+ * `resourceBindings`, pruning unreferenced resources, and cleaning orphaned page state.
1403
+ */
1404
+ declare function optimizePdfUnit(unit: IPdfDocumentData, options?: IPdfOptimizeUnitOptions): IPdfDocumentData;
1405
+ type IPdfBatchAction = {
1406
+ type: 'rotatePages';
1407
+ rotation: PdfPageRotation;
1408
+ pageIndices?: number[];
1409
+ } | {
1410
+ type: 'addWatermark';
1411
+ text: string;
1412
+ opacity?: number;
1413
+ color?: string;
1414
+ fontSize?: number;
1415
+ angle?: number;
1416
+ } | {
1417
+ type: 'applyBatesNumbering';
1418
+ prefix?: string;
1419
+ suffix?: string;
1420
+ startNumber?: number;
1421
+ digits?: number;
1422
+ position?: PdfBatesPosition;
1423
+ continueAcrossFiles?: boolean;
1424
+ } | {
1425
+ type: 'redactRegex';
1426
+ pattern: string;
1427
+ flags?: string;
1428
+ overlayLabel?: string;
1429
+ fillColor?: string;
1430
+ } | ({
1431
+ type: 'sanitizeMetadata';
1432
+ } & IPdfSanitizeOptions) | {
1433
+ type: 'flattenForms';
1434
+ } | ({
1435
+ type: 'optimizeSize';
1436
+ } & IPdfOptimizeUnitOptions);
1437
+ interface IPdfBatchPipelineFileInput {
1438
+ name: string;
1439
+ unit?: IPdfDocumentData;
1440
+ pdfBytes?: Uint8Array;
1441
+ }
1442
+ interface IPdfBatchPipelineItemResult {
1443
+ name: string;
1444
+ unit: IPdfDocumentData;
1445
+ pdfBytes: Uint8Array;
1446
+ appliedActions: string[];
1447
+ byteLength: number;
1448
+ }
1449
+ /**
1450
+ * Executes a sequential multi-file Action Wizard pipeline (`rotatePages`, `addWatermark`,
1451
+ * `applyBatesNumbering`, `redactRegex`, `sanitizeMetadata`, `flattenForms`, `optimizeSize`).
1452
+ */
1453
+ declare function runPdfBatchPipeline(files: IPdfBatchPipelineFileInput[], actions: IPdfBatchAction[], baseExportOptions?: IPdfExportOptions): Promise<IPdfBatchPipelineItemResult[]>;
1454
+ /**
1455
+ * Extracts embedded `/Names << /EmbeddedFiles ... >>` `/Filespec` attachments from a PDF binary.
1456
+ */
1457
+ declare function extractAttachmentsFromPdfBytes(pdfBytes: Uint8Array): Promise<IPdfAttachment[]>;
1458
+ interface IPdfUnitSignatureVerificationResult {
1459
+ signed: boolean;
1460
+ valid: boolean;
1461
+ tampered: boolean;
1462
+ signerName?: string;
1463
+ certificateSubject?: string;
1464
+ certificateIssuer?: string;
1465
+ signedAt?: string;
1466
+ expectedContentDigestHex?: string;
1467
+ actualContentDigestHex?: string;
1468
+ envelopeDigestHex?: string;
1469
+ }
1470
+ /**
1471
+ * Signs an `IPdfDocumentData` unit with a deterministic SHA-256 content hash and X.509-style signer certificate metadata.
1472
+ */
1473
+ declare function signPdfUnitWithDigest(unit: IPdfDocumentData, signerInfo: IPdfSignerInfo): IPdfDocumentData;
1474
+ /**
1475
+ * Verifies the SHA-256 digital signature envelope of an `IPdfDocumentData` unit and detects any post-signing tampering.
1476
+ */
1477
+ declare function verifyPdfUnitSignature(unit: IPdfDocumentData): IPdfUnitSignatureVerificationResult;
1478
+ interface IPdfInspectedPageSize {
1479
+ pageNumber: number;
1480
+ pageIndex: number;
1481
+ widthPt: number;
1482
+ heightPt: number;
1483
+ widthMm: number;
1484
+ heightMm: number;
1485
+ rotation: number;
1486
+ orientation: 'portrait' | 'landscape';
1487
+ preset: string | null;
1488
+ }
1489
+ /**
1490
+ * Inspects every page of a PDF binary (`Uint8Array`) and returns point/millimeter dimensions,
1491
+ * rotation, orientation, and closest standard paper preset.
1492
+ */
1493
+ declare function inspectPdfBytePageSizes(pdfBytes: Uint8Array, options?: {
1494
+ password?: string;
1495
+ }): Promise<IPdfInspectedPageSize[]>;
1496
+ interface IPdfRenderedPageImage {
1497
+ pageNumber: number;
1498
+ pageIndex: number;
1499
+ widthPx: number;
1500
+ heightPx: number;
1501
+ mimeType: 'image/png' | 'image/jpeg';
1502
+ bytes: Uint8Array;
1503
+ dataUri: string;
1504
+ }
1505
+ interface IRenderPdfBytesToImagesOptions {
1506
+ scale?: number;
1507
+ format?: 'png' | 'jpeg';
1508
+ quality?: number;
1509
+ pageRange?: string | number[];
1510
+ maxDimensionPx?: number;
1511
+ }
1512
+ /**
1513
+ * Renders selected pages of a PDF binary (`Uint8Array`) to PNG/JPEG images.
1514
+ * Uses `pdfjs-dist` + HTML5 `<canvas>` in browser environments, and falls back to a valid
1515
+ * RFC-2083 PNG proportional page preview in headless Node environments.
1516
+ */
1517
+ declare function renderPdfBytesToImages(pdfBytes: Uint8Array, options?: IRenderPdfBytesToImagesOptions): Promise<IPdfRenderedPageImage[]>;
1518
+ type PdfConvertibleImageInput = Uint8Array | string | {
1519
+ bytes?: Uint8Array;
1520
+ dataUri?: string;
1521
+ fit?: 'contain' | 'cover' | 'fill';
1522
+ objectPosition?: string;
1523
+ };
1524
+ interface IConvertImagesToPdfOptions {
1525
+ pageSize?: 'auto' | keyof typeof PDF_PAGE_PRESETS | string | {
1526
+ widthMm: number;
1527
+ heightMm: number;
1528
+ } | {
1529
+ width: number;
1530
+ height: number;
1531
+ };
1532
+ marginMm?: number;
1533
+ fit?: 'contain' | 'cover' | 'fill';
1534
+ objectPosition?: string;
1535
+ }
1536
+ /**
1537
+ * Converts one or more PNG / JPEG images (`Uint8Array` or `data:image/...` data URIs) into a multi-page PDF,
1538
+ * honoring JPEG EXIF orientation, `'auto'` or preset page dimensions, margins, `fit`, and `objectPosition`.
1539
+ */
1540
+ declare function convertImagesToPdfBytes(images: PdfConvertibleImageInput[], options?: IConvertImagesToPdfOptions): Promise<Uint8Array>;
1541
+ interface IConvertMarkdownToPdfOptions {
1542
+ name?: string;
1543
+ pageSize?: keyof typeof PDF_PAGE_PRESETS | {
1544
+ width: number;
1545
+ height: number;
1546
+ };
1547
+ marginsMm?: [number, number, number, number];
1548
+ baseFontSize?: number;
1549
+ exportOptions?: IPdfExportOptions;
1550
+ }
1551
+ /**
1552
+ * Converts a CommonMark / GitHub-Flavored Markdown document into a structured multi-page Univer `IPdfUnitData` unit
1553
+ * supporting headings (`#`..`######`), inline markdown (`**bold**`, `*italic*`, `~~strike~~`, `` `code` ``, `[link](url)`),
1554
+ * GFM pipe tables, bullet/ordered/task lists, fenced code blocks, blockquotes, horizontal rules, images, and page breaks.
1555
+ */
1556
+ declare function convertMarkdownToPdfUnit(markdown: string, options?: IConvertMarkdownToPdfOptions): IPdfUnitData;
1557
+ /**
1558
+ * Compiles a CommonMark / GitHub-Flavored Markdown string directly into standard PDF bytes.
1559
+ */
1560
+ declare function convertMarkdownToPdfBytes(markdown: string, options?: IConvertMarkdownToPdfOptions): Promise<Uint8Array>;
1561
+
1562
+ interface ITrueTypeFontInspection {
1563
+ sfntVersion: number;
1564
+ tables: string[];
1565
+ numGlyphs: number;
1566
+ unitsPerEm: number;
1567
+ ascent: number;
1568
+ descent: number;
1569
+ lineGap: number;
1570
+ indexToLocFormat: 0 | 1;
1571
+ bbox: [number, number, number, number];
1572
+ mappedCodePointCount: number;
1573
+ }
1574
+ interface ISubsetFontResult {
1575
+ subsetBytes: Uint8Array;
1576
+ originalByteLength: number;
1577
+ subsetByteLength: number;
1578
+ glyphCount: number;
1579
+ codePointToGid: Record<number, number>;
1580
+ gidAdvanceWidths: number[];
1581
+ unitsPerEm: number;
1582
+ ascent: number;
1583
+ descent: number;
1584
+ bbox: [number, number, number, number];
1585
+ }
1586
+ /**
1587
+ * Scans an `IPdfUnitData` snapshot (plus optional dynamic runtime data) and returns
1588
+ * sorted unique Unicode code points used across text boxes, lists, table headers/cells,
1589
+ * form controls, stamps, barcodes, and watermarks.
1590
+ */
1591
+ declare function collectUsedCodePointsFromPdfUnit(unitData: IPdfUnitData, data?: Record<string, unknown>): number[];
1592
+ /**
1593
+ * Inspects a TrueType (`sfnt`) font binary and returns structural metrics and glyph counts.
1594
+ */
1595
+ declare function inspectTrueTypeFont(ttfBytes: Uint8Array): ITrueTypeFontInspection;
1596
+ /**
1597
+ * Returns the set of Unicode code points mapped to non-zero glyph IDs in a TrueType (`sfnt`) font's `cmap` table.
1598
+ */
1599
+ declare function getTrueTypeMappedCodePoints(ttfBytes: Uint8Array): Set<number>;
1600
+ /**
1601
+ * Pure-TS TrueType (`TTF`) Font Subsetter:
1602
+ * Extracts `.notdef` (GID 0), all requested Unicode `codePoints`, and recursive composite glyph
1603
+ * dependencies (`numberOfContours < 0`), rebuilding compact `glyf`, `loca`, `hmtx`, `hhea`,
1604
+ * `maxp`, `head`, `cmap`, `post`, `name`, and `OS/2` tables into a valid subset TTF `Uint8Array`.
1605
+ */
1606
+ declare function subsetTrueTypeFont(ttfBytes: Uint8Array, codePoints: number[]): ISubsetFontResult;
1607
+ /**
1608
+ * Deterministically builds a valid, self-contained TrueType (`sfnt` `0x00010000`) font fixture
1609
+ * containing `.notdef`, printable ASCII (`0x20..0x7E`), CJK ideographs (200+ glyphs by default),
1610
+ * and a composite glyph (`U+2605` `'★'`) for clean-room unit testing without external binary files.
1611
+ */
1612
+ declare function buildMinimalTestTrueTypeFont(extraCodePoints?: number[]): Uint8Array;
1613
+
1614
+ type IPdfImportOutcome = {
1615
+ /** Keep/replace background base PDF for print-overlay while preserving or resizing pages */
1616
+ mode: 'overlay';
1617
+ sourceDocumentRef: IPdfSourceDocumentRef;
1618
+ pageSizes: IPdfPageSize[];
1619
+ } | {
1620
+ /** Replace the entire editable `IPdfUnitData` unit snapshot (e.g. parsed by backend PDF parser) */
1621
+ mode: 'snapshot';
1622
+ snapshot: IPdfUnitData;
1623
+ };
1624
+ interface IPdfImportContext {
1625
+ unitId: string;
1626
+ snapshot: IPdfUnitData;
1627
+ /** Built-in pure frontend importer fallback */
1628
+ defaultImport: (file: File) => Promise<IPdfImportOutcome>;
1629
+ }
1630
+ interface IPdfExportContext {
1631
+ unitId: string;
1632
+ snapshot: IPdfUnitData;
1633
+ data?: Record<string, unknown>;
1634
+ options?: IPdfExportOptions;
1635
+ /** Built-in pure frontend PDF generator (`pdf-lib` + CJK rendering + QR/Barcode) */
1636
+ defaultExport: () => Promise<Uint8Array>;
1637
+ }
1638
+ interface IPdfSaveContext {
1639
+ unitId: string;
1640
+ snapshot: IPdfUnitData;
1641
+ }
1642
+ interface ISilentPrintOptions {
1643
+ printerName?: string;
1644
+ copies?: number;
1645
+ duplex?: 'simplex' | 'long-edge' | 'short-edge';
1646
+ paperSize?: string;
1647
+ excludeBasePdf?: boolean;
1648
+ /** Horizontal needle/thermal printer feed offset compensation in millimeters */
1649
+ printerOffsetXMm?: number;
1650
+ /** Vertical needle/thermal printer feed offset compensation in millimeters */
1651
+ printerOffsetYMm?: number;
1652
+ data?: Record<string, unknown>;
1653
+ exportOptions?: IPdfExportOptions;
1654
+ }
1655
+ interface ISilentPrintResult {
1656
+ jobId: string;
1657
+ driver: string;
1658
+ byteLength: number;
1659
+ printedAt: number;
1660
+ }
1661
+ type SilentPrintDriverType = 'lodop' | 'qz-tray' | 'yudao-print-agent';
1662
+ interface IHttpSilentPrintAdapterConfig {
1663
+ endpoint: string;
1664
+ driver?: SilentPrintDriverType;
1665
+ headers?: Record<string, string>;
1666
+ fetchImpl?: typeof fetch;
1667
+ }
1668
+ /**
1669
+ * Pluggable Import / Export / Save / Silent-Print SPI for `@yudaocode/univer-pdfs`.
1670
+ * By default, all operations run purely in the browser. Host applications (e.g. Spring Boot / Node.js / Local Print Agent)
1671
+ * can override any hook to delegate heavy parsing, rendering, silent printing, or persistence.
1672
+ */
1673
+ interface IPdfIoAdapter {
1674
+ /** Optional human-readable adapter label (e.g. `'frontend-default'` or `'yudao-spring-boot'`) */
1675
+ name?: string;
1676
+ /** Custom PDF import hook (supports returning either an `overlay` base PDF or a parsed `snapshot`) */
1677
+ importPdf?: (file: File, context: IPdfImportContext) => Promise<IPdfImportOutcome>;
1678
+ /** Custom PDF export hook (can call backend PDF engine or wrap `context.defaultExport()`) */
1679
+ exportPdf?: (context: IPdfExportContext) => Promise<Uint8Array | ArrayBuffer | Blob>;
1680
+ /** Custom template persistence hook triggered when saving template snapshot to host system */
1681
+ onSave?: (context: IPdfSaveContext) => Promise<void> | void;
1682
+ /** Silent direct hardware print hook (e.g. Lodop / QZ-Tray / Yudao Local Print Agent) */
1683
+ onSilentPrint?: (pdfBytes: Uint8Array, options: ISilentPrintOptions, ctx: {
1684
+ unitId: string;
1685
+ snapshot: IPdfUnitData;
1686
+ }) => Promise<ISilentPrintResult>;
1687
+ }
1688
+ /**
1689
+ * Creates a ready-to-use HTTP Silent Print Bridge adapter connecting `@yudaocode/univer-pdfs`
1690
+ * to local print daemons (`lodop`, `qz-tray`, or `yudao-print-agent`).
1691
+ */
1692
+ declare function createHttpSilentPrintAdapter(config: IHttpSilentPrintAdapterConfig): IPdfIoAdapter;
1693
+ type PdfIoTarget = 'auto' | 'browser' | 'server';
1694
+ declare class PdfIoTargetError extends Error {
1695
+ readonly code: "SERVER_ADAPTER_NOT_CONFIGURED";
1696
+ readonly target: "server";
1697
+ readonly suggestedFallback: "browser";
1698
+ constructor(message: string);
1699
+ }
1700
+ type PdfImportErrorCode = 'INVALID_PDF_HEADER' | 'ENCRYPTED_PDF_PASSWORD_REQUIRED' | 'CORRUPT_PDF';
1701
+ declare class PdfImportError extends Error {
1702
+ readonly code: PdfImportErrorCode;
1703
+ suggestedFallback?: 'server' | 'browser';
1704
+ constructor(code: PdfImportErrorCode, message: string);
1705
+ }
1706
+ /**
1707
+ * Computes a deterministic full-payload 64-bit (dual-32-bit FNV-1a) digest + byte/character length
1708
+ * so two base64 PDFs or binary buffers of identical length never collide in document caches.
1709
+ */
1710
+ declare function computePdfPayloadDigest(input: string | Uint8Array): string;
1711
+ interface IPdfIoCapabilities {
1712
+ browser: {
1713
+ importOverlayPdf: true;
1714
+ exportPdf: true;
1715
+ exportBatchPdf: true;
1716
+ };
1717
+ server: {
1718
+ adapterName: string;
1719
+ importPdf: boolean;
1720
+ exportPdf: boolean;
1721
+ onSave: boolean;
1722
+ silentPrint: boolean;
1723
+ };
1724
+ recommendedDefaultTarget: 'server' | 'browser';
1725
+ }
1726
+ interface IBeforePdfExportHookParams {
1727
+ unitId: string;
1728
+ snapshot: IPdfUnitData;
1729
+ data?: Record<string, unknown>;
1730
+ options?: IPdfExportOptions;
1731
+ cancel?: boolean;
1732
+ }
1733
+ interface IPdfExportedHookParams {
1734
+ unitId: string;
1735
+ bytes: Uint8Array;
1736
+ byteLength: number;
1737
+ options?: IPdfExportOptions;
1738
+ }
1739
+ interface IBeforePdfPrintHookParams {
1740
+ unitId: string;
1741
+ snapshot: IPdfUnitData;
1742
+ mode: 'browser' | 'silent';
1743
+ options?: ISilentPrintOptions | IPdfExportOptions;
1744
+ cancel?: boolean;
1745
+ }
1746
+ interface IPdfIoService {
1747
+ readonly adapter$: Observable<IPdfIoAdapter>;
1748
+ getAdapter(): IPdfIoAdapter;
1749
+ setAdapter(adapter: IPdfIoAdapter): void;
1750
+ patchAdapter(patch: Partial<IPdfIoAdapter>): void;
1751
+ getIoCapabilities(): IPdfIoCapabilities;
1752
+ getAiCopilotAdapter(): IPdfAiCopilotAdapter;
1753
+ setAiCopilotAdapter(adapter: IPdfAiCopilotAdapter): void;
1754
+ generateTemplateByAi(prompt: string): Promise<IPdfUnitData>;
1755
+ recognizeReceiptByAi(fields: IPdfOcrFieldInput[]): Promise<IPdfUnitData>;
1756
+ getOcrAdapter(): IPdfOcrAdapter | null;
1757
+ setOcrAdapter(adapter: IPdfOcrAdapter): void;
1758
+ getPdfjsAssets(): IPdfjsAssetsConfig | undefined;
1759
+ setPdfjsAssets(assets?: IPdfjsAssetsConfig): void;
1760
+ importPdf(file: File, context: {
1761
+ unitId: string;
1762
+ snapshot: IPdfUnitData;
1763
+ defaultImport?: (file: File) => Promise<IPdfImportOutcome>;
1764
+ target?: PdfIoTarget;
1765
+ password?: string;
1766
+ }): Promise<IPdfImportOutcome>;
1767
+ exportPdf(params: {
1768
+ unitId: string;
1769
+ snapshot: IPdfUnitData;
1770
+ data?: Record<string, unknown>;
1771
+ options?: IPdfExportOptions;
1772
+ target?: PdfIoTarget;
1773
+ }): Promise<Uint8Array>;
1774
+ silentPrint(params: {
1775
+ unitId: string;
1776
+ snapshot: IPdfUnitData;
1777
+ options?: ISilentPrintOptions;
1778
+ target?: PdfIoTarget;
1779
+ }): Promise<ISilentPrintResult>;
1780
+ saveToHost(context: IPdfSaveContext): Promise<boolean>;
1781
+ readonly exported$: Observable<IPdfExportedHookParams>;
1782
+ registerBeforeExportHook(fn: (event: IBeforePdfExportHookParams) => void): IDisposable;
1783
+ runBeforeExportHooks(event: IBeforePdfExportHookParams): boolean;
1784
+ notifyExported(event: IPdfExportedHookParams): void;
1785
+ registerBeforePrintHook(fn: (event: IBeforePdfPrintHookParams) => void): IDisposable;
1786
+ runBeforePrintHooks(event: IBeforePdfPrintHookParams): boolean;
1787
+ }
1788
+ declare const IPdfIoService: _univerjs_core.IdentifierDecorator<IPdfIoService>;
1789
+ interface IPdfImportSourceOptions {
1790
+ fileName?: string;
1791
+ password?: string;
1792
+ }
1793
+ type IPdfImportSourceResult = IPdfImportOutcome & {
1794
+ mode: 'overlay';
1795
+ bytes: Uint8Array;
1796
+ };
1797
+ /**
1798
+ * Validates and imports a PDF source (`File`, `Blob`, `ArrayBuffer`, `Uint8Array`, or Base64 / Data URI string).
1799
+ * Strictly verifies the `%PDF-` magic header and `PDFDocument.load` structure (with optional `password`),
1800
+ * throwing a typed `PdfImportError` (`'INVALID_PDF_HEADER' | 'ENCRYPTED_PDF_PASSWORD_REQUIRED' | 'CORRUPT_PDF'`)
1801
+ * instead of silently falling back to a blank A4 document on corrupt or encrypted inputs.
1802
+ */
1803
+ declare function importPdfSource(source: File | Blob | ArrayBuffer | Uint8Array | string, options?: IPdfImportSourceOptions): Promise<IPdfImportSourceResult>;
1804
+ declare class PdfIoService extends Disposable implements IPdfIoService {
1805
+ private readonly _adapter$;
1806
+ readonly adapter$: Observable<IPdfIoAdapter>;
1807
+ private readonly _exported$;
1808
+ readonly exported$: Observable<IPdfExportedHookParams>;
1809
+ private readonly _beforeExportHooks;
1810
+ private readonly _beforePrintHooks;
1811
+ private _aiCopilotAdapter;
1812
+ private _ocrAdapter;
1813
+ private _pdfjsAssets?;
1814
+ constructor();
1815
+ registerBeforeExportHook(fn: (event: IBeforePdfExportHookParams) => void): IDisposable;
1816
+ runBeforeExportHooks(event: IBeforePdfExportHookParams): boolean;
1817
+ notifyExported(event: IPdfExportedHookParams): void;
1818
+ registerBeforePrintHook(fn: (event: IBeforePdfPrintHookParams) => void): IDisposable;
1819
+ runBeforePrintHooks(event: IBeforePdfPrintHookParams): boolean;
1820
+ getAdapter(): IPdfIoAdapter;
1821
+ setAdapter(adapter: IPdfIoAdapter): void;
1822
+ patchAdapter(patch: Partial<IPdfIoAdapter>): void;
1823
+ getAiCopilotAdapter(): IPdfAiCopilotAdapter;
1824
+ setAiCopilotAdapter(adapter: IPdfAiCopilotAdapter): void;
1825
+ generateTemplateByAi(prompt: string): Promise<IPdfUnitData>;
1826
+ recognizeReceiptByAi(fields: IPdfOcrFieldInput[]): Promise<IPdfUnitData>;
1827
+ getOcrAdapter(): IPdfOcrAdapter | null;
1828
+ setOcrAdapter(adapter: IPdfOcrAdapter): void;
1829
+ getPdfjsAssets(): IPdfjsAssetsConfig | undefined;
1830
+ setPdfjsAssets(assets?: IPdfjsAssetsConfig): void;
1831
+ getIoCapabilities(): IPdfIoCapabilities;
1832
+ importPdf(file: File, context: {
1833
+ unitId: string;
1834
+ snapshot: IPdfUnitData;
1835
+ defaultImport?: (file: File) => Promise<IPdfImportOutcome>;
1836
+ target?: PdfIoTarget;
1837
+ password?: string;
1838
+ }): Promise<IPdfImportOutcome>;
1839
+ exportPdf(params: {
1840
+ unitId: string;
1841
+ snapshot: IPdfUnitData;
1842
+ data?: Record<string, unknown>;
1843
+ options?: IPdfExportOptions;
1844
+ target?: PdfIoTarget;
1845
+ }): Promise<Uint8Array>;
1846
+ silentPrint(params: {
1847
+ unitId: string;
1848
+ snapshot: IPdfUnitData;
1849
+ options?: ISilentPrintOptions;
1850
+ target?: PdfIoTarget;
1851
+ }): Promise<ISilentPrintResult>;
1852
+ saveToHost(context: IPdfSaveContext): Promise<boolean>;
1853
+ }
1854
+
1855
+ interface IUniverPdfsConfig {
1856
+ /** Default physical unit displayed in rulers and inspector (`'mm'` or `'pt'`) */
1857
+ defaultDisplayUnit?: 'pt' | 'mm';
1858
+ /**
1859
+ * Optional pluggable Import / Export / Save / Silent-Print IO adapter.
1860
+ * Defaults to built-in pure frontend engine (`pdfjs-dist` + `pdf-lib`);
1861
+ * override `importPdf`, `exportPdf`, `onSave`, or `onSilentPrint` to connect to your backend / print agent.
1862
+ */
1863
+ io?: IPdfIoAdapter;
1864
+ /** Optional pluggable AI Copilot adapter for receipt / waybill template generation & OCR reconstruction */
1865
+ aiCopilot?: IPdfAiCopilotAdapter;
1866
+ /** Optional PDF.js worker, CMap, and standard font asset URLs */
1867
+ pdfjsAssets?: IPdfjsAssetsConfig;
1868
+ }
1869
+ declare const UNIVER_PDFS_PLUGIN_NAME = "UNIVER_PDFS_PLUGIN";
1870
+ declare class UniverPdfsPlugin extends Plugin {
1871
+ private readonly _config;
1872
+ protected readonly _injector: Injector;
1873
+ private readonly _univerInstanceService;
1874
+ private readonly _commandService;
1875
+ static pluginName: string;
1876
+ static packageName: string;
1877
+ constructor(_config: Partial<IUniverPdfsConfig> | undefined, _injector: Injector, _univerInstanceService: IUniverInstanceService, _commandService: ICommandService);
1878
+ onStarting(): void;
1879
+ }
1880
+
1881
+ interface IPdfViewportRatio {
1882
+ top: number;
1883
+ left: number;
1884
+ width: number;
1885
+ height: number;
1886
+ }
1887
+ interface IPdfSelectionState {
1888
+ unitId: string | null;
1889
+ activePageId: string | null;
1890
+ selectedElementIds: string[];
1891
+ editingElementId: string | null;
1892
+ }
1893
+ interface IPdfSelectionService {
1894
+ readonly state$: Observable<IPdfSelectionState>;
1895
+ readonly zoom$: Observable<number>;
1896
+ readonly displayUnit$: Observable<PdfDisplayUnit>;
1897
+ readonly showRuler$: Observable<boolean>;
1898
+ readonly showGrid$: Observable<boolean>;
1899
+ readonly showCalibrationGrid$: Observable<boolean>;
1900
+ readonly showMargins$: Observable<boolean>;
1901
+ readonly snapEnabled$: Observable<boolean>;
1902
+ readonly interactionMode$: Observable<PdfInteractionMode>;
1903
+ readonly inkColor$: Observable<string>;
1904
+ readonly viewportRatio$: Observable<IPdfViewportRatio>;
1905
+ readonly previewOpen$: Observable<boolean>;
1906
+ readonly clipboard$: Observable<IPdfPageElement[]>;
1907
+ readonly versionsChange$: Observable<string>;
1908
+ getState(): IPdfSelectionState;
1909
+ getActiveUnit(): PdfUnitModel | null;
1910
+ getActivePageId(): string | null;
1911
+ getSelectedElementIds(): string[];
1912
+ getSelectedElements(): IPdfPageElement[];
1913
+ setActivePage(pageId: string): void;
1914
+ selectElements(elementIds: string[], editingElementId?: string | null): void;
1915
+ toggleSelectElement(elementId: string): void;
1916
+ clearSelection(): void;
1917
+ setEditingElement(elementId: string | null): void;
1918
+ getZoom(): number;
1919
+ setZoom(zoom: number): void;
1920
+ getDisplayUnit(): PdfDisplayUnit;
1921
+ setDisplayUnit(unit: PdfDisplayUnit): void;
1922
+ getShowRuler(): boolean;
1923
+ setShowRuler(visible: boolean): void;
1924
+ getShowGrid(): boolean;
1925
+ setShowGrid(visible: boolean): void;
1926
+ getShowCalibrationGrid(): boolean;
1927
+ setShowCalibrationGrid(visible: boolean): void;
1928
+ getShowMargins(): boolean;
1929
+ setShowMargins(visible: boolean): void;
1930
+ getSnapEnabled(): boolean;
1931
+ setSnapEnabled(enabled: boolean): void;
1932
+ getInteractionMode(): PdfInteractionMode;
1933
+ setInteractionMode(mode: PdfInteractionMode): void;
1934
+ getInkColor(): string;
1935
+ setInkColor(color: string): void;
1936
+ setViewportRatio(ratio: IPdfViewportRatio): void;
1937
+ setPreviewOpen(open: boolean): void;
1938
+ setClipboard(elements: IPdfPageElement[]): void;
1939
+ getClipboard(): IPdfPageElement[];
1940
+ getPasteStep(): number;
1941
+ nextPasteStep(): number;
1942
+ registerActiveEditorCommitter(committer: (() => void) | null): IDisposable;
1943
+ commitActiveEditing(): boolean;
1944
+ saveVersionSnapshot(unitId: string, label?: string): IPdfVersionSnapshot | null;
1945
+ listVersionSnapshots(unitId: string): IPdfVersionSnapshot[];
1946
+ getVersionSnapshot(unitId: string, versionId: string): IPdfVersionSnapshot | null;
1947
+ }
1948
+ declare const IPdfSelectionService: _univerjs_core.IdentifierDecorator<IPdfSelectionService>;
1949
+ declare class PdfSelectionService extends Disposable implements IPdfSelectionService {
1950
+ private readonly _univerInstanceService;
1951
+ private readonly _versionsByUnit;
1952
+ private readonly _versionsChange$;
1953
+ readonly versionsChange$: Observable<string>;
1954
+ private readonly _activeEditorCommitters;
1955
+ private _pasteStep;
1956
+ private readonly _state$;
1957
+ readonly state$: Observable<IPdfSelectionState>;
1958
+ private readonly _zoom$;
1959
+ readonly zoom$: Observable<number>;
1960
+ private readonly _displayUnit$;
1961
+ readonly displayUnit$: Observable<PdfDisplayUnit>;
1962
+ private readonly _showRuler$;
1963
+ readonly showRuler$: Observable<boolean>;
1964
+ private readonly _showGrid$;
1965
+ readonly showGrid$: Observable<boolean>;
1966
+ private readonly _showCalibrationGrid$;
1967
+ readonly showCalibrationGrid$: Observable<boolean>;
1968
+ private readonly _showMargins$;
1969
+ readonly showMargins$: Observable<boolean>;
1970
+ private readonly _snapEnabled$;
1971
+ readonly snapEnabled$: Observable<boolean>;
1972
+ private readonly _interactionMode$;
1973
+ readonly interactionMode$: Observable<PdfInteractionMode>;
1974
+ private readonly _inkColor$;
1975
+ readonly inkColor$: Observable<string>;
1976
+ private readonly _viewportRatio$;
1977
+ readonly viewportRatio$: Observable<IPdfViewportRatio>;
1978
+ private readonly _previewOpen$;
1979
+ readonly previewOpen$: Observable<boolean>;
1980
+ private readonly _clipboard$;
1981
+ readonly clipboard$: Observable<IPdfPageElement[]>;
1982
+ constructor(_univerInstanceService: IUniverInstanceService);
1983
+ dispose(): void;
1984
+ getState(): IPdfSelectionState;
1985
+ getActiveUnit(): PdfUnitModel | null;
1986
+ getActivePageId(): string | null;
1987
+ getSelectedElementIds(): string[];
1988
+ getSelectedElements(): IPdfPageElement[];
1989
+ setActivePage(pageId: string): void;
1990
+ selectElements(elementIds: string[], editingElementId?: string | null): void;
1991
+ toggleSelectElement(elementId: string): void;
1992
+ clearSelection(): void;
1993
+ setEditingElement(elementId: string | null): void;
1994
+ getZoom(): number;
1995
+ setZoom(zoom: number): void;
1996
+ getDisplayUnit(): PdfDisplayUnit;
1997
+ setDisplayUnit(unit: PdfDisplayUnit): void;
1998
+ getShowRuler(): boolean;
1999
+ setShowRuler(visible: boolean): void;
2000
+ getShowGrid(): boolean;
2001
+ setShowGrid(visible: boolean): void;
2002
+ getShowCalibrationGrid(): boolean;
2003
+ setShowCalibrationGrid(visible: boolean): void;
2004
+ getShowMargins(): boolean;
2005
+ setShowMargins(visible: boolean): void;
2006
+ getSnapEnabled(): boolean;
2007
+ setSnapEnabled(enabled: boolean): void;
2008
+ getInteractionMode(): PdfInteractionMode;
2009
+ setInteractionMode(mode: PdfInteractionMode): void;
2010
+ getInkColor(): string;
2011
+ setInkColor(color: string): void;
2012
+ setViewportRatio(ratio: IPdfViewportRatio): void;
2013
+ setPreviewOpen(open: boolean): void;
2014
+ setClipboard(elements: IPdfPageElement[]): void;
2015
+ getClipboard(): IPdfPageElement[];
2016
+ getPasteStep(): number;
2017
+ nextPasteStep(): number;
2018
+ registerActiveEditorCommitter(committer: (() => void) | null): IDisposable;
2019
+ commitActiveEditing(): boolean;
2020
+ saveVersionSnapshot(unitId: string, label?: string): IPdfVersionSnapshot | null;
2021
+ listVersionSnapshots(unitId: string): IPdfVersionSnapshot[];
2022
+ getVersionSnapshot(unitId: string, versionId: string): IPdfVersionSnapshot | null;
2023
+ }
2024
+
2025
+ export { ASPECT_RATIO_LOCKED_BARCODE_TYPES, AddPdfElementCommand, AddPdfElementMutation, AddPdfLayerCommand, AddPdfPageCommand, AddPdfPageMutation, AlignSelectedPdfElementsCommand, type AspectRatioLockedBarcodeType, AssignPdfElementLayerCommand, BARCODE_TYPES, CIRCLE_MARK_BEZIER_KAPPA, DeleteSelectedPdfElementsCommand, DistributeSelectedPdfElementsCommand, DuplicateSelectedPdfElementsCommand, FindAndReplacePdfTextCommand, type IAddPdfElementCommandParams, type IAddPdfLayerCommandParams, type IAssignPdfElementLayerCommandParams, type IBarcodeBarRun, type IBarcodeLayoutBox, type IBeforePdfExportHookParams, type IBeforePdfPrintHookParams, type ICircleMarkBezierEllipse, type IComputeSmartSnapParams, type IConvertImagesToPdfOptions, type IConvertMarkdownToPdfOptions, type IDataMatrixEncodedResult, type IDeleteSelectedPdfElementsCommandParams, type IDistributeSelectedPdfElementsCommandParams, type IDynamicLayoutItemInput, type IDynamicLayoutPlacement, type IDynamicLayoutSplitOptions, type IDynamicLayoutSplitRange, type IFindAndReplacePdfTextCommandParams, type IGs1128EncodedResult, type IGs1DataMatrixEncodedResult, type IHttpSilentPrintAdapterConfig, type IImageFitPlacement, type IImportPdfSourceCommandParams, type IJapanPostBar, type IJapanPostEncodedResult, type ILinear1dEncodedResult, type INw7EncodedResult, type IParsedPdfColor, type IParsedStreamTextOp, type IPdf417EncodedResult, type IPdfAiCopilotAdapter, IPdfAttachment, type IPdfAuditSealOptions, type IPdfAuditVerificationResult, type IPdfBatchAction, type IPdfBatchPipelineFileInput, type IPdfBatchPipelineItemResult, IPdfBatesConfig, IPdfBookmarkItem, IPdfCircleMarkElement, type IPdfComparisonResult, IPdfCropBox, IPdfDocument, IPdfDocumentData, type IPdfDocxDocumentSnapshot, type IPdfElementDiffItem, type IPdfExportContext, IPdfExportOptions, type IPdfExportedHookParams, type IPdfFormFieldIssue, type IPdfFormValidationResult, IPdfHeaderFooterConfig, type IPdfImportContext, type IPdfImportOutcome, type IPdfImportSourceOptions, type IPdfImportSourceResult, type IPdfInspectedPageSize, type IPdfIoAdapter, type IPdfIoCapabilities, IPdfIoService, IPdfLayer, IPdfListElement, type IPdfListPageChunk, IPdfNativeTextSpan, type IPdfOcrAdapter, type IPdfOcrFieldInput, type IPdfOcrPageInfo, type IPdfOcrRecognizedBlock, type IPdfOptimizeUnitOptions, type IPdfOrganizeAction, IPdfPage, IPdfPageElement, IPdfPageSize, type IPdfRenderedPageImage, IPdfResourceBinding, IPdfRichTextSpan, type IPdfSanitizeOptions, type IPdfSaveContext, IPdfSecurityPermissions, IPdfSelectionService, type IPdfSelectionState, type IPdfSheetConvertedStructure, type IPdfSheetConvertedTable, IPdfSignatureEnvelope, type IPdfSignedAuditResult, IPdfSignerInfo, IPdfSourceDocumentRef, type IPdfTextDiffItem, IPdfTextElement, IPdfTextStyle, IPdfUnitData, IPdfUnitMetadata, type IPdfUnitPropsPatch, type IPdfUnitSignatureVerificationResult, IPdfVersionSnapshot, type IPdfViewportRatio, IPdfWatermarkConfig, type IPdfWordBlock, type IPdfWordConvertedPage, type IPdfWordConvertedStructure, type IPdfWorkbookCell, type IPdfWorkbookSnapshot, IPdfjsAssetsConfig, type IRemovePdfLayerCommandParams, type IRenderPdfBytesToImagesOptions, type IReplacePdfNativeTextCommandParams, type IRotatePdfPageCommandParams, type ISetPdfAttachmentsCommandParams, type ISetPdfBatesConfigCommandParams, type ISetPdfBookmarksCommandParams, type ISetPdfHeaderFooterConfigCommandParams, type ISetPdfNativeTextSpansCommandParams, type ISetPdfPageCropBoxCommandParams, type ISetPdfWatermarkConfigCommandParams, type ISilentPrintOptions, type ISilentPrintResult, type ISmartSnapBox, type ISnapGuideLine, type ISubsetFontResult, type ITemplateVariableMatch, type ITrueTypeFontInspection, type IUnifiedBarcodeEncoded, type IUniverPdfsConfig, type IUpdatePdfElementsCommandParams, type IUpdatePdfLayerCommandParams, type IUpdatePdfPageMutationParams, type IUpdatePdfPagePropsCommandParams, type IUpdatePdfUnitPropsCommandParams, type IUpdatePdfUnitPropsMutationParams, ImportPdfSourceCommand, type JapanPostBarState, PDF_DIFF_COLORS, PDF_PAGE_PRESETS, type PdfAlignMode, PdfBatesPosition, type PdfCanonicalBarcodeType, PdfColorSpaceType, type PdfConvertibleImageInput, PdfDateTimeKind, PdfDisplayUnit, type PdfDistributeDirection, PdfElementType, type PdfExifMatrixTuple, type PdfExifOrientation, PdfImportError, type PdfImportErrorCode, PdfInteractionMode, PdfIoService, type PdfIoTarget, PdfIoTargetError, type PdfLayerOrderMode, PdfPageRotation, PdfSelectionService, PdfUnitModel, RemovePdfElementsMutation, RemovePdfLayerCommand, RemovePdfPageCommand, RemovePdfPageMutation, ReorderPdfElementOrderMutation, ReorderPdfLayerCommand, ReorderPdfPagesCommand, ReorderPdfPagesMutation, ReplacePdfNativeTextCommand, ReplacePdfSnapshotCommand, RestorePdfVersionCommand, RotatePdfPageCommand, SavePdfVersionCommand, SetPdfAttachmentsCommand, SetPdfBatesConfigCommand, SetPdfBookmarksCommand, SetPdfHeaderFooterConfigCommand, SetPdfNativeTextSpansCommand, SetPdfPageCropBoxCommand, SetPdfPageSizeCommand, SetPdfWatermarkConfigCommand, type SignatureQuadraticSegment, type SilentPrintDriverType, type SvgMat2D, UNIVER_PDFS_PLUGIN_NAME, UniverPdfsPlugin, UpdatePdfElementsCommand, UpdatePdfElementsMutation, UpdatePdfLayerCommand, UpdatePdfPageMutation, UpdatePdfPagePropsCommand, UpdatePdfUnitPropsCommand, UpdatePdfUnitPropsMutation, applyOcrToUnitPage, autoDetectFormFieldsOnPage, buildMinimalTestTrueTypeFont, buildPdfTemplateFromOcrFields, canonicalJsonStringify, cmykToRgb, collectUsedCodePointsFromPdfUnit, comparePdfBytes, comparePdfUnits, computeBarcodeLayoutBox, computeCircleMarkBezierEllipse, computeDynamicLayoutSplitRanges, computeElementCenterTransformMatrix, computeExifTransformMatrix, computeExpandedTextHeightMm, computeExpandedTextHeightPt, computeImageFitPlacement, computePasteCascadeOffset, computePdfPayloadDigest, computeSmartSnapWithEqualGap, convertImagesToPdfBytes, convertMarkdownToPdfBytes, convertMarkdownToPdfUnit, convertPdfBytesToCsv, convertPdfBytesToDocxBytes, convertPdfToSheetStructure, convertPdfToWordStructure, convertPdfUnitToCsv, createDefaultElement, createDefaultPdfUnitData, createHttpSilentPrintAdapter, detectFormFieldsFromPageSpans, drawVectorSvgOnPdfPage, encodeBarcodeByFormat, encodeCodabar, encodeCode128, encodeCode39, encodeDataMatrix, encodeEan13, encodeEan8, encodeGs1128, encodeGs1DataMatrix, encodeItf14, encodeJapanPost, encodeNw7, encodePdf417, encodeQrCodeMatrix, encodeUpcA, encodeUpcE, evaluatePdfFormExpression, evaluateSafeTemplateExpression, exportFormDataToFdf, exportFormDataToXfdf, exportPdfToDocxSnapshot, exportPdfToWorkbookSnapshot, exportSignedPdfWithAuditSeal, extractAttachmentsFromPdfBytes, extractNativeTextSpansFromPdfBytes, formatGs1HumanReadable, formatPdfDateTimeValue, generatePdfTemplateByPrompt, getDefaultDateTimeFormat, getRegisteredOcrAdapter, getTrueTypeMappedCodePoints, importAcroFormPdfToUnit, importFormDataFromFdf, importFormDataFromXfdf, importPdfSource, insertPdfPagesBytes, inspectPdfBytePageSizes, inspectTrueTypeFont, isAspectRatioLockedBarcodeType, isCircleMarkChecked, isExifDimensionsSwapped, mayBeJson, mergePdfBytes, movePdfPageBytes, normalizeBarcodeFormatType, optimizePdfUnit, organizePdfBytes, paginatePdfListItems, parseGs1ApplicationIdentifiers, parseInlineMarkdownToSpans, parseObjectPositionRatios, parsePdfColorWithAlpha, parsePdfContentStreamTextOps, parsePdfPageRange, parseSafeKeyValueRecord, parseSvgToVectorCommands, parseSvgTransformAttr, readJpegExifOrientation, recalculatePdfFormFields, rectsIntersect, registerOcrAdapter, removePdfPagesBytes, renderBarcodeSvgByFormat, renderBarcodeSvgDataUrlByFormat, renderDataMatrixSvg, renderDataMatrixSvgDataUrl, renderGs1128Svg, renderGs1128SvgDataUrl, renderGs1DataMatrixSvg, renderGs1DataMatrixSvgDataUrl, renderPdf417Svg, renderPdf417SvgDataUrl, renderPdfBytesToImages, resolveMultiVariableText, rgbToCmyk, rotatePdfPagesBytes, runPdfBatchPipeline, safeLookupVariablePath, sanitizePdfUnit, scanTemplateExpressionTokens, sha256BytesSync, sha256Hex, sha256HexSync, signPdfUnitWithDigest, exportSignedPdfWithAuditSeal as signPdfWithAuditDigest, smoothSignatureStrokeQuadratic, splitPdfBytes, stripPdfPageNativeTextInRects, subsetTrueTypeFont, svgToDataUri, toHtmlDateTimeInputValue, toPdfLibColor, toggleCircleMarkState, validatePdfFormFields, verifyPdfAuditSeal as verifyPdfAuditDigest, verifyPdfAuditSeal, verifyPdfUnitSignature, visitTemplateVariables, wrapPdfTextLines };