@embedpdf/models 1.0.17 → 1.0.19
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/helpers/index.d.ts +1 -0
- package/dist/helpers/logger.d.ts +24 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +59 -3
- package/dist/index.js.map +1 -1
- package/dist/pdf.d.ts +108 -61
- package/package.json +1 -1
package/dist/pdf.d.ts
CHANGED
|
@@ -1928,17 +1928,6 @@ export interface PdfAnnotationTransformation {
|
|
|
1928
1928
|
*/
|
|
1929
1929
|
scale: Size;
|
|
1930
1930
|
}
|
|
1931
|
-
/**
|
|
1932
|
-
* Render options
|
|
1933
|
-
*
|
|
1934
|
-
* @public
|
|
1935
|
-
*/
|
|
1936
|
-
export interface PdfRenderOptions {
|
|
1937
|
-
/**
|
|
1938
|
-
* Whether needs to render the page with annotations
|
|
1939
|
-
*/
|
|
1940
|
-
withAnnotations: boolean;
|
|
1941
|
-
}
|
|
1942
1931
|
/**
|
|
1943
1932
|
* source can be byte array contains pdf content
|
|
1944
1933
|
*
|
|
@@ -1988,7 +1977,7 @@ export interface PdfFileLoader extends PdfFileWithoutContent {
|
|
|
1988
1977
|
*/
|
|
1989
1978
|
callback: (offset: number, length: number) => Uint8Array;
|
|
1990
1979
|
}
|
|
1991
|
-
export interface
|
|
1980
|
+
export interface PdfAnnotationsProgress {
|
|
1992
1981
|
page: number;
|
|
1993
1982
|
annotations: PdfAnnotationObject[];
|
|
1994
1983
|
}
|
|
@@ -2015,10 +2004,6 @@ export interface PdfFile extends PdfFileWithoutContent {
|
|
|
2015
2004
|
export interface PdfFileUrl extends PdfFileWithoutContent {
|
|
2016
2005
|
url: string;
|
|
2017
2006
|
}
|
|
2018
|
-
export interface PdfUrlOptions {
|
|
2019
|
-
mode?: 'auto' | 'range-request' | 'full-fetch';
|
|
2020
|
-
password?: string;
|
|
2021
|
-
}
|
|
2022
2007
|
export declare enum PdfErrorCode {
|
|
2023
2008
|
Ok = 0,// #define FPDF_ERR_SUCCESS 0 // No error.
|
|
2024
2009
|
Unknown = 1,// #define FPDF_ERR_UNKNOWN 1 // Unknown error.
|
|
@@ -2082,6 +2067,80 @@ export declare class PdfTaskHelper {
|
|
|
2082
2067
|
*/
|
|
2083
2068
|
static abort<T = any, P = unknown>(reason: PdfErrorReason): Task<T, PdfErrorReason, P>;
|
|
2084
2069
|
}
|
|
2070
|
+
export interface PdfOpenDocumentBufferOptions {
|
|
2071
|
+
/**
|
|
2072
|
+
* Password for the document
|
|
2073
|
+
*/
|
|
2074
|
+
password?: string;
|
|
2075
|
+
}
|
|
2076
|
+
export interface PdfOpenDocumentUrlOptions {
|
|
2077
|
+
/**
|
|
2078
|
+
* Password for the document
|
|
2079
|
+
*/
|
|
2080
|
+
password?: string;
|
|
2081
|
+
/**
|
|
2082
|
+
* Loading mode
|
|
2083
|
+
*/
|
|
2084
|
+
mode?: 'auto' | 'range-request' | 'full-fetch';
|
|
2085
|
+
}
|
|
2086
|
+
export interface PdfRenderOptions {
|
|
2087
|
+
/**
|
|
2088
|
+
* Scale factor
|
|
2089
|
+
*/
|
|
2090
|
+
scaleFactor?: number;
|
|
2091
|
+
/**
|
|
2092
|
+
* Rotation
|
|
2093
|
+
*/
|
|
2094
|
+
rotation?: Rotation;
|
|
2095
|
+
/**
|
|
2096
|
+
* Device pixel ratio
|
|
2097
|
+
*/
|
|
2098
|
+
dpr?: number;
|
|
2099
|
+
/**
|
|
2100
|
+
* Image type
|
|
2101
|
+
*/
|
|
2102
|
+
imageType?: ImageConversionTypes;
|
|
2103
|
+
}
|
|
2104
|
+
export interface PdfRenderPageOptions extends PdfRenderOptions {
|
|
2105
|
+
/**
|
|
2106
|
+
* Whether to render annotations
|
|
2107
|
+
*/
|
|
2108
|
+
withAnnotations?: boolean;
|
|
2109
|
+
}
|
|
2110
|
+
export interface PdfRenderPageAnnotationOptions extends PdfRenderOptions {
|
|
2111
|
+
/**
|
|
2112
|
+
* Appearance mode normal down or rollover
|
|
2113
|
+
*/
|
|
2114
|
+
mode?: AppearanceMode;
|
|
2115
|
+
}
|
|
2116
|
+
export interface PdfRenderThumbnailOptions extends PdfRenderOptions {
|
|
2117
|
+
/**
|
|
2118
|
+
* Whether to render annotations
|
|
2119
|
+
*/
|
|
2120
|
+
withAnnotations?: boolean;
|
|
2121
|
+
}
|
|
2122
|
+
export interface PdfSearchAllPagesOptions {
|
|
2123
|
+
/**
|
|
2124
|
+
* Search flags
|
|
2125
|
+
*/
|
|
2126
|
+
flags?: MatchFlag[];
|
|
2127
|
+
}
|
|
2128
|
+
export interface PdfRedactTextOptions {
|
|
2129
|
+
/**
|
|
2130
|
+
* Whether to recurse forms
|
|
2131
|
+
*/
|
|
2132
|
+
recurseForms?: boolean;
|
|
2133
|
+
/**
|
|
2134
|
+
* Whether to draw black boxes
|
|
2135
|
+
*/
|
|
2136
|
+
drawBlackBoxes?: boolean;
|
|
2137
|
+
}
|
|
2138
|
+
export interface PdfFlattenPageOptions {
|
|
2139
|
+
/**
|
|
2140
|
+
* Flatten flag
|
|
2141
|
+
*/
|
|
2142
|
+
flag?: PdfPageFlattenFlag;
|
|
2143
|
+
}
|
|
2085
2144
|
/**
|
|
2086
2145
|
* Pdf engine
|
|
2087
2146
|
*
|
|
@@ -2110,21 +2169,14 @@ export interface PdfEngine<T = Blob> {
|
|
|
2110
2169
|
* @param options - Additional options including mode (auto, range-request, full-fetch) and password
|
|
2111
2170
|
* @returns Task that resolves with the PdfDocumentObject or an error
|
|
2112
2171
|
*/
|
|
2113
|
-
openDocumentUrl: (file: PdfFileUrl, options?:
|
|
2172
|
+
openDocumentUrl: (file: PdfFileUrl, options?: PdfOpenDocumentUrlOptions) => PdfTask<PdfDocumentObject>;
|
|
2114
2173
|
/**
|
|
2115
2174
|
* Open pdf document from buffer
|
|
2116
2175
|
* @param file - pdf file
|
|
2117
|
-
* @param
|
|
2176
|
+
* @param options - Additional options including password
|
|
2118
2177
|
* @returns task that contains the file or error
|
|
2119
2178
|
*/
|
|
2120
|
-
|
|
2121
|
-
/**
|
|
2122
|
-
* Open pdf document from loader
|
|
2123
|
-
* @param file - pdf file
|
|
2124
|
-
* @param password - protected password for this file
|
|
2125
|
-
* @returns task that contains the file or error
|
|
2126
|
-
*/
|
|
2127
|
-
openDocumentFromLoader: (file: PdfFileLoader, password: string) => PdfTask<PdfDocumentObject>;
|
|
2179
|
+
openDocumentBuffer: (file: PdfFile, options?: PdfOpenDocumentBufferOptions) => PdfTask<PdfDocumentObject>;
|
|
2128
2180
|
/**
|
|
2129
2181
|
* Get the metadata of the file
|
|
2130
2182
|
* @param doc - pdf document
|
|
@@ -2159,25 +2211,27 @@ export interface PdfEngine<T = Blob> {
|
|
|
2159
2211
|
* Render the specified pdf page
|
|
2160
2212
|
* @param doc - pdf document
|
|
2161
2213
|
* @param page - pdf page
|
|
2162
|
-
* @param scaleFactor - factor of scaling
|
|
2163
|
-
* @param rotation - rotated angle
|
|
2164
|
-
* @param dpr - devicePixelRatio
|
|
2165
2214
|
* @param options - render options
|
|
2166
2215
|
* @returns task contains the rendered image or error
|
|
2167
2216
|
*/
|
|
2168
|
-
renderPage: (doc: PdfDocumentObject, page: PdfPageObject,
|
|
2217
|
+
renderPage: (doc: PdfDocumentObject, page: PdfPageObject, options?: PdfRenderPageOptions) => PdfTask<T>;
|
|
2169
2218
|
/**
|
|
2170
2219
|
* Render the specified rect of pdf page
|
|
2171
2220
|
* @param doc - pdf document
|
|
2172
2221
|
* @param page - pdf page
|
|
2173
|
-
* @param scaleFactor - factor of scaling
|
|
2174
|
-
* @param rotation - rotated angle
|
|
2175
|
-
* @param dpr - devicePixelRatio
|
|
2176
2222
|
* @param rect - target rect
|
|
2177
2223
|
* @param options - render options
|
|
2178
2224
|
* @returns task contains the rendered image or error
|
|
2179
2225
|
*/
|
|
2180
|
-
renderPageRect: (doc: PdfDocumentObject, page: PdfPageObject,
|
|
2226
|
+
renderPageRect: (doc: PdfDocumentObject, page: PdfPageObject, rect: Rect, options?: PdfRenderPageOptions) => PdfTask<T>;
|
|
2227
|
+
/**
|
|
2228
|
+
* Render the thumbnail of specified pdf page
|
|
2229
|
+
* @param doc - pdf document
|
|
2230
|
+
* @param page - pdf page
|
|
2231
|
+
* @param options - render options
|
|
2232
|
+
* @returns task contains the rendered image or error
|
|
2233
|
+
*/
|
|
2234
|
+
renderThumbnail: (doc: PdfDocumentObject, page: PdfPageObject, options?: PdfRenderThumbnailOptions) => PdfTask<T>;
|
|
2181
2235
|
/**
|
|
2182
2236
|
* Render a single annotation into an ImageData blob.
|
|
2183
2237
|
*
|
|
@@ -2186,18 +2240,13 @@ export interface PdfEngine<T = Blob> {
|
|
|
2186
2240
|
* @param doc - pdf document
|
|
2187
2241
|
* @param page - pdf page
|
|
2188
2242
|
* @param annotation - the annotation to render
|
|
2189
|
-
* @param
|
|
2190
|
-
* @param rotation - rotated angle
|
|
2191
|
-
* @param dpr - devicePixelRatio
|
|
2192
|
-
* @param mode - appearance mode
|
|
2243
|
+
* @param options - render options
|
|
2193
2244
|
*/
|
|
2194
|
-
|
|
2245
|
+
renderPageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject, options?: PdfRenderPageAnnotationOptions): PdfTask<T>;
|
|
2195
2246
|
/**
|
|
2196
2247
|
* Get annotations of pdf page
|
|
2197
2248
|
* @param doc - pdf document
|
|
2198
2249
|
* @param page - pdf page
|
|
2199
|
-
* @param scaleFactor - factor of scaling
|
|
2200
|
-
* @param rotation - rotated angle
|
|
2201
2250
|
* @returns task contains the annotations or error
|
|
2202
2251
|
*/
|
|
2203
2252
|
getPageAnnotations: (doc: PdfDocumentObject, page: PdfPageObject) => PdfTask<PdfAnnotationObject[]>;
|
|
@@ -2206,9 +2255,10 @@ export interface PdfEngine<T = Blob> {
|
|
|
2206
2255
|
* @param doc - pdf document
|
|
2207
2256
|
* @param page - pdf page
|
|
2208
2257
|
* @param annotation - new annotations
|
|
2258
|
+
* @param context - context of the annotation
|
|
2209
2259
|
* @returns task whether the annotations is created successfully
|
|
2210
2260
|
*/
|
|
2211
|
-
createPageAnnotation: <A extends PdfAnnotationObject>(doc: PdfDocumentObject, page: PdfPageObject, annotation: A, context?: AnnotationCreateContext<A>) => PdfTask<
|
|
2261
|
+
createPageAnnotation: <A extends PdfAnnotationObject>(doc: PdfDocumentObject, page: PdfPageObject, annotation: A, context?: AnnotationCreateContext<A>) => PdfTask<string>;
|
|
2212
2262
|
/**
|
|
2213
2263
|
* Update a annotation on specified page
|
|
2214
2264
|
* @param doc - pdf document
|
|
@@ -2229,36 +2279,24 @@ export interface PdfEngine<T = Blob> {
|
|
|
2229
2279
|
* get all text rects in pdf page
|
|
2230
2280
|
* @param doc - pdf document
|
|
2231
2281
|
* @param page - pdf page
|
|
2232
|
-
* @param
|
|
2233
|
-
* @param rotation - rotated angle
|
|
2282
|
+
* @param options - get page text rects options
|
|
2234
2283
|
* @returns task contains the text rects or error
|
|
2235
2284
|
*/
|
|
2236
|
-
getPageTextRects: (doc: PdfDocumentObject, page: PdfPageObject
|
|
2237
|
-
/**
|
|
2238
|
-
* Render the thumbnail of specified pdf page
|
|
2239
|
-
* @param doc - pdf document
|
|
2240
|
-
* @param page - pdf page
|
|
2241
|
-
* @param scaleFactor - factor of scaling
|
|
2242
|
-
* @param rotation - rotated angle
|
|
2243
|
-
* @param dpr - devicePixelRatio
|
|
2244
|
-
* @param options - render options
|
|
2245
|
-
* @returns task contains the rendered image or error
|
|
2246
|
-
*/
|
|
2247
|
-
renderThumbnail: (doc: PdfDocumentObject, page: PdfPageObject, scaleFactor: number, rotation: Rotation, dpr: number) => PdfTask<T>;
|
|
2285
|
+
getPageTextRects: (doc: PdfDocumentObject, page: PdfPageObject) => PdfTask<PdfTextRectObject[]>;
|
|
2248
2286
|
/**
|
|
2249
2287
|
* Search across all pages in the document
|
|
2250
2288
|
* @param doc - pdf document
|
|
2251
2289
|
* @param keyword - search keyword
|
|
2252
|
-
* @param
|
|
2290
|
+
* @param options - search all pages options
|
|
2253
2291
|
* @returns Task contains all search results throughout the document
|
|
2254
2292
|
*/
|
|
2255
|
-
searchAllPages: (doc: PdfDocumentObject, keyword: string,
|
|
2293
|
+
searchAllPages: (doc: PdfDocumentObject, keyword: string, options?: PdfSearchAllPagesOptions) => PdfTask<SearchAllPagesResult, PdfPageSearchProgress>;
|
|
2256
2294
|
/**
|
|
2257
2295
|
* Get all annotations in this file
|
|
2258
2296
|
* @param doc - pdf document
|
|
2259
2297
|
* @returns task that contains the annotations or error
|
|
2260
2298
|
*/
|
|
2261
|
-
getAllAnnotations: (doc: PdfDocumentObject) => PdfTask<Record<number, PdfAnnotationObject[]>,
|
|
2299
|
+
getAllAnnotations: (doc: PdfDocumentObject) => PdfTask<Record<number, PdfAnnotationObject[]>, PdfAnnotationsProgress>;
|
|
2262
2300
|
/**
|
|
2263
2301
|
* Get all attachments in this file
|
|
2264
2302
|
* @param doc - pdf document
|
|
@@ -2284,9 +2322,9 @@ export interface PdfEngine<T = Blob> {
|
|
|
2284
2322
|
* Flatten annotations and form fields into the page contents.
|
|
2285
2323
|
* @param doc - pdf document
|
|
2286
2324
|
* @param page - pdf page
|
|
2287
|
-
* @param
|
|
2325
|
+
* @param options - flatten page options
|
|
2288
2326
|
*/
|
|
2289
|
-
flattenPage: (doc: PdfDocumentObject, page: PdfPageObject,
|
|
2327
|
+
flattenPage: (doc: PdfDocumentObject, page: PdfPageObject, options?: PdfFlattenPageOptions) => PdfTask<PdfPageFlattenResult>;
|
|
2290
2328
|
/**
|
|
2291
2329
|
* Extract pdf pages to a new file
|
|
2292
2330
|
* @param doc - pdf document
|
|
@@ -2301,6 +2339,15 @@ export interface PdfEngine<T = Blob> {
|
|
|
2301
2339
|
* @returns task contains the text
|
|
2302
2340
|
*/
|
|
2303
2341
|
extractText: (doc: PdfDocumentObject, pageIndexes: number[]) => PdfTask<string>;
|
|
2342
|
+
/**
|
|
2343
|
+
* Redact text by run slices
|
|
2344
|
+
* @param doc - pdf document
|
|
2345
|
+
* @param page - pdf page
|
|
2346
|
+
* @param rects - rects to redact
|
|
2347
|
+
* @param options - redact text options
|
|
2348
|
+
* @returns task contains the result
|
|
2349
|
+
*/
|
|
2350
|
+
redactTextInRects: (doc: PdfDocumentObject, page: PdfPageObject, rects: Rect[], options?: PdfRedactTextOptions) => PdfTask<boolean>;
|
|
2304
2351
|
/**
|
|
2305
2352
|
* Extract text on specified pdf pages
|
|
2306
2353
|
* @param doc - pdf document
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/models",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
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",
|