@embedpdf/models 2.0.0-next.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/logger.d.ts CHANGED
@@ -147,6 +147,7 @@ export declare class LevelLogger implements Logger {
147
147
  * @public
148
148
  */
149
149
  export declare class PerfLogger implements Logger {
150
+ private marks;
150
151
  /**
151
152
  * create new PerfLogger
152
153
  */
package/dist/pdf.d.ts CHANGED
@@ -352,6 +352,18 @@ export type PdfImage = {
352
352
  width: number;
353
353
  height: number;
354
354
  };
355
+ /**
356
+ * Image data type that matches both browser's ImageData and plain objects.
357
+ * Used for raw rendering output that may include colorSpace from browser APIs.
358
+ *
359
+ * @public
360
+ */
361
+ export type ImageDataLike = {
362
+ data: Uint8ClampedArray<ArrayBuffer>;
363
+ width: number;
364
+ height: number;
365
+ colorSpace?: PredefinedColorSpace;
366
+ };
355
367
  /**
356
368
  * Representation of pdf action
357
369
  *
@@ -1429,9 +1441,9 @@ export interface PdfPathObject {
1429
1441
  export interface PdfImageObject {
1430
1442
  type: PdfPageObjectType.IMAGE;
1431
1443
  /**
1432
- * data of the image
1444
+ * data of the image (cross-platform compatible, works in Node.js and browsers)
1433
1445
  */
1434
- imageData: ImageData;
1446
+ imageData: ImageDataLike;
1435
1447
  /**
1436
1448
  * transform matrix
1437
1449
  */
@@ -2051,7 +2063,7 @@ export interface PdfFileLoader extends PdfFileWithoutContent {
2051
2063
  }
2052
2064
  export interface PdfAnnotationsProgress {
2053
2065
  page: number;
2054
- annotations: PdfAnnotationObject[];
2066
+ result: PdfAnnotationObject[];
2055
2067
  }
2056
2068
  /**
2057
2069
  * Progress of search all pages
@@ -2299,11 +2311,6 @@ export interface PdfEngine<T = Blob> {
2299
2311
  * @returns support or not
2300
2312
  */
2301
2313
  isSupport?: (feature: PdfEngineFeature) => PdfTask<PdfEngineOperation[]>;
2302
- /**
2303
- * Initialize the engine
2304
- * @returns task that indicate whether initialization is successful
2305
- */
2306
- initialize?: () => PdfTask<boolean>;
2307
2314
  /**
2308
2315
  * Destroy the engine
2309
2316
  * @returns task that indicate whether destroy is successful
@@ -2598,6 +2605,74 @@ export interface PdfEngine<T = Blob> {
2598
2605
  * @public
2599
2606
  */
2600
2607
  export type PdfEngineMethodName = keyof Required<PdfEngine>;
2608
+ /**
2609
+ * Progress info for batch operations
2610
+ * Emitted per-page as the batch is processed
2611
+ *
2612
+ * @public
2613
+ */
2614
+ export interface BatchProgress<T> {
2615
+ /** Index of the page that was just processed */
2616
+ pageIndex: number;
2617
+ /** Result for this page */
2618
+ result: T;
2619
+ /** Number of pages completed so far */
2620
+ completed: number;
2621
+ /** Total number of pages in this batch */
2622
+ total: number;
2623
+ }
2624
+ /**
2625
+ * Executor interface for PDFium implementations.
2626
+ * Can be either PdfiumNative (direct) or RemoteExecutor (worker proxy).
2627
+ *
2628
+ * @public
2629
+ */
2630
+ export interface IPdfiumExecutor {
2631
+ destroy(): void;
2632
+ openDocumentBuffer(file: PdfFile, options?: PdfOpenDocumentBufferOptions): PdfTask<PdfDocumentObject>;
2633
+ getMetadata(doc: PdfDocumentObject): PdfTask<PdfMetadataObject>;
2634
+ setMetadata(doc: PdfDocumentObject, metadata: Partial<PdfMetadataObject>): PdfTask<boolean>;
2635
+ getDocPermissions(doc: PdfDocumentObject): PdfTask<number>;
2636
+ getDocUserPermissions(doc: PdfDocumentObject): PdfTask<number>;
2637
+ getSignatures(doc: PdfDocumentObject): PdfTask<PdfSignatureObject[]>;
2638
+ getBookmarks(doc: PdfDocumentObject): PdfTask<PdfBookmarksObject>;
2639
+ setBookmarks(doc: PdfDocumentObject, bookmarks: PdfBookmarkObject[]): PdfTask<boolean>;
2640
+ deleteBookmarks(doc: PdfDocumentObject): PdfTask<boolean>;
2641
+ renderPageRaw(doc: PdfDocumentObject, page: PdfPageObject, options?: PdfRenderPageOptions): PdfTask<ImageDataLike>;
2642
+ renderPageRect(doc: PdfDocumentObject, page: PdfPageObject, rect: Rect, options?: PdfRenderPageOptions): PdfTask<ImageDataLike>;
2643
+ renderThumbnailRaw(doc: PdfDocumentObject, page: PdfPageObject, options?: PdfRenderThumbnailOptions): PdfTask<ImageDataLike>;
2644
+ renderPageAnnotationRaw(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject, options?: PdfRenderPageAnnotationOptions): PdfTask<ImageDataLike>;
2645
+ getPageAnnotationsRaw(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfAnnotationObject[]>;
2646
+ getPageAnnotations(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfAnnotationObject[]>;
2647
+ createPageAnnotation<A extends PdfAnnotationObject>(doc: PdfDocumentObject, page: PdfPageObject, annotation: A, context?: AnnotationCreateContext<A>): PdfTask<string>;
2648
+ updatePageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): PdfTask<boolean>;
2649
+ removePageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): PdfTask<boolean>;
2650
+ getPageTextRects(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfTextRectObject[]>;
2651
+ searchInPage(doc: PdfDocumentObject, page: PdfPageObject, keyword: string, flags: number): PdfTask<SearchResult[]>;
2652
+ getAnnotationsBatch(doc: PdfDocumentObject, pages: PdfPageObject[]): PdfTask<Record<number, PdfAnnotationObject[]>, BatchProgress<PdfAnnotationObject[]>>;
2653
+ searchBatch(doc: PdfDocumentObject, pages: PdfPageObject[], keyword: string, flags: number): PdfTask<Record<number, SearchResult[]>, BatchProgress<SearchResult[]>>;
2654
+ getAttachments(doc: PdfDocumentObject): PdfTask<PdfAttachmentObject[]>;
2655
+ addAttachment(doc: PdfDocumentObject, params: PdfAddAttachmentParams): PdfTask<boolean>;
2656
+ removeAttachment(doc: PdfDocumentObject, attachment: PdfAttachmentObject): PdfTask<boolean>;
2657
+ readAttachmentContent(doc: PdfDocumentObject, attachment: PdfAttachmentObject): PdfTask<ArrayBuffer>;
2658
+ setFormFieldValue(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfWidgetAnnoObject, value: FormFieldValue): PdfTask<boolean>;
2659
+ flattenPage(doc: PdfDocumentObject, page: PdfPageObject, options?: PdfFlattenPageOptions): PdfTask<PdfPageFlattenResult>;
2660
+ extractPages(doc: PdfDocumentObject, pageIndexes: number[]): PdfTask<ArrayBuffer>;
2661
+ extractText(doc: PdfDocumentObject, pageIndexes: number[]): PdfTask<string>;
2662
+ redactTextInRects(doc: PdfDocumentObject, page: PdfPageObject, rects: Rect[], options?: PdfRedactTextOptions): PdfTask<boolean>;
2663
+ getTextSlices(doc: PdfDocumentObject, slices: PageTextSlice[]): PdfTask<string[]>;
2664
+ getPageGlyphs(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfGlyphObject[]>;
2665
+ getPageGeometry(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfPageGeometry>;
2666
+ merge(files: PdfFile[]): PdfTask<PdfFile>;
2667
+ mergePages(mergeConfigs: Array<{
2668
+ docId: string;
2669
+ pageIndices: number[];
2670
+ }>): PdfTask<PdfFile>;
2671
+ preparePrintDocument(doc: PdfDocumentObject, options?: PdfPrintOptions): PdfTask<ArrayBuffer>;
2672
+ saveAsCopy(doc: PdfDocumentObject): PdfTask<ArrayBuffer>;
2673
+ closeDocument(doc: PdfDocumentObject): PdfTask<boolean>;
2674
+ closeAllDocuments(): PdfTask<boolean>;
2675
+ }
2601
2676
  /**
2602
2677
  * Arguments of PdfEngine method
2603
2678
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/models",
3
- "version": "2.0.0-next.2",
3
+ "version": "2.0.0",
4
4
  "private": false,
5
5
  "description": "Shared type definitions, data models, and utility helpers (geometry, tasks, logging, PDF primitives) that underpin every package in the EmbedPDF ecosystem.",
6
6
  "type": "module",