@embedpdf/models 2.6.2 → 2.7.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/pdf.d.ts CHANGED
@@ -382,6 +382,36 @@ export type ImageDataLike = {
382
382
  height: number;
383
383
  colorSpace?: PredefinedColorSpace;
384
384
  };
385
+ /**
386
+ * Bitmask constants for annotation appearance stream modes.
387
+ * @public
388
+ */
389
+ export declare const AP_MODE_NORMAL = 1;
390
+ export declare const AP_MODE_ROLLOVER = 2;
391
+ export declare const AP_MODE_DOWN = 4;
392
+ /**
393
+ * A rendered appearance stream image for a single mode of an annotation.
394
+ * @public
395
+ */
396
+ export interface AnnotationAppearanceImage<TImage = ImageDataLike> {
397
+ data: TImage;
398
+ rect: Rect;
399
+ }
400
+ /**
401
+ * All available appearance stream images for one annotation,
402
+ * keyed by mode (normal, rollover, down).
403
+ * @public
404
+ */
405
+ export interface AnnotationAppearances<TImage = ImageDataLike> {
406
+ normal?: AnnotationAppearanceImage<TImage>;
407
+ rollover?: AnnotationAppearanceImage<TImage>;
408
+ down?: AnnotationAppearanceImage<TImage>;
409
+ }
410
+ /**
411
+ * Map of annotation ID to its rendered appearance stream images.
412
+ * @public
413
+ */
414
+ export type AnnotationAppearanceMap<TImage = ImageDataLike> = Record<string, AnnotationAppearances<TImage>>;
385
415
  /**
386
416
  * Representation of pdf action
387
417
  *
@@ -928,6 +958,12 @@ export interface PdfAnnotationObjectBase {
928
958
  * Custom data of the annotation
929
959
  */
930
960
  custom?: any;
961
+ /**
962
+ * Bitmask of available appearance stream modes.
963
+ * bit 0 (1) = Normal, bit 1 (2) = Rollover, bit 2 (4) = Down.
964
+ * 0 or undefined = no appearance stream.
965
+ */
966
+ appearanceModes?: number;
931
967
  /**
932
968
  * In reply to annotation id (IRT - for grouping or reply threads)
933
969
  */
@@ -2770,6 +2806,24 @@ export interface PdfEngine<T = Blob> {
2770
2806
  * @param options - render options
2771
2807
  */
2772
2808
  renderPageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject, options?: PdfRenderPageAnnotationOptions): PdfTask<T>;
2809
+ /**
2810
+ * Batch-render all annotation appearance streams for a page and encode
2811
+ * each rendered image to the output type of this engine.
2812
+ * Returns a map of annotation ID to rendered appearances (Normal/Rollover/Down).
2813
+ * @param doc - pdf document
2814
+ * @param page - pdf page
2815
+ * @param options - render options
2816
+ */
2817
+ renderPageAnnotations(doc: PdfDocumentObject, page: PdfPageObject, options?: PdfRenderPageAnnotationOptions): PdfTask<AnnotationAppearanceMap<T>>;
2818
+ /**
2819
+ * Batch-render all annotation appearance streams for a page.
2820
+ * Returns a map of annotation ID to rendered appearances (Normal/Rollover/Down).
2821
+ * Skips EmbedPDF-rotated annotations and annotations without appearance streams.
2822
+ * @param doc - pdf document
2823
+ * @param page - pdf page
2824
+ * @param options - render options (scaleFactor, dpr, rotation)
2825
+ */
2826
+ renderPageAnnotationsRaw(doc: PdfDocumentObject, page: PdfPageObject, options?: PdfRenderPageAnnotationOptions): PdfTask<AnnotationAppearanceMap<ImageDataLike>>;
2773
2827
  /**
2774
2828
  * Get annotations of pdf page
2775
2829
  * @param doc - pdf document
@@ -2793,7 +2847,9 @@ export interface PdfEngine<T = Blob> {
2793
2847
  * @param annotation - new annotations
2794
2848
  * @returns task that indicates whether the operation succeeded
2795
2849
  */
2796
- updatePageAnnotation: (doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject) => PdfTask<boolean>;
2850
+ updatePageAnnotation: (doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject, options?: {
2851
+ regenerateAppearance?: boolean;
2852
+ }) => PdfTask<boolean>;
2797
2853
  /**
2798
2854
  * Remove a annotation on specified page
2799
2855
  * @param doc - pdf document
@@ -3063,10 +3119,13 @@ export interface IPdfiumExecutor {
3063
3119
  renderPageRect(doc: PdfDocumentObject, page: PdfPageObject, rect: Rect, options?: PdfRenderPageOptions): PdfTask<ImageDataLike>;
3064
3120
  renderThumbnailRaw(doc: PdfDocumentObject, page: PdfPageObject, options?: PdfRenderThumbnailOptions): PdfTask<ImageDataLike>;
3065
3121
  renderPageAnnotationRaw(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject, options?: PdfRenderPageAnnotationOptions): PdfTask<ImageDataLike>;
3122
+ renderPageAnnotationsRaw(doc: PdfDocumentObject, page: PdfPageObject, options?: PdfRenderPageAnnotationOptions): PdfTask<AnnotationAppearanceMap<ImageDataLike>>;
3066
3123
  getPageAnnotationsRaw(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfAnnotationObject[]>;
3067
3124
  getPageAnnotations(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfAnnotationObject[]>;
3068
3125
  createPageAnnotation<A extends PdfAnnotationObject>(doc: PdfDocumentObject, page: PdfPageObject, annotation: A, context?: AnnotationCreateContext<A>): PdfTask<string>;
3069
- updatePageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): PdfTask<boolean>;
3126
+ updatePageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject, options?: {
3127
+ regenerateAppearance?: boolean;
3128
+ }): PdfTask<boolean>;
3070
3129
  removePageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): PdfTask<boolean>;
3071
3130
  getPageTextRects(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfTextRectObject[]>;
3072
3131
  searchInPage(doc: PdfDocumentObject, page: PdfPageObject, keyword: string, flags: number): PdfTask<SearchResult[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/models",
3
- "version": "2.6.2",
3
+ "version": "2.7.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",