@embedpdf/models 2.6.1 → 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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/pdf.d.ts +103 -8
- package/package.json +1 -1
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
|
*/
|
|
@@ -2090,19 +2126,34 @@ export interface SearchAllPagesResult {
|
|
|
2090
2126
|
*/
|
|
2091
2127
|
export interface PdfGlyphObject {
|
|
2092
2128
|
/**
|
|
2093
|
-
* Origin of the glyph
|
|
2129
|
+
* Origin of the glyph (loose bounds from FPDFText_GetLooseCharBox)
|
|
2094
2130
|
*/
|
|
2095
2131
|
origin: {
|
|
2096
2132
|
x: number;
|
|
2097
2133
|
y: number;
|
|
2098
2134
|
};
|
|
2099
2135
|
/**
|
|
2100
|
-
* Size of the glyph
|
|
2136
|
+
* Size of the glyph (loose bounds from FPDFText_GetLooseCharBox)
|
|
2101
2137
|
*/
|
|
2102
2138
|
size: {
|
|
2103
2139
|
width: number;
|
|
2104
2140
|
height: number;
|
|
2105
2141
|
};
|
|
2142
|
+
/**
|
|
2143
|
+
* Tight bounds origin (from FPDFText_GetCharBox, closely surrounds the actual glyph shape).
|
|
2144
|
+
* Used for hit-testing to match Chrome's FPDFText_GetCharIndexAtPos behaviour.
|
|
2145
|
+
*/
|
|
2146
|
+
tightOrigin?: {
|
|
2147
|
+
x: number;
|
|
2148
|
+
y: number;
|
|
2149
|
+
};
|
|
2150
|
+
/**
|
|
2151
|
+
* Tight bounds size (from FPDFText_GetCharBox)
|
|
2152
|
+
*/
|
|
2153
|
+
tightSize?: {
|
|
2154
|
+
width: number;
|
|
2155
|
+
height: number;
|
|
2156
|
+
};
|
|
2106
2157
|
/**
|
|
2107
2158
|
* Whether the glyph is a space
|
|
2108
2159
|
*/
|
|
@@ -2119,25 +2170,42 @@ export interface PdfGlyphObject {
|
|
|
2119
2170
|
*/
|
|
2120
2171
|
export interface PdfGlyphSlim {
|
|
2121
2172
|
/**
|
|
2122
|
-
* X coordinate of the glyph
|
|
2173
|
+
* X coordinate of the glyph (loose bounds from FPDFText_GetLooseCharBox)
|
|
2123
2174
|
*/
|
|
2124
2175
|
x: number;
|
|
2125
2176
|
/**
|
|
2126
|
-
* Y coordinate of the glyph
|
|
2177
|
+
* Y coordinate of the glyph (loose bounds from FPDFText_GetLooseCharBox)
|
|
2127
2178
|
*/
|
|
2128
2179
|
y: number;
|
|
2129
2180
|
/**
|
|
2130
|
-
* Width of the glyph
|
|
2181
|
+
* Width of the glyph (loose bounds from FPDFText_GetLooseCharBox)
|
|
2131
2182
|
*/
|
|
2132
2183
|
width: number;
|
|
2133
2184
|
/**
|
|
2134
|
-
* Height of the glyph
|
|
2185
|
+
* Height of the glyph (loose bounds from FPDFText_GetLooseCharBox)
|
|
2135
2186
|
*/
|
|
2136
2187
|
height: number;
|
|
2137
2188
|
/**
|
|
2138
2189
|
* Flags of the glyph
|
|
2139
2190
|
*/
|
|
2140
2191
|
flags: number;
|
|
2192
|
+
/**
|
|
2193
|
+
* Tight X coordinate (from FPDFText_GetCharBox).
|
|
2194
|
+
* Used for hit-testing to match Chrome's FPDFText_GetCharIndexAtPos behaviour.
|
|
2195
|
+
*/
|
|
2196
|
+
tightX?: number;
|
|
2197
|
+
/**
|
|
2198
|
+
* Tight Y coordinate (from FPDFText_GetCharBox)
|
|
2199
|
+
*/
|
|
2200
|
+
tightY?: number;
|
|
2201
|
+
/**
|
|
2202
|
+
* Tight width (from FPDFText_GetCharBox)
|
|
2203
|
+
*/
|
|
2204
|
+
tightWidth?: number;
|
|
2205
|
+
/**
|
|
2206
|
+
* Tight height (from FPDFText_GetCharBox)
|
|
2207
|
+
*/
|
|
2208
|
+
tightHeight?: number;
|
|
2141
2209
|
}
|
|
2142
2210
|
/**
|
|
2143
2211
|
* Run object
|
|
@@ -2162,6 +2230,10 @@ export interface PdfRun {
|
|
|
2162
2230
|
* Glyphs of the run
|
|
2163
2231
|
*/
|
|
2164
2232
|
glyphs: PdfGlyphSlim[];
|
|
2233
|
+
/**
|
|
2234
|
+
* Font size of the run (all glyphs in a run share the same font size)
|
|
2235
|
+
*/
|
|
2236
|
+
fontSize?: number;
|
|
2165
2237
|
}
|
|
2166
2238
|
/**
|
|
2167
2239
|
* Page geometry
|
|
@@ -2734,6 +2806,24 @@ export interface PdfEngine<T = Blob> {
|
|
|
2734
2806
|
* @param options - render options
|
|
2735
2807
|
*/
|
|
2736
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>>;
|
|
2737
2827
|
/**
|
|
2738
2828
|
* Get annotations of pdf page
|
|
2739
2829
|
* @param doc - pdf document
|
|
@@ -2757,7 +2847,9 @@ export interface PdfEngine<T = Blob> {
|
|
|
2757
2847
|
* @param annotation - new annotations
|
|
2758
2848
|
* @returns task that indicates whether the operation succeeded
|
|
2759
2849
|
*/
|
|
2760
|
-
updatePageAnnotation: (doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject
|
|
2850
|
+
updatePageAnnotation: (doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject, options?: {
|
|
2851
|
+
regenerateAppearance?: boolean;
|
|
2852
|
+
}) => PdfTask<boolean>;
|
|
2761
2853
|
/**
|
|
2762
2854
|
* Remove a annotation on specified page
|
|
2763
2855
|
* @param doc - pdf document
|
|
@@ -3027,10 +3119,13 @@ export interface IPdfiumExecutor {
|
|
|
3027
3119
|
renderPageRect(doc: PdfDocumentObject, page: PdfPageObject, rect: Rect, options?: PdfRenderPageOptions): PdfTask<ImageDataLike>;
|
|
3028
3120
|
renderThumbnailRaw(doc: PdfDocumentObject, page: PdfPageObject, options?: PdfRenderThumbnailOptions): PdfTask<ImageDataLike>;
|
|
3029
3121
|
renderPageAnnotationRaw(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject, options?: PdfRenderPageAnnotationOptions): PdfTask<ImageDataLike>;
|
|
3122
|
+
renderPageAnnotationsRaw(doc: PdfDocumentObject, page: PdfPageObject, options?: PdfRenderPageAnnotationOptions): PdfTask<AnnotationAppearanceMap<ImageDataLike>>;
|
|
3030
3123
|
getPageAnnotationsRaw(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfAnnotationObject[]>;
|
|
3031
3124
|
getPageAnnotations(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfAnnotationObject[]>;
|
|
3032
3125
|
createPageAnnotation<A extends PdfAnnotationObject>(doc: PdfDocumentObject, page: PdfPageObject, annotation: A, context?: AnnotationCreateContext<A>): PdfTask<string>;
|
|
3033
|
-
updatePageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject
|
|
3126
|
+
updatePageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject, options?: {
|
|
3127
|
+
regenerateAppearance?: boolean;
|
|
3128
|
+
}): PdfTask<boolean>;
|
|
3034
3129
|
removePageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): PdfTask<boolean>;
|
|
3035
3130
|
getPageTextRects(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfTextRectObject[]>;
|
|
3036
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.
|
|
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",
|