@libpdf/core 0.0.1-beta.1 → 0.0.1-beta.4
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/LICENSE.md +1 -1
- package/README.md +15 -17
- package/dist/index.d.mts +1774 -267
- package/dist/index.mjs +4372 -1250
- package/dist/index.mjs.map +1 -1
- package/package.json +56 -41
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import * as _google_cloud_kms0 from "@google-cloud/kms";
|
|
3
|
+
import * as _google_cloud_secret_manager0 from "@google-cloud/secret-manager";
|
|
2
4
|
|
|
3
5
|
//#region package.d.ts
|
|
4
6
|
declare let version: string;
|
|
@@ -2495,6 +2497,12 @@ interface LtvValidationData {
|
|
|
2495
2497
|
crls: Uint8Array[];
|
|
2496
2498
|
/** Timestamp when validation data was gathered */
|
|
2497
2499
|
timestamp: Date;
|
|
2500
|
+
/**
|
|
2501
|
+
* Embedded timestamp tokens (for VRI entries).
|
|
2502
|
+
* Each timestamp token embedded in the signature's unsigned attributes
|
|
2503
|
+
* needs its own VRI entry per ETSI EN 319 142-2.
|
|
2504
|
+
*/
|
|
2505
|
+
embeddedTimestamps?: Uint8Array[];
|
|
2498
2506
|
}
|
|
2499
2507
|
/**
|
|
2500
2508
|
* Result of signing operation.
|
|
@@ -2565,6 +2573,14 @@ declare class PlaceholderError extends SignatureError {
|
|
|
2565
2573
|
readonly availableSize: number;
|
|
2566
2574
|
constructor(requiredSize: number, availableSize: number);
|
|
2567
2575
|
}
|
|
2576
|
+
/**
|
|
2577
|
+
* Error with KMS signer (e.g., key issues, permission denied, unsupported algorithm).
|
|
2578
|
+
*/
|
|
2579
|
+
declare class KmsSignerError extends SignerError {
|
|
2580
|
+
/** The original error that caused this error (if any) */
|
|
2581
|
+
readonly cause?: Error;
|
|
2582
|
+
constructor(message: string, cause?: Error);
|
|
2583
|
+
}
|
|
2568
2584
|
//#endregion
|
|
2569
2585
|
//#region src/text/types.d.ts
|
|
2570
2586
|
/**
|
|
@@ -3002,181 +3018,1312 @@ declare class PDFPageTree {
|
|
|
3002
3018
|
* @param toIndex The target page index
|
|
3003
3019
|
* @throws {RangeError} if either index is out of bounds
|
|
3004
3020
|
*/
|
|
3005
|
-
movePage(fromIndex: number, toIndex: number): void;
|
|
3021
|
+
movePage(fromIndex: number, toIndex: number): void;
|
|
3022
|
+
}
|
|
3023
|
+
//#endregion
|
|
3024
|
+
//#region src/api/pdf-context.d.ts
|
|
3025
|
+
/**
|
|
3026
|
+
* Function type for resolving embedded font references.
|
|
3027
|
+
* Synchronous because refs are pre-allocated when fonts are embedded.
|
|
3028
|
+
*/
|
|
3029
|
+
type FontRefResolver = (font: EmbeddedFont) => PdfRef;
|
|
3030
|
+
/**
|
|
3031
|
+
* Document metadata stored in the context.
|
|
3032
|
+
*/
|
|
3033
|
+
interface DocumentInfo {
|
|
3034
|
+
/** PDF version (e.g., "1.7", "2.0") */
|
|
3035
|
+
version: string;
|
|
3036
|
+
/** Whether the document is encrypted */
|
|
3037
|
+
isEncrypted: boolean;
|
|
3038
|
+
/** Whether authentication succeeded */
|
|
3039
|
+
isAuthenticated: boolean;
|
|
3040
|
+
/** Trailer dictionary */
|
|
3041
|
+
trailer: PdfDict;
|
|
3042
|
+
/** Security handler (if encrypted) */
|
|
3043
|
+
securityHandler: StandardSecurityHandler | null;
|
|
3044
|
+
}
|
|
3045
|
+
/**
|
|
3046
|
+
* Central context for PDF document operations.
|
|
3047
|
+
*
|
|
3048
|
+
* Encapsulates all the shared state and services that subsystems need:
|
|
3049
|
+
* - Object registry for tracking and resolving objects
|
|
3050
|
+
* - Catalog for document-level structures
|
|
3051
|
+
* - Page tree for page access
|
|
3052
|
+
* - Document info (version, encryption status, trailer)
|
|
3053
|
+
*/
|
|
3054
|
+
declare class PDFContext {
|
|
3055
|
+
/** Object registry for tracking refs and objects */
|
|
3056
|
+
readonly registry: ObjectRegistry;
|
|
3057
|
+
/** Document catalog wrapper */
|
|
3058
|
+
readonly catalog: PDFCatalog;
|
|
3059
|
+
/** Page tree for page access and manipulation */
|
|
3060
|
+
readonly pages: PDFPageTree;
|
|
3061
|
+
/** Document metadata */
|
|
3062
|
+
readonly info: DocumentInfo;
|
|
3063
|
+
/** Font reference resolver (set by PDF class) */
|
|
3064
|
+
private fontRefResolver;
|
|
3065
|
+
constructor(registry: ObjectRegistry, catalog: PDFCatalog, pages: PDFPageTree, info: DocumentInfo);
|
|
3066
|
+
/**
|
|
3067
|
+
* Set the font reference resolver.
|
|
3068
|
+
* @internal Called by PDF class to wire up font resolution.
|
|
3069
|
+
*/
|
|
3070
|
+
setFontRefResolver(resolver: FontRefResolver): void;
|
|
3071
|
+
/**
|
|
3072
|
+
* Get a font reference for an embedded font.
|
|
3073
|
+
*
|
|
3074
|
+
* The reference is available immediately because refs are pre-allocated
|
|
3075
|
+
* when fonts are embedded. Actual font objects are created at save time.
|
|
3076
|
+
*/
|
|
3077
|
+
getFontRef(font: EmbeddedFont): PdfRef;
|
|
3078
|
+
/**
|
|
3079
|
+
* Register a new object, assigning it a reference.
|
|
3080
|
+
*/
|
|
3081
|
+
register(obj: PdfObject): PdfRef;
|
|
3082
|
+
/**
|
|
3083
|
+
* Resolve an object by reference (async, fetches if needed).
|
|
3084
|
+
*/
|
|
3085
|
+
resolve(ref: PdfRef): Promise<PdfObject | null>;
|
|
3086
|
+
/**
|
|
3087
|
+
* Get an object by reference (sync, only if already loaded).
|
|
3088
|
+
*/
|
|
3089
|
+
getObject(ref: PdfRef): PdfObject | null;
|
|
3090
|
+
/**
|
|
3091
|
+
* Get the reference for an object.
|
|
3092
|
+
*/
|
|
3093
|
+
getRef(obj: PdfObject): PdfRef | null;
|
|
3094
|
+
/**
|
|
3095
|
+
* Add a warning message.
|
|
3096
|
+
*/
|
|
3097
|
+
addWarning(message: string): void;
|
|
3098
|
+
/**
|
|
3099
|
+
* Get all warnings.
|
|
3100
|
+
*/
|
|
3101
|
+
get warnings(): string[];
|
|
3102
|
+
}
|
|
3103
|
+
//#endregion
|
|
3104
|
+
//#region src/api/pdf-attachments.d.ts
|
|
3105
|
+
/**
|
|
3106
|
+
* PDFAttachments manages file attachments for a PDF document.
|
|
3107
|
+
*/
|
|
3108
|
+
declare class PDFAttachments {
|
|
3109
|
+
/** PDF context */
|
|
3110
|
+
private readonly ctx;
|
|
3111
|
+
constructor(ctx: PDFContext);
|
|
3112
|
+
/**
|
|
3113
|
+
* List all attachments in the document.
|
|
3114
|
+
*
|
|
3115
|
+
* @returns Map of attachment name to attachment info
|
|
3116
|
+
*
|
|
3117
|
+
* @example
|
|
3118
|
+
* ```typescript
|
|
3119
|
+
* const attachments = await pdf.attachments.list();
|
|
3120
|
+
* for (const [name, info] of attachments) {
|
|
3121
|
+
* console.log(`${name}: ${info.size} bytes`);
|
|
3122
|
+
* }
|
|
3123
|
+
* ```
|
|
3124
|
+
*/
|
|
3125
|
+
list(): Promise<Map<string, AttachmentInfo>>;
|
|
3126
|
+
/**
|
|
3127
|
+
* Get the raw bytes of an attachment.
|
|
3128
|
+
*
|
|
3129
|
+
* @param name - The attachment name (key in the EmbeddedFiles tree)
|
|
3130
|
+
* @returns The attachment bytes, or null if not found
|
|
3131
|
+
*
|
|
3132
|
+
* @example
|
|
3133
|
+
* ```typescript
|
|
3134
|
+
* const data = await pdf.attachments.get("document.txt");
|
|
3135
|
+
* if (data) {
|
|
3136
|
+
* const text = new TextDecoder().decode(data);
|
|
3137
|
+
* console.log(text);
|
|
3138
|
+
* }
|
|
3139
|
+
* ```
|
|
3140
|
+
*/
|
|
3141
|
+
get(name: string): Promise<Uint8Array | null>;
|
|
3142
|
+
/**
|
|
3143
|
+
* Check if an attachment exists.
|
|
3144
|
+
*
|
|
3145
|
+
* @param name - The attachment name
|
|
3146
|
+
* @returns True if the attachment exists
|
|
3147
|
+
*
|
|
3148
|
+
* @example
|
|
3149
|
+
* ```typescript
|
|
3150
|
+
* if (await pdf.attachments.has("report.pdf")) {
|
|
3151
|
+
* const data = await pdf.attachments.get("report.pdf");
|
|
3152
|
+
* }
|
|
3153
|
+
* ```
|
|
3154
|
+
*/
|
|
3155
|
+
has(name: string): Promise<boolean>;
|
|
3156
|
+
/**
|
|
3157
|
+
* Add a file attachment to the document.
|
|
3158
|
+
*
|
|
3159
|
+
* @param name - The attachment name (key in the EmbeddedFiles tree)
|
|
3160
|
+
* @param data - The file data
|
|
3161
|
+
* @param options - Attachment options (description, MIME type, dates)
|
|
3162
|
+
* @throws {Error} if name already exists and overwrite !== true
|
|
3163
|
+
*
|
|
3164
|
+
* @example
|
|
3165
|
+
* ```typescript
|
|
3166
|
+
* // Add with auto-detected MIME type
|
|
3167
|
+
* await pdf.attachments.add("report.pdf", pdfBytes);
|
|
3168
|
+
*
|
|
3169
|
+
* // Add with explicit options
|
|
3170
|
+
* await pdf.attachments.add("data.json", jsonBytes, {
|
|
3171
|
+
* description: "Configuration data",
|
|
3172
|
+
* mimeType: "application/json",
|
|
3173
|
+
* });
|
|
3174
|
+
*
|
|
3175
|
+
* // Replace existing attachment
|
|
3176
|
+
* await pdf.attachments.add("report.pdf", newBytes, { overwrite: true });
|
|
3177
|
+
* ```
|
|
3178
|
+
*/
|
|
3179
|
+
add(name: string, data: Uint8Array, options?: AddAttachmentOptions): Promise<void>;
|
|
3180
|
+
/**
|
|
3181
|
+
* Remove an attachment from the document.
|
|
3182
|
+
*
|
|
3183
|
+
* @param name - The attachment name
|
|
3184
|
+
* @returns True if the attachment was removed, false if not found
|
|
3185
|
+
*
|
|
3186
|
+
* @example
|
|
3187
|
+
* ```typescript
|
|
3188
|
+
* const removed = await pdf.attachments.remove("old-file.txt");
|
|
3189
|
+
* if (removed) {
|
|
3190
|
+
* console.log("Attachment removed");
|
|
3191
|
+
* }
|
|
3192
|
+
* ```
|
|
3193
|
+
*/
|
|
3194
|
+
remove(name: string): Promise<boolean>;
|
|
3195
|
+
}
|
|
3196
|
+
//#endregion
|
|
3197
|
+
//#region src/helpers/colors.d.ts
|
|
3198
|
+
/**
|
|
3199
|
+
* Color types and helper functions for form fields.
|
|
3200
|
+
*
|
|
3201
|
+
* Provides RGB, Grayscale, and CMYK color types for use with form field styling.
|
|
3202
|
+
*/
|
|
3203
|
+
/**
|
|
3204
|
+
* RGB color with values in the 0-1 range.
|
|
3205
|
+
*/
|
|
3206
|
+
interface RGB {
|
|
3207
|
+
type: "RGB";
|
|
3208
|
+
red: number;
|
|
3209
|
+
green: number;
|
|
3210
|
+
blue: number;
|
|
3211
|
+
}
|
|
3212
|
+
/**
|
|
3213
|
+
* Grayscale color with value in the 0-1 range.
|
|
3214
|
+
* 0 = black, 1 = white.
|
|
3215
|
+
*/
|
|
3216
|
+
interface Grayscale {
|
|
3217
|
+
type: "Grayscale";
|
|
3218
|
+
gray: number;
|
|
3219
|
+
}
|
|
3220
|
+
/**
|
|
3221
|
+
* CMYK color with values in the 0-1 range.
|
|
3222
|
+
*/
|
|
3223
|
+
interface CMYK {
|
|
3224
|
+
type: "CMYK";
|
|
3225
|
+
cyan: number;
|
|
3226
|
+
magenta: number;
|
|
3227
|
+
yellow: number;
|
|
3228
|
+
black: number;
|
|
3229
|
+
}
|
|
3230
|
+
/**
|
|
3231
|
+
* Union type for all supported color types.
|
|
3232
|
+
*/
|
|
3233
|
+
type Color = RGB | Grayscale | CMYK;
|
|
3234
|
+
/**
|
|
3235
|
+
* Create an RGB color.
|
|
3236
|
+
*
|
|
3237
|
+
* @param r Red component (0-1)
|
|
3238
|
+
* @param g Green component (0-1)
|
|
3239
|
+
* @param b Blue component (0-1)
|
|
3240
|
+
* @returns RGB color object
|
|
3241
|
+
*
|
|
3242
|
+
* @example
|
|
3243
|
+
* ```typescript
|
|
3244
|
+
* const red = rgb(1, 0, 0);
|
|
3245
|
+
* const gray50 = rgb(0.5, 0.5, 0.5);
|
|
3246
|
+
* const cream = rgb(1, 1, 0.9);
|
|
3247
|
+
* ```
|
|
3248
|
+
*/
|
|
3249
|
+
declare function rgb(r: number, g: number, b: number): RGB;
|
|
3250
|
+
/**
|
|
3251
|
+
* Create a grayscale color.
|
|
3252
|
+
*
|
|
3253
|
+
* @param gray Gray value (0 = black, 1 = white)
|
|
3254
|
+
* @returns Grayscale color object
|
|
3255
|
+
*
|
|
3256
|
+
* @example
|
|
3257
|
+
* ```typescript
|
|
3258
|
+
* const black = grayscale(0);
|
|
3259
|
+
* const white = grayscale(1);
|
|
3260
|
+
* const midGray = grayscale(0.5);
|
|
3261
|
+
* ```
|
|
3262
|
+
*/
|
|
3263
|
+
declare function grayscale(gray: number): Grayscale;
|
|
3264
|
+
/**
|
|
3265
|
+
* Create a CMYK color.
|
|
3266
|
+
*
|
|
3267
|
+
* @param c Cyan component (0-1)
|
|
3268
|
+
* @param m Magenta component (0-1)
|
|
3269
|
+
* @param y Yellow component (0-1)
|
|
3270
|
+
* @param k Black component (0-1)
|
|
3271
|
+
* @returns CMYK color object
|
|
3272
|
+
*
|
|
3273
|
+
* @example
|
|
3274
|
+
* ```typescript
|
|
3275
|
+
* const black = cmyk(0, 0, 0, 1);
|
|
3276
|
+
* const cyan = cmyk(1, 0, 0, 0);
|
|
3277
|
+
* ```
|
|
3278
|
+
*/
|
|
3279
|
+
declare function cmyk(c: number, m: number, y: number, k: number): CMYK;
|
|
3280
|
+
/** Black color (grayscale 0) */
|
|
3281
|
+
declare const black: Grayscale;
|
|
3282
|
+
/** White color (grayscale 1) */
|
|
3283
|
+
declare const white: Grayscale;
|
|
3284
|
+
/** Red color (RGB) */
|
|
3285
|
+
declare const red: RGB;
|
|
3286
|
+
/** Green color (RGB) */
|
|
3287
|
+
declare const green: RGB;
|
|
3288
|
+
/** Blue color (RGB) */
|
|
3289
|
+
declare const blue: RGB;
|
|
3290
|
+
//#endregion
|
|
3291
|
+
//#region src/annotations/types.d.ts
|
|
3292
|
+
/**
|
|
3293
|
+
* Annotation subtype values as defined in PDF spec Table 169.
|
|
3294
|
+
*/
|
|
3295
|
+
type AnnotationSubtype = "Text" | "Link" | "FreeText" | "Line" | "Square" | "Circle" | "Polygon" | "PolyLine" | "Highlight" | "Underline" | "Squiggly" | "StrikeOut" | "Stamp" | "Caret" | "Ink" | "Popup" | "FileAttachment" | "Widget";
|
|
3296
|
+
/**
|
|
3297
|
+
* Annotation flags (PDF spec Table 165).
|
|
3298
|
+
*/
|
|
3299
|
+
declare enum AnnotationFlags {
|
|
3300
|
+
/** Don't display unknown types */
|
|
3301
|
+
Invisible = 1,
|
|
3302
|
+
/** Don't display or print */
|
|
3303
|
+
Hidden = 2,
|
|
3304
|
+
/** Print when page is printed */
|
|
3305
|
+
Print = 4,
|
|
3306
|
+
/** Don't scale with page zoom */
|
|
3307
|
+
NoZoom = 8,
|
|
3308
|
+
/** Don't rotate with page */
|
|
3309
|
+
NoRotate = 16,
|
|
3310
|
+
/** Don't display on screen */
|
|
3311
|
+
NoView = 32,
|
|
3312
|
+
/** Don't allow interaction */
|
|
3313
|
+
ReadOnly = 64,
|
|
3314
|
+
/** Don't allow deletion/modification */
|
|
3315
|
+
Locked = 128,
|
|
3316
|
+
/** Invert NoView for certain events */
|
|
3317
|
+
ToggleNoView = 256,
|
|
3318
|
+
/** Don't allow content modification */
|
|
3319
|
+
LockedContents = 512,
|
|
3320
|
+
}
|
|
3321
|
+
/**
|
|
3322
|
+
* A rectangle defined by x, y (bottom-left origin), width, and height.
|
|
3323
|
+
*/
|
|
3324
|
+
interface Rect {
|
|
3325
|
+
x: number;
|
|
3326
|
+
y: number;
|
|
3327
|
+
width: number;
|
|
3328
|
+
height: number;
|
|
3329
|
+
}
|
|
3330
|
+
/**
|
|
3331
|
+
* A point in 2D space.
|
|
3332
|
+
*/
|
|
3333
|
+
interface Point {
|
|
3334
|
+
x: number;
|
|
3335
|
+
y: number;
|
|
3336
|
+
}
|
|
3337
|
+
/**
|
|
3338
|
+
* Border style types.
|
|
3339
|
+
*/
|
|
3340
|
+
type BorderStyleType = "solid" | "dashed" | "beveled" | "inset" | "underline";
|
|
3341
|
+
/**
|
|
3342
|
+
* Border style configuration.
|
|
3343
|
+
*/
|
|
3344
|
+
interface BorderStyle {
|
|
3345
|
+
/** Border width in points (default: 1) */
|
|
3346
|
+
width?: number;
|
|
3347
|
+
/** Border style (default: "solid") */
|
|
3348
|
+
style?: BorderStyleType;
|
|
3349
|
+
/** Dash array for dashed style (default: [3]) */
|
|
3350
|
+
dashArray?: number[];
|
|
3351
|
+
}
|
|
3352
|
+
/**
|
|
3353
|
+
* Line ending styles (PDF spec Table 176).
|
|
3354
|
+
*/
|
|
3355
|
+
type LineEndingStyle = "None" | "Square" | "Circle" | "Diamond" | "OpenArrow" | "ClosedArrow" | "Butt" | "ROpenArrow" | "RClosedArrow" | "Slash";
|
|
3356
|
+
/**
|
|
3357
|
+
* Text annotation icon names (PDF spec Table 172).
|
|
3358
|
+
*/
|
|
3359
|
+
type TextAnnotationIcon = "Comment" | "Key" | "Note" | "Help" | "NewParagraph" | "Paragraph" | "Insert";
|
|
3360
|
+
/**
|
|
3361
|
+
* Stamp annotation standard names (PDF spec Table 181).
|
|
3362
|
+
*/
|
|
3363
|
+
type StampName = "Approved" | "Experimental" | "NotApproved" | "AsIs" | "Expired" | "NotForPublicRelease" | "Confidential" | "Final" | "Sold" | "Departmental" | "ForComment" | "TopSecret" | "Draft" | "ForPublicRelease";
|
|
3364
|
+
/**
|
|
3365
|
+
* File attachment icon names.
|
|
3366
|
+
*/
|
|
3367
|
+
type FileAttachmentIcon = "Graph" | "Paperclip" | "PushPin" | "Tag";
|
|
3368
|
+
/**
|
|
3369
|
+
* Options for creating a Text annotation (sticky note).
|
|
3370
|
+
*/
|
|
3371
|
+
interface TextAnnotationOptions {
|
|
3372
|
+
/** Annotation rectangle */
|
|
3373
|
+
rect: Rect;
|
|
3374
|
+
/** Text content */
|
|
3375
|
+
contents?: string;
|
|
3376
|
+
/** Author/title */
|
|
3377
|
+
title?: string;
|
|
3378
|
+
/** Background color */
|
|
3379
|
+
color?: Color;
|
|
3380
|
+
/** Icon to display */
|
|
3381
|
+
icon?: TextAnnotationIcon;
|
|
3382
|
+
/** Whether the popup is initially open */
|
|
3383
|
+
open?: boolean;
|
|
3384
|
+
}
|
|
3385
|
+
/**
|
|
3386
|
+
* Options for creating a text markup annotation (Highlight, Underline, StrikeOut, Squiggly).
|
|
3387
|
+
*/
|
|
3388
|
+
interface TextMarkupAnnotationOptions {
|
|
3389
|
+
/** Single rectangle for simple horizontal text */
|
|
3390
|
+
rect?: Rect;
|
|
3391
|
+
/** Multiple rectangles for multi-line selections */
|
|
3392
|
+
rects?: Rect[];
|
|
3393
|
+
/** Raw quadPoints for rotated/skewed text (advanced) */
|
|
3394
|
+
quadPoints?: number[][];
|
|
3395
|
+
/** Annotation color */
|
|
3396
|
+
color?: Color;
|
|
3397
|
+
/** Opacity (0-1, default: 1) */
|
|
3398
|
+
opacity?: number;
|
|
3399
|
+
/** Text content/comment */
|
|
3400
|
+
contents?: string;
|
|
3401
|
+
/** Author/title */
|
|
3402
|
+
title?: string;
|
|
3403
|
+
}
|
|
3404
|
+
/**
|
|
3405
|
+
* Destination types for links.
|
|
3406
|
+
*/
|
|
3407
|
+
type DestinationType = "Fit" | "FitH" | "FitV" | "FitB" | "FitBH" | "FitBV" | "XYZ" | "FitR";
|
|
3408
|
+
/**
|
|
3409
|
+
* A link destination.
|
|
3410
|
+
*
|
|
3411
|
+
* For internal destinations, the page is typically a page reference.
|
|
3412
|
+
* For remote destinations (GoToR), the page can be a 0-based page index.
|
|
3413
|
+
*/
|
|
3414
|
+
interface LinkDestination {
|
|
3415
|
+
/**
|
|
3416
|
+
* Target page for the destination.
|
|
3417
|
+
*
|
|
3418
|
+
* - Internal `GoTo` destinations: a `PdfRef` to a page object.
|
|
3419
|
+
* - Remote `GoToR` destinations: a 0-based page index (`number`).
|
|
3420
|
+
*/
|
|
3421
|
+
page: PdfRef | number;
|
|
3422
|
+
/** Destination type */
|
|
3423
|
+
type: DestinationType;
|
|
3424
|
+
/** Top coordinate for FitH, FitBH, XYZ */
|
|
3425
|
+
top?: number;
|
|
3426
|
+
/** Left coordinate for FitV, FitBV, XYZ */
|
|
3427
|
+
left?: number;
|
|
3428
|
+
/** Zoom level for XYZ (null means no change) */
|
|
3429
|
+
zoom?: number | null;
|
|
3430
|
+
/** Bounds for FitR: [left, bottom, right, top] */
|
|
3431
|
+
rect?: [number, number, number, number];
|
|
3432
|
+
}
|
|
3433
|
+
/**
|
|
3434
|
+
* A link destination for internal links created in this document.
|
|
3435
|
+
*/
|
|
3436
|
+
type InternalLinkDestination = Omit<LinkDestination, "page"> & {
|
|
3437
|
+
/** Target page in the current document. */
|
|
3438
|
+
page: PdfRef | PDFPage;
|
|
3439
|
+
};
|
|
3440
|
+
/**
|
|
3441
|
+
* Options for creating a Link annotation.
|
|
3442
|
+
*/
|
|
3443
|
+
interface LinkAnnotationOptions {
|
|
3444
|
+
/** Annotation rectangle */
|
|
3445
|
+
rect: Rect;
|
|
3446
|
+
/** External URI */
|
|
3447
|
+
uri?: string;
|
|
3448
|
+
/**
|
|
3449
|
+
* Internal destination within this document.
|
|
3450
|
+
*
|
|
3451
|
+
* Pass a `PDFPage` (recommended) or a `PdfRef` to the target page.
|
|
3452
|
+
*/
|
|
3453
|
+
destination?: InternalLinkDestination;
|
|
3454
|
+
/** Border width (default: 0 for invisible border) */
|
|
3455
|
+
borderWidth?: number;
|
|
3456
|
+
/** Border color */
|
|
3457
|
+
borderColor?: Color;
|
|
3458
|
+
}
|
|
3459
|
+
/**
|
|
3460
|
+
* Options for creating a FreeText annotation.
|
|
3461
|
+
*/
|
|
3462
|
+
interface FreeTextAnnotationOptions {
|
|
3463
|
+
/** Annotation rectangle */
|
|
3464
|
+
rect: Rect;
|
|
3465
|
+
/** Text content */
|
|
3466
|
+
contents: string;
|
|
3467
|
+
/** Font size (default: 12) */
|
|
3468
|
+
fontSize?: number;
|
|
3469
|
+
/** Text color (default: black) */
|
|
3470
|
+
color?: Color;
|
|
3471
|
+
/** Background color */
|
|
3472
|
+
backgroundColor?: Color;
|
|
3473
|
+
/** Border color */
|
|
3474
|
+
borderColor?: Color;
|
|
3475
|
+
/** Border width */
|
|
3476
|
+
borderWidth?: number;
|
|
3477
|
+
/** Text alignment: 0=left, 1=center, 2=right */
|
|
3478
|
+
justification?: 0 | 1 | 2;
|
|
3479
|
+
}
|
|
3480
|
+
/**
|
|
3481
|
+
* Options for creating a Line annotation.
|
|
3482
|
+
*/
|
|
3483
|
+
interface LineAnnotationOptions {
|
|
3484
|
+
/** Start point */
|
|
3485
|
+
start: Point;
|
|
3486
|
+
/** End point */
|
|
3487
|
+
end: Point;
|
|
3488
|
+
/** Line color */
|
|
3489
|
+
color?: Color;
|
|
3490
|
+
/** Line width (default: 1) */
|
|
3491
|
+
width?: number;
|
|
3492
|
+
/** Line ending style at start */
|
|
3493
|
+
startStyle?: LineEndingStyle;
|
|
3494
|
+
/** Line ending style at end */
|
|
3495
|
+
endStyle?: LineEndingStyle;
|
|
3496
|
+
/** Fill color for closed arrows */
|
|
3497
|
+
interiorColor?: Color;
|
|
3498
|
+
/** Text content/comment */
|
|
3499
|
+
contents?: string;
|
|
3500
|
+
}
|
|
3501
|
+
/**
|
|
3502
|
+
* Options for creating a Square annotation.
|
|
3503
|
+
*/
|
|
3504
|
+
interface SquareAnnotationOptions {
|
|
3505
|
+
/** Annotation rectangle */
|
|
3506
|
+
rect: Rect;
|
|
3507
|
+
/** Stroke color */
|
|
3508
|
+
color?: Color;
|
|
3509
|
+
/** Fill color */
|
|
3510
|
+
fillColor?: Color;
|
|
3511
|
+
/** Border width (default: 1) */
|
|
3512
|
+
borderWidth?: number;
|
|
3513
|
+
/** Text content/comment */
|
|
3514
|
+
contents?: string;
|
|
3515
|
+
}
|
|
3516
|
+
/**
|
|
3517
|
+
* Options for creating a Circle annotation.
|
|
3518
|
+
*/
|
|
3519
|
+
interface CircleAnnotationOptions {
|
|
3520
|
+
/** Annotation rectangle (bounding box of ellipse) */
|
|
3521
|
+
rect: Rect;
|
|
3522
|
+
/** Stroke color */
|
|
3523
|
+
color?: Color;
|
|
3524
|
+
/** Fill color */
|
|
3525
|
+
fillColor?: Color;
|
|
3526
|
+
/** Border width (default: 1) */
|
|
3527
|
+
borderWidth?: number;
|
|
3528
|
+
/** Text content/comment */
|
|
3529
|
+
contents?: string;
|
|
3530
|
+
}
|
|
3531
|
+
/**
|
|
3532
|
+
* Options for creating a Polygon annotation.
|
|
3533
|
+
*/
|
|
3534
|
+
interface PolygonAnnotationOptions {
|
|
3535
|
+
/** Vertices of the polygon */
|
|
3536
|
+
vertices: Point[];
|
|
3537
|
+
/** Stroke color */
|
|
3538
|
+
color?: Color;
|
|
3539
|
+
/** Fill color */
|
|
3540
|
+
fillColor?: Color;
|
|
3541
|
+
/** Border width (default: 1) */
|
|
3542
|
+
borderWidth?: number;
|
|
3543
|
+
/** Text content/comment */
|
|
3544
|
+
contents?: string;
|
|
3545
|
+
}
|
|
3546
|
+
/**
|
|
3547
|
+
* Options for creating a PolyLine annotation.
|
|
3548
|
+
*/
|
|
3549
|
+
interface PolylineAnnotationOptions {
|
|
3550
|
+
/** Vertices of the polyline */
|
|
3551
|
+
vertices: Point[];
|
|
3552
|
+
/** Line color */
|
|
3553
|
+
color?: Color;
|
|
3554
|
+
/** Line width (default: 1) */
|
|
3555
|
+
width?: number;
|
|
3556
|
+
/** Line ending style at start */
|
|
3557
|
+
startStyle?: LineEndingStyle;
|
|
3558
|
+
/** Line ending style at end */
|
|
3559
|
+
endStyle?: LineEndingStyle;
|
|
3560
|
+
/** Text content/comment */
|
|
3561
|
+
contents?: string;
|
|
3562
|
+
}
|
|
3563
|
+
/**
|
|
3564
|
+
* Options for creating a Stamp annotation.
|
|
3565
|
+
*/
|
|
3566
|
+
interface StampAnnotationOptions {
|
|
3567
|
+
/** Annotation rectangle */
|
|
3568
|
+
rect: Rect;
|
|
3569
|
+
/** Standard stamp name */
|
|
3570
|
+
name?: StampName | string;
|
|
3571
|
+
/** Text content/comment */
|
|
3572
|
+
contents?: string;
|
|
3573
|
+
}
|
|
3574
|
+
/**
|
|
3575
|
+
* Options for creating an Ink annotation.
|
|
3576
|
+
*/
|
|
3577
|
+
interface InkAnnotationOptions {
|
|
3578
|
+
/** Paths (array of point arrays) */
|
|
3579
|
+
paths: Point[][];
|
|
3580
|
+
/** Stroke color */
|
|
3581
|
+
color?: Color;
|
|
3582
|
+
/** Stroke width (default: 1) */
|
|
3583
|
+
width?: number;
|
|
3584
|
+
/** Text content/comment */
|
|
3585
|
+
contents?: string;
|
|
3586
|
+
}
|
|
3587
|
+
/**
|
|
3588
|
+
* Options for creating a Caret annotation.
|
|
3589
|
+
*/
|
|
3590
|
+
interface CaretAnnotationOptions {
|
|
3591
|
+
/** Annotation rectangle */
|
|
3592
|
+
rect: Rect;
|
|
3593
|
+
/** Symbol: "P" for paragraph, "None" */
|
|
3594
|
+
symbol?: "P" | "None";
|
|
3595
|
+
/** Text content/comment */
|
|
3596
|
+
contents?: string;
|
|
3597
|
+
/** Annotation color */
|
|
3598
|
+
color?: Color;
|
|
3599
|
+
}
|
|
3600
|
+
/**
|
|
3601
|
+
* Options for creating a Popup annotation (linked to another annotation).
|
|
3602
|
+
*/
|
|
3603
|
+
interface PopupOptions {
|
|
3604
|
+
/** Popup rectangle */
|
|
3605
|
+
rect: Rect;
|
|
3606
|
+
/** Initially open */
|
|
3607
|
+
open?: boolean;
|
|
3608
|
+
}
|
|
3609
|
+
/**
|
|
3610
|
+
* Options for removing annotations.
|
|
3611
|
+
*/
|
|
3612
|
+
interface RemoveAnnotationsOptions {
|
|
3613
|
+
/** Filter by annotation type */
|
|
3614
|
+
type?: AnnotationSubtype;
|
|
3615
|
+
}
|
|
3616
|
+
/**
|
|
3617
|
+
* Options for flattening annotations.
|
|
3618
|
+
*/
|
|
3619
|
+
interface FlattenAnnotationsOptions {
|
|
3620
|
+
/** Annotation types to exclude from flattening */
|
|
3621
|
+
exclude?: AnnotationSubtype[];
|
|
3622
|
+
}
|
|
3623
|
+
//#endregion
|
|
3624
|
+
//#region src/annotations/base.d.ts
|
|
3625
|
+
/**
|
|
3626
|
+
* Base class for PDF annotations.
|
|
3627
|
+
*/
|
|
3628
|
+
declare class PDFAnnotation {
|
|
3629
|
+
/** The underlying annotation dictionary */
|
|
3630
|
+
readonly dict: PdfDict;
|
|
3631
|
+
/** Reference to this annotation object */
|
|
3632
|
+
readonly ref: PdfRef | null;
|
|
3633
|
+
/** Object registry for change tracking */
|
|
3634
|
+
protected readonly registry: ObjectRegistry;
|
|
3635
|
+
/** Track if annotation has been modified */
|
|
3636
|
+
private _modified;
|
|
3637
|
+
constructor(dict: PdfDict, ref: PdfRef | null, registry: ObjectRegistry);
|
|
3638
|
+
/**
|
|
3639
|
+
* Annotation subtype (e.g., "Text", "Highlight", "Link").
|
|
3640
|
+
*/
|
|
3641
|
+
get type(): AnnotationSubtype;
|
|
3642
|
+
/**
|
|
3643
|
+
* Annotation rectangle in page coordinates.
|
|
3644
|
+
*/
|
|
3645
|
+
get rect(): Rect;
|
|
3646
|
+
/**
|
|
3647
|
+
* Set the annotation rectangle.
|
|
3648
|
+
*/
|
|
3649
|
+
setRect(rect: Rect): void;
|
|
3650
|
+
/**
|
|
3651
|
+
* Text content or description of the annotation.
|
|
3652
|
+
*/
|
|
3653
|
+
get contents(): string | null;
|
|
3654
|
+
/**
|
|
3655
|
+
* Set the annotation contents.
|
|
3656
|
+
*/
|
|
3657
|
+
setContents(contents: string): void;
|
|
3658
|
+
/**
|
|
3659
|
+
* Annotation name (unique identifier within page).
|
|
3660
|
+
*/
|
|
3661
|
+
get name(): string | null;
|
|
3662
|
+
/**
|
|
3663
|
+
* Set the annotation name.
|
|
3664
|
+
*/
|
|
3665
|
+
setName(name: string): void;
|
|
3666
|
+
/**
|
|
3667
|
+
* Modification date.
|
|
3668
|
+
*/
|
|
3669
|
+
get modificationDate(): string | null;
|
|
3670
|
+
/**
|
|
3671
|
+
* Set the modification date (PDF date format).
|
|
3672
|
+
*/
|
|
3673
|
+
setModificationDate(date: string): void;
|
|
3674
|
+
/**
|
|
3675
|
+
* Annotation flags.
|
|
3676
|
+
*/
|
|
3677
|
+
get flags(): number;
|
|
3678
|
+
/**
|
|
3679
|
+
* Check if the annotation has a specific flag set.
|
|
3680
|
+
*/
|
|
3681
|
+
hasFlag(flag: AnnotationFlags): boolean;
|
|
3682
|
+
/**
|
|
3683
|
+
* Set or clear a specific flag.
|
|
3684
|
+
*/
|
|
3685
|
+
setFlag(flag: AnnotationFlags, value: boolean): void;
|
|
3686
|
+
/**
|
|
3687
|
+
* Whether the annotation is hidden.
|
|
3688
|
+
*/
|
|
3689
|
+
get isHidden(): boolean;
|
|
3690
|
+
/**
|
|
3691
|
+
* Set whether the annotation is hidden.
|
|
3692
|
+
*/
|
|
3693
|
+
setHidden(hidden: boolean): void;
|
|
3694
|
+
/**
|
|
3695
|
+
* Whether the annotation is printable.
|
|
3696
|
+
*/
|
|
3697
|
+
get isPrintable(): boolean;
|
|
3698
|
+
/**
|
|
3699
|
+
* Set whether the annotation is printable.
|
|
3700
|
+
*/
|
|
3701
|
+
setPrintable(printable: boolean): void;
|
|
3702
|
+
/**
|
|
3703
|
+
* Annotation color.
|
|
3704
|
+
*/
|
|
3705
|
+
get color(): Color | null;
|
|
3706
|
+
/**
|
|
3707
|
+
* Set the annotation color.
|
|
3708
|
+
*/
|
|
3709
|
+
setColor(color: Color): void;
|
|
3710
|
+
/**
|
|
3711
|
+
* Get the border style.
|
|
3712
|
+
*/
|
|
3713
|
+
getBorderStyle(): BorderStyle | null;
|
|
3714
|
+
/**
|
|
3715
|
+
* Set the border style.
|
|
3716
|
+
*/
|
|
3717
|
+
setBorderStyle(style: BorderStyle): void;
|
|
3718
|
+
/**
|
|
3719
|
+
* Check if the annotation has a normal appearance stream.
|
|
3720
|
+
*/
|
|
3721
|
+
hasNormalAppearance(): boolean;
|
|
3722
|
+
/**
|
|
3723
|
+
* Get the normal appearance stream.
|
|
3724
|
+
*/
|
|
3725
|
+
getNormalAppearance(): Promise<PdfStream | null>;
|
|
3726
|
+
/**
|
|
3727
|
+
* Get the rollover appearance stream.
|
|
3728
|
+
*/
|
|
3729
|
+
getRolloverAppearance(): Promise<PdfStream | null>;
|
|
3730
|
+
/**
|
|
3731
|
+
* Get the down appearance stream.
|
|
3732
|
+
*/
|
|
3733
|
+
getDownAppearance(): Promise<PdfStream | null>;
|
|
3734
|
+
/**
|
|
3735
|
+
* Set the normal appearance stream.
|
|
3736
|
+
*/
|
|
3737
|
+
setNormalAppearance(stream: PdfStream): void;
|
|
3738
|
+
/**
|
|
3739
|
+
* Set the rollover appearance stream.
|
|
3740
|
+
*/
|
|
3741
|
+
setRolloverAppearance(stream: PdfStream): void;
|
|
3742
|
+
/**
|
|
3743
|
+
* Set the down appearance stream.
|
|
3744
|
+
*/
|
|
3745
|
+
setDownAppearance(stream: PdfStream): void;
|
|
3746
|
+
/**
|
|
3747
|
+
* Get an appearance stream by type.
|
|
3748
|
+
*/
|
|
3749
|
+
private getAppearance;
|
|
3750
|
+
/**
|
|
3751
|
+
* Set an appearance stream by type.
|
|
3752
|
+
*/
|
|
3753
|
+
private setAppearance;
|
|
3754
|
+
/**
|
|
3755
|
+
* Mark the annotation as modified.
|
|
3756
|
+
* Called automatically by setters.
|
|
3757
|
+
* Note: The dict's dirty flag is set automatically by PdfDict operations.
|
|
3758
|
+
*/
|
|
3759
|
+
protected markModified(): void;
|
|
3760
|
+
/**
|
|
3761
|
+
* Check if the annotation has been modified.
|
|
3762
|
+
*/
|
|
3763
|
+
get isModified(): boolean;
|
|
3764
|
+
}
|
|
3765
|
+
//#endregion
|
|
3766
|
+
//#region src/annotations/popup.d.ts
|
|
3767
|
+
/**
|
|
3768
|
+
* Popup annotation - displays text in a pop-up window.
|
|
3769
|
+
*/
|
|
3770
|
+
declare class PDFPopupAnnotation extends PDFAnnotation {
|
|
3771
|
+
/**
|
|
3772
|
+
* Reference to the parent annotation that this popup is associated with.
|
|
3773
|
+
*/
|
|
3774
|
+
get parentRef(): PdfRef | null;
|
|
3775
|
+
/**
|
|
3776
|
+
* Whether the popup is initially open.
|
|
3777
|
+
*/
|
|
3778
|
+
get isOpen(): boolean;
|
|
3779
|
+
/**
|
|
3780
|
+
* Set whether the popup is open.
|
|
3781
|
+
*/
|
|
3782
|
+
setOpen(open: boolean): void;
|
|
3783
|
+
}
|
|
3784
|
+
//#endregion
|
|
3785
|
+
//#region src/annotations/markup.d.ts
|
|
3786
|
+
/**
|
|
3787
|
+
* Base class for markup annotations.
|
|
3788
|
+
*/
|
|
3789
|
+
declare class PDFMarkupAnnotation extends PDFAnnotation {
|
|
3790
|
+
/** Cached popup annotation */
|
|
3791
|
+
private _popup;
|
|
3792
|
+
/**
|
|
3793
|
+
* Text label for the annotation (often the author name).
|
|
3794
|
+
*/
|
|
3795
|
+
get title(): string | null;
|
|
3796
|
+
/**
|
|
3797
|
+
* Set the title/author.
|
|
3798
|
+
*/
|
|
3799
|
+
setTitle(title: string): void;
|
|
3800
|
+
/**
|
|
3801
|
+
* Opacity (CA) - constant opacity value for the annotation.
|
|
3802
|
+
* Range 0-1, where 0 is fully transparent and 1 is fully opaque.
|
|
3803
|
+
*/
|
|
3804
|
+
get opacity(): number;
|
|
3805
|
+
/**
|
|
3806
|
+
* Set the opacity.
|
|
3807
|
+
*/
|
|
3808
|
+
setOpacity(opacity: number): void;
|
|
3809
|
+
/**
|
|
3810
|
+
* Creation date (CreationDate).
|
|
3811
|
+
*/
|
|
3812
|
+
get creationDate(): string | null;
|
|
3813
|
+
/**
|
|
3814
|
+
* Set the creation date.
|
|
3815
|
+
*/
|
|
3816
|
+
setCreationDate(date: string): void;
|
|
3817
|
+
/**
|
|
3818
|
+
* Subject - the subject of the annotation.
|
|
3819
|
+
*/
|
|
3820
|
+
get subject(): string | null;
|
|
3821
|
+
/**
|
|
3822
|
+
* Set the subject.
|
|
3823
|
+
*/
|
|
3824
|
+
setSubject(subject: string): void;
|
|
3825
|
+
/**
|
|
3826
|
+
* Reference to an associated popup annotation.
|
|
3827
|
+
*/
|
|
3828
|
+
get popupRef(): PdfRef | null;
|
|
3829
|
+
/**
|
|
3830
|
+
* Get the associated popup annotation, if any.
|
|
3831
|
+
*/
|
|
3832
|
+
getPopup(): Promise<PDFPopupAnnotation | null>;
|
|
3833
|
+
/**
|
|
3834
|
+
* Create a popup annotation associated with this annotation.
|
|
3835
|
+
* The popup is added to the parent annotation and registered.
|
|
3836
|
+
*/
|
|
3837
|
+
createPopup(options: PopupOptions): PDFPopupAnnotation;
|
|
3838
|
+
/**
|
|
3839
|
+
* Get the reply-to annotation reference (for replies).
|
|
3840
|
+
*/
|
|
3841
|
+
get inReplyToRef(): PdfRef | null;
|
|
3842
|
+
/**
|
|
3843
|
+
* Intent (IT) - the intent of the markup annotation.
|
|
3844
|
+
*/
|
|
3845
|
+
get intent(): string | null;
|
|
3846
|
+
}
|
|
3847
|
+
//#endregion
|
|
3848
|
+
//#region src/annotations/caret.d.ts
|
|
3849
|
+
/**
|
|
3850
|
+
* Caret symbol types.
|
|
3851
|
+
*/
|
|
3852
|
+
type CaretSymbol = "P" | "None";
|
|
3853
|
+
/**
|
|
3854
|
+
* Caret annotation - insertion point marker.
|
|
3855
|
+
*/
|
|
3856
|
+
declare class PDFCaretAnnotation extends PDFMarkupAnnotation {
|
|
3857
|
+
/**
|
|
3858
|
+
* Symbol to display.
|
|
3859
|
+
* "P" = paragraph symbol, "None" = no symbol.
|
|
3860
|
+
*/
|
|
3861
|
+
get symbol(): CaretSymbol;
|
|
3862
|
+
/**
|
|
3863
|
+
* Set the symbol.
|
|
3864
|
+
*/
|
|
3865
|
+
setSymbol(symbol: CaretSymbol): void;
|
|
3866
|
+
}
|
|
3867
|
+
//#endregion
|
|
3868
|
+
//#region src/annotations/file-attachment.d.ts
|
|
3869
|
+
/**
|
|
3870
|
+
* File attachment annotation - embedded file icon.
|
|
3871
|
+
*/
|
|
3872
|
+
declare class PDFFileAttachmentAnnotation extends PDFMarkupAnnotation {
|
|
3873
|
+
/**
|
|
3874
|
+
* Icon to display.
|
|
3875
|
+
*/
|
|
3876
|
+
get icon(): FileAttachmentIcon;
|
|
3877
|
+
/**
|
|
3878
|
+
* Set the icon.
|
|
3879
|
+
*/
|
|
3880
|
+
setIcon(icon: FileAttachmentIcon): void;
|
|
3881
|
+
/**
|
|
3882
|
+
* Reference to the file specification.
|
|
3883
|
+
*/
|
|
3884
|
+
get fileSpecRef(): PdfRef | null;
|
|
3885
|
+
/**
|
|
3886
|
+
* Get the file specification dictionary.
|
|
3887
|
+
*/
|
|
3888
|
+
getFileSpec(): Promise<PdfDict | null>;
|
|
3889
|
+
/**
|
|
3890
|
+
* Get the file name from the file specification.
|
|
3891
|
+
*/
|
|
3892
|
+
getFileName(): Promise<string | null>;
|
|
3893
|
+
}
|
|
3894
|
+
//#endregion
|
|
3895
|
+
//#region src/annotations/free-text.d.ts
|
|
3896
|
+
/**
|
|
3897
|
+
* Text justification for FreeText annotations.
|
|
3898
|
+
*/
|
|
3899
|
+
type FreeTextJustification = "left" | "center" | "right";
|
|
3900
|
+
/**
|
|
3901
|
+
* FreeText annotation - text box displayed on page.
|
|
3902
|
+
*/
|
|
3903
|
+
declare class PDFFreeTextAnnotation extends PDFMarkupAnnotation {
|
|
3904
|
+
/**
|
|
3905
|
+
* Default appearance string (DA).
|
|
3906
|
+
* Contains font and color operators.
|
|
3907
|
+
*/
|
|
3908
|
+
get defaultAppearance(): string | null;
|
|
3909
|
+
/**
|
|
3910
|
+
* Set the default appearance.
|
|
3911
|
+
*/
|
|
3912
|
+
setDefaultAppearance(da: string): void;
|
|
3913
|
+
/**
|
|
3914
|
+
* Text justification: 0=left, 1=center, 2=right.
|
|
3915
|
+
*/
|
|
3916
|
+
get justification(): FreeTextJustification;
|
|
3917
|
+
/**
|
|
3918
|
+
* Set the text justification.
|
|
3919
|
+
*/
|
|
3920
|
+
setJustification(justification: FreeTextJustification): void;
|
|
3921
|
+
/**
|
|
3922
|
+
* Default style string (DS).
|
|
3923
|
+
* Contains CSS-style formatting.
|
|
3924
|
+
*/
|
|
3925
|
+
get defaultStyle(): string | null;
|
|
3926
|
+
/**
|
|
3927
|
+
* Set the default style.
|
|
3928
|
+
*/
|
|
3929
|
+
setDefaultStyle(ds: string): void;
|
|
3930
|
+
/**
|
|
3931
|
+
* Intent (IT) - specific to FreeText annotations.
|
|
3932
|
+
* Can be "FreeText", "FreeTextCallout", or "FreeTextTypeWriter".
|
|
3933
|
+
*/
|
|
3934
|
+
get freeTextIntent(): string | null;
|
|
3935
|
+
/**
|
|
3936
|
+
* Set the intent.
|
|
3937
|
+
*/
|
|
3938
|
+
setFreeTextIntent(intent: "FreeText" | "FreeTextCallout" | "FreeTextTypeWriter"): void;
|
|
3939
|
+
}
|
|
3940
|
+
//#endregion
|
|
3941
|
+
//#region src/annotations/ink.d.ts
|
|
3942
|
+
/**
|
|
3943
|
+
* Ink annotation - freehand drawing.
|
|
3944
|
+
*/
|
|
3945
|
+
declare class PDFInkAnnotation extends PDFMarkupAnnotation {
|
|
3946
|
+
/**
|
|
3947
|
+
* Create a new ink annotation dictionary.
|
|
3948
|
+
*/
|
|
3949
|
+
static create(options: InkAnnotationOptions): PdfDict;
|
|
3950
|
+
/**
|
|
3951
|
+
* Get the ink paths.
|
|
3952
|
+
* Each path is an array of points.
|
|
3953
|
+
*/
|
|
3954
|
+
get inkPaths(): Point[][];
|
|
3955
|
+
/**
|
|
3956
|
+
* Set the ink paths.
|
|
3957
|
+
*/
|
|
3958
|
+
setInkPaths(paths: Point[][]): void;
|
|
3959
|
+
/**
|
|
3960
|
+
* Stroke width from border style.
|
|
3961
|
+
*/
|
|
3962
|
+
get strokeWidth(): number;
|
|
3963
|
+
}
|
|
3964
|
+
//#endregion
|
|
3965
|
+
//#region src/annotations/line.d.ts
|
|
3966
|
+
/**
|
|
3967
|
+
* Line annotation - a line with optional arrow endings.
|
|
3968
|
+
*/
|
|
3969
|
+
declare class PDFLineAnnotation extends PDFMarkupAnnotation {
|
|
3970
|
+
/**
|
|
3971
|
+
* Create a new line annotation dictionary.
|
|
3972
|
+
*/
|
|
3973
|
+
static create(options: LineAnnotationOptions): PdfDict;
|
|
3974
|
+
/**
|
|
3975
|
+
* Get the line endpoints.
|
|
3976
|
+
*/
|
|
3977
|
+
get lineEndpoints(): {
|
|
3978
|
+
start: Point;
|
|
3979
|
+
end: Point;
|
|
3980
|
+
};
|
|
3981
|
+
/**
|
|
3982
|
+
* Set the line endpoints.
|
|
3983
|
+
*/
|
|
3984
|
+
setLineEndpoints(start: Point, end: Point): void;
|
|
3985
|
+
/**
|
|
3986
|
+
* Get the start point.
|
|
3987
|
+
*/
|
|
3988
|
+
get start(): Point;
|
|
3989
|
+
/**
|
|
3990
|
+
* Get the end point.
|
|
3991
|
+
*/
|
|
3992
|
+
get end(): Point;
|
|
3993
|
+
/**
|
|
3994
|
+
* Line ending styles [start, end].
|
|
3995
|
+
*/
|
|
3996
|
+
get lineEndingStyles(): [LineEndingStyle, LineEndingStyle];
|
|
3997
|
+
/**
|
|
3998
|
+
* Set the line ending styles.
|
|
3999
|
+
*/
|
|
4000
|
+
setLineEndingStyles(startStyle: LineEndingStyle, endStyle: LineEndingStyle): void;
|
|
4001
|
+
/**
|
|
4002
|
+
* Interior color (fill color for closed arrow heads).
|
|
4003
|
+
*/
|
|
4004
|
+
get interiorColor(): Color | null;
|
|
4005
|
+
/**
|
|
4006
|
+
* Set the interior color.
|
|
4007
|
+
*/
|
|
4008
|
+
setInteriorColor(color: Color): void;
|
|
4009
|
+
/**
|
|
4010
|
+
* Line leader length (for dimension lines).
|
|
4011
|
+
*/
|
|
4012
|
+
get leaderLength(): number;
|
|
4013
|
+
/**
|
|
4014
|
+
* Line leader line extension.
|
|
4015
|
+
*/
|
|
4016
|
+
get leaderExtension(): number;
|
|
4017
|
+
/**
|
|
4018
|
+
* Caption flag - whether to show caption with the line.
|
|
4019
|
+
*/
|
|
4020
|
+
get hasCaption(): boolean;
|
|
4021
|
+
/**
|
|
4022
|
+
* Line width from border style.
|
|
4023
|
+
*/
|
|
4024
|
+
get lineWidth(): number;
|
|
4025
|
+
}
|
|
4026
|
+
//#endregion
|
|
4027
|
+
//#region src/annotations/link.d.ts
|
|
4028
|
+
/**
|
|
4029
|
+
* Parsed link action.
|
|
4030
|
+
*/
|
|
4031
|
+
type LinkAction = {
|
|
4032
|
+
type: "uri";
|
|
4033
|
+
uri: string;
|
|
4034
|
+
} | {
|
|
4035
|
+
type: "goto";
|
|
4036
|
+
destination: LinkDestination;
|
|
4037
|
+
} | {
|
|
4038
|
+
type: "gotoRemote";
|
|
4039
|
+
file: string;
|
|
4040
|
+
destination: LinkDestination | null;
|
|
4041
|
+
} | null;
|
|
4042
|
+
/**
|
|
4043
|
+
* Highlight mode for link annotations.
|
|
4044
|
+
*/
|
|
4045
|
+
type HighlightMode = "None" | "Invert" | "Outline" | "Push";
|
|
4046
|
+
/**
|
|
4047
|
+
* Link annotation - hyperlinks and internal navigation.
|
|
4048
|
+
*/
|
|
4049
|
+
declare class PDFLinkAnnotation extends PDFAnnotation {
|
|
4050
|
+
/**
|
|
4051
|
+
* Create a new link annotation dictionary.
|
|
4052
|
+
*/
|
|
4053
|
+
static create(options: LinkAnnotationOptions): PdfDict;
|
|
4054
|
+
/**
|
|
4055
|
+
* Get the URI if this is an external link.
|
|
4056
|
+
*/
|
|
4057
|
+
get uri(): string | null;
|
|
4058
|
+
/**
|
|
4059
|
+
* Get the destination if this is an internal link.
|
|
4060
|
+
*/
|
|
4061
|
+
get destination(): LinkDestination | null;
|
|
4062
|
+
/**
|
|
4063
|
+
* Get the parsed link action.
|
|
4064
|
+
*/
|
|
4065
|
+
getAction(): Promise<LinkAction>;
|
|
4066
|
+
/**
|
|
4067
|
+
* Highlight mode when the link is clicked.
|
|
4068
|
+
*/
|
|
4069
|
+
get highlightMode(): HighlightMode;
|
|
4070
|
+
/**
|
|
4071
|
+
* Parse a destination value.
|
|
4072
|
+
*/
|
|
4073
|
+
private parseDestination;
|
|
4074
|
+
}
|
|
4075
|
+
//#endregion
|
|
4076
|
+
//#region src/annotations/polygon.d.ts
|
|
4077
|
+
/**
|
|
4078
|
+
* Base class for Polygon and Polyline annotations.
|
|
4079
|
+
*/
|
|
4080
|
+
declare abstract class PDFPolyAnnotation extends PDFMarkupAnnotation {
|
|
4081
|
+
/**
|
|
4082
|
+
* Get the vertices of the polygon/polyline.
|
|
4083
|
+
*/
|
|
4084
|
+
get vertices(): Point[];
|
|
4085
|
+
/**
|
|
4086
|
+
* Set the vertices.
|
|
4087
|
+
*/
|
|
4088
|
+
setVertices(vertices: Point[]): void;
|
|
4089
|
+
/**
|
|
4090
|
+
* Border width from border style.
|
|
4091
|
+
*/
|
|
4092
|
+
get borderWidth(): number;
|
|
4093
|
+
}
|
|
4094
|
+
/**
|
|
4095
|
+
* Polygon annotation - closed polygon shape.
|
|
4096
|
+
*/
|
|
4097
|
+
declare class PDFPolygonAnnotation extends PDFPolyAnnotation {
|
|
4098
|
+
/**
|
|
4099
|
+
* Interior color (fill color).
|
|
4100
|
+
*/
|
|
4101
|
+
get interiorColor(): Color | null;
|
|
4102
|
+
/**
|
|
4103
|
+
* Set the interior color.
|
|
4104
|
+
*/
|
|
4105
|
+
setInteriorColor(color: Color): void;
|
|
4106
|
+
/**
|
|
4107
|
+
* Intent - specific to polygon annotations.
|
|
4108
|
+
* Can be "PolygonCloud" or "PolygonDimension".
|
|
4109
|
+
*/
|
|
4110
|
+
get polygonIntent(): string | null;
|
|
4111
|
+
}
|
|
4112
|
+
/**
|
|
4113
|
+
* Polyline annotation - open polyline shape.
|
|
4114
|
+
*/
|
|
4115
|
+
declare class PDFPolylineAnnotation extends PDFPolyAnnotation {
|
|
4116
|
+
/**
|
|
4117
|
+
* Line ending styles [start, end].
|
|
4118
|
+
*/
|
|
4119
|
+
get lineEndingStyles(): [LineEndingStyle, LineEndingStyle];
|
|
4120
|
+
/**
|
|
4121
|
+
* Set the line ending styles.
|
|
4122
|
+
*/
|
|
4123
|
+
setLineEndingStyles(startStyle: LineEndingStyle, endStyle: LineEndingStyle): void;
|
|
4124
|
+
/**
|
|
4125
|
+
* Intent - specific to polyline annotations.
|
|
4126
|
+
* Can be "PolyLineDimension".
|
|
4127
|
+
*/
|
|
4128
|
+
get polylineIntent(): string | null;
|
|
4129
|
+
}
|
|
4130
|
+
//#endregion
|
|
4131
|
+
//#region src/annotations/square-circle.d.ts
|
|
4132
|
+
/**
|
|
4133
|
+
* Base class for square and circle annotations.
|
|
4134
|
+
*/
|
|
4135
|
+
declare abstract class PDFShapeAnnotation extends PDFMarkupAnnotation {
|
|
4136
|
+
/**
|
|
4137
|
+
* Interior color (fill color).
|
|
4138
|
+
*/
|
|
4139
|
+
get interiorColor(): Color | null;
|
|
4140
|
+
/**
|
|
4141
|
+
* Set the interior color.
|
|
4142
|
+
*/
|
|
4143
|
+
setInteriorColor(color: Color): void;
|
|
4144
|
+
/**
|
|
4145
|
+
* Rectangle difference (RD) - inset of the drawing from the Rect.
|
|
4146
|
+
* [left, bottom, right, top] offsets.
|
|
4147
|
+
*/
|
|
4148
|
+
get rectDifference(): [number, number, number, number] | null;
|
|
4149
|
+
/**
|
|
4150
|
+
* Get the actual drawing rectangle (Rect minus RD).
|
|
4151
|
+
*/
|
|
4152
|
+
getDrawingRect(): Rect;
|
|
4153
|
+
/**
|
|
4154
|
+
* Border width from border style.
|
|
4155
|
+
*/
|
|
4156
|
+
get borderWidth(): number;
|
|
4157
|
+
}
|
|
4158
|
+
/**
|
|
4159
|
+
* Square annotation - rectangle shape.
|
|
4160
|
+
*/
|
|
4161
|
+
declare class PDFSquareAnnotation extends PDFShapeAnnotation {
|
|
4162
|
+
/**
|
|
4163
|
+
* Create a new square annotation dictionary.
|
|
4164
|
+
*/
|
|
4165
|
+
static create(options: SquareAnnotationOptions): PdfDict;
|
|
4166
|
+
}
|
|
4167
|
+
/**
|
|
4168
|
+
* Circle annotation - ellipse shape.
|
|
4169
|
+
*/
|
|
4170
|
+
declare class PDFCircleAnnotation extends PDFShapeAnnotation {
|
|
4171
|
+
/**
|
|
4172
|
+
* Create a new circle annotation dictionary.
|
|
4173
|
+
*/
|
|
4174
|
+
static create(options: CircleAnnotationOptions): PdfDict;
|
|
4175
|
+
}
|
|
4176
|
+
//#endregion
|
|
4177
|
+
//#region src/annotations/stamp.d.ts
|
|
4178
|
+
/**
|
|
4179
|
+
* Standard stamp names as defined in PDF spec.
|
|
4180
|
+
*/
|
|
4181
|
+
declare const STANDARD_STAMPS: StampName[];
|
|
4182
|
+
/**
|
|
4183
|
+
* Stamp annotation - rubber stamp.
|
|
4184
|
+
*/
|
|
4185
|
+
declare class PDFStampAnnotation extends PDFMarkupAnnotation {
|
|
4186
|
+
/**
|
|
4187
|
+
* Create a new stamp annotation dictionary.
|
|
4188
|
+
*/
|
|
4189
|
+
static create(options: StampAnnotationOptions): PdfDict;
|
|
4190
|
+
/**
|
|
4191
|
+
* Stamp name/type.
|
|
4192
|
+
*/
|
|
4193
|
+
get stampName(): string;
|
|
4194
|
+
/**
|
|
4195
|
+
* Set the stamp name.
|
|
4196
|
+
*/
|
|
4197
|
+
setStampName(name: StampName | string): void;
|
|
4198
|
+
/**
|
|
4199
|
+
* Check if this is a standard stamp.
|
|
4200
|
+
*/
|
|
4201
|
+
isStandardStamp(): boolean;
|
|
3006
4202
|
}
|
|
3007
4203
|
//#endregion
|
|
3008
|
-
//#region src/
|
|
4204
|
+
//#region src/annotations/text.d.ts
|
|
3009
4205
|
/**
|
|
3010
|
-
*
|
|
3011
|
-
* Synchronous because refs are pre-allocated when fonts are embedded.
|
|
4206
|
+
* Text annotation state (for review workflows).
|
|
3012
4207
|
*/
|
|
3013
|
-
type
|
|
4208
|
+
type TextAnnotationState = "Marked" | "Unmarked" | "Accepted" | "Rejected" | "Cancelled" | "Completed" | "None";
|
|
3014
4209
|
/**
|
|
3015
|
-
*
|
|
4210
|
+
* Text annotation state model.
|
|
3016
4211
|
*/
|
|
3017
|
-
|
|
3018
|
-
/** PDF version (e.g., "1.7", "2.0") */
|
|
3019
|
-
version: string;
|
|
3020
|
-
/** Whether the document is encrypted */
|
|
3021
|
-
isEncrypted: boolean;
|
|
3022
|
-
/** Whether authentication succeeded */
|
|
3023
|
-
isAuthenticated: boolean;
|
|
3024
|
-
/** Trailer dictionary */
|
|
3025
|
-
trailer: PdfDict;
|
|
3026
|
-
/** Security handler (if encrypted) */
|
|
3027
|
-
securityHandler: StandardSecurityHandler | null;
|
|
3028
|
-
}
|
|
4212
|
+
type TextAnnotationStateModel = "Marked" | "Review";
|
|
3029
4213
|
/**
|
|
3030
|
-
*
|
|
3031
|
-
*
|
|
3032
|
-
* Encapsulates all the shared state and services that subsystems need:
|
|
3033
|
-
* - Object registry for tracking and resolving objects
|
|
3034
|
-
* - Catalog for document-level structures
|
|
3035
|
-
* - Page tree for page access
|
|
3036
|
-
* - Document info (version, encryption status, trailer)
|
|
4214
|
+
* Text annotation - sticky note/comment.
|
|
3037
4215
|
*/
|
|
3038
|
-
declare class
|
|
3039
|
-
/** Object registry for tracking refs and objects */
|
|
3040
|
-
readonly registry: ObjectRegistry;
|
|
3041
|
-
/** Document catalog wrapper */
|
|
3042
|
-
readonly catalog: PDFCatalog;
|
|
3043
|
-
/** Page tree for page access and manipulation */
|
|
3044
|
-
readonly pages: PDFPageTree;
|
|
3045
|
-
/** Document metadata */
|
|
3046
|
-
readonly info: DocumentInfo;
|
|
3047
|
-
/** Font reference resolver (set by PDF class) */
|
|
3048
|
-
private fontRefResolver;
|
|
3049
|
-
constructor(registry: ObjectRegistry, catalog: PDFCatalog, pages: PDFPageTree, info: DocumentInfo);
|
|
4216
|
+
declare class PDFTextAnnotation extends PDFMarkupAnnotation {
|
|
3050
4217
|
/**
|
|
3051
|
-
*
|
|
3052
|
-
* @internal Called by PDF class to wire up font resolution.
|
|
4218
|
+
* Create a new text annotation dictionary.
|
|
3053
4219
|
*/
|
|
3054
|
-
|
|
4220
|
+
static create(options: TextAnnotationOptions): PdfDict;
|
|
3055
4221
|
/**
|
|
3056
|
-
*
|
|
3057
|
-
*
|
|
3058
|
-
* The reference is available immediately because refs are pre-allocated
|
|
3059
|
-
* when fonts are embedded. Actual font objects are created at save time.
|
|
4222
|
+
* Whether the annotation popup is initially open.
|
|
3060
4223
|
*/
|
|
3061
|
-
|
|
4224
|
+
get isOpen(): boolean;
|
|
3062
4225
|
/**
|
|
3063
|
-
*
|
|
4226
|
+
* Set whether the popup is initially open.
|
|
3064
4227
|
*/
|
|
3065
|
-
|
|
4228
|
+
setOpen(open: boolean): void;
|
|
3066
4229
|
/**
|
|
3067
|
-
*
|
|
4230
|
+
* Icon name to display.
|
|
3068
4231
|
*/
|
|
3069
|
-
|
|
4232
|
+
get icon(): TextAnnotationIcon;
|
|
3070
4233
|
/**
|
|
3071
|
-
*
|
|
4234
|
+
* Set the icon to display.
|
|
3072
4235
|
*/
|
|
3073
|
-
|
|
4236
|
+
setIcon(icon: TextAnnotationIcon): void;
|
|
3074
4237
|
/**
|
|
3075
|
-
*
|
|
4238
|
+
* State of the annotation (for review workflows).
|
|
3076
4239
|
*/
|
|
3077
|
-
|
|
4240
|
+
get state(): TextAnnotationState | null;
|
|
3078
4241
|
/**
|
|
3079
|
-
*
|
|
4242
|
+
* Set the annotation state.
|
|
3080
4243
|
*/
|
|
3081
|
-
|
|
4244
|
+
setState(state: TextAnnotationState): void;
|
|
3082
4245
|
/**
|
|
3083
|
-
*
|
|
4246
|
+
* State model for the annotation.
|
|
3084
4247
|
*/
|
|
3085
|
-
get
|
|
4248
|
+
get stateModel(): TextAnnotationStateModel | null;
|
|
4249
|
+
/**
|
|
4250
|
+
* Set the state model.
|
|
4251
|
+
*/
|
|
4252
|
+
setStateModel(model: TextAnnotationStateModel): void;
|
|
3086
4253
|
}
|
|
3087
4254
|
//#endregion
|
|
3088
|
-
//#region src/
|
|
4255
|
+
//#region src/annotations/text-markup.d.ts
|
|
3089
4256
|
/**
|
|
3090
|
-
*
|
|
4257
|
+
* Base class for text markup annotations (Highlight, Underline, StrikeOut, Squiggly).
|
|
3091
4258
|
*/
|
|
3092
|
-
declare class
|
|
3093
|
-
/** PDF context */
|
|
3094
|
-
private readonly ctx;
|
|
3095
|
-
constructor(ctx: PDFContext);
|
|
4259
|
+
declare abstract class PDFTextMarkupAnnotation extends PDFMarkupAnnotation {
|
|
3096
4260
|
/**
|
|
3097
|
-
*
|
|
4261
|
+
* Get the raw QuadPoints as an array of quads.
|
|
4262
|
+
* Each quad is an array of 8 numbers [x1,y1, x2,y2, x3,y3, x4,y4].
|
|
3098
4263
|
*
|
|
3099
|
-
*
|
|
3100
|
-
*
|
|
3101
|
-
* @example
|
|
3102
|
-
* ```typescript
|
|
3103
|
-
* const attachments = await pdf.attachments.list();
|
|
3104
|
-
* for (const [name, info] of attachments) {
|
|
3105
|
-
* console.log(`${name}: ${info.size} bytes`);
|
|
3106
|
-
* }
|
|
3107
|
-
* ```
|
|
4264
|
+
* PDF spec order is: top-left, top-right, bottom-left, bottom-right
|
|
4265
|
+
* (counterclockwise from top-left of text baseline)
|
|
3108
4266
|
*/
|
|
3109
|
-
|
|
4267
|
+
get quadPoints(): number[][];
|
|
3110
4268
|
/**
|
|
3111
|
-
*
|
|
3112
|
-
*
|
|
3113
|
-
* @param name - The attachment name (key in the EmbeddedFiles tree)
|
|
3114
|
-
* @returns The attachment bytes, or null if not found
|
|
3115
|
-
*
|
|
3116
|
-
* @example
|
|
3117
|
-
* ```typescript
|
|
3118
|
-
* const data = await pdf.attachments.get("document.txt");
|
|
3119
|
-
* if (data) {
|
|
3120
|
-
* const text = new TextDecoder().decode(data);
|
|
3121
|
-
* console.log(text);
|
|
3122
|
-
* }
|
|
3123
|
-
* ```
|
|
4269
|
+
* Set the QuadPoints.
|
|
3124
4270
|
*/
|
|
3125
|
-
|
|
4271
|
+
setQuadPoints(quads: number[][]): void;
|
|
3126
4272
|
/**
|
|
3127
|
-
*
|
|
3128
|
-
*
|
|
3129
|
-
* @param name - The attachment name
|
|
3130
|
-
* @returns True if the attachment exists
|
|
3131
|
-
*
|
|
3132
|
-
* @example
|
|
3133
|
-
* ```typescript
|
|
3134
|
-
* if (await pdf.attachments.has("report.pdf")) {
|
|
3135
|
-
* const data = await pdf.attachments.get("report.pdf");
|
|
3136
|
-
* }
|
|
3137
|
-
* ```
|
|
4273
|
+
* Get the bounding box that encompasses all QuadPoints.
|
|
4274
|
+
* This is a convenience method for simple use cases.
|
|
3138
4275
|
*/
|
|
3139
|
-
|
|
4276
|
+
getBounds(): Rect;
|
|
3140
4277
|
/**
|
|
3141
|
-
*
|
|
3142
|
-
*
|
|
3143
|
-
* @param name - The attachment name (key in the EmbeddedFiles tree)
|
|
3144
|
-
* @param data - The file data
|
|
3145
|
-
* @param options - Attachment options (description, MIME type, dates)
|
|
3146
|
-
* @throws {Error} if name already exists and overwrite !== true
|
|
3147
|
-
*
|
|
3148
|
-
* @example
|
|
3149
|
-
* ```typescript
|
|
3150
|
-
* // Add with auto-detected MIME type
|
|
3151
|
-
* await pdf.attachments.add("report.pdf", pdfBytes);
|
|
3152
|
-
*
|
|
3153
|
-
* // Add with explicit options
|
|
3154
|
-
* await pdf.attachments.add("data.json", jsonBytes, {
|
|
3155
|
-
* description: "Configuration data",
|
|
3156
|
-
* mimeType: "application/json",
|
|
3157
|
-
* });
|
|
3158
|
-
*
|
|
3159
|
-
* // Replace existing attachment
|
|
3160
|
-
* await pdf.attachments.add("report.pdf", newBytes, { overwrite: true });
|
|
3161
|
-
* ```
|
|
4278
|
+
* Update the Rect entry to encompass all QuadPoints.
|
|
3162
4279
|
*/
|
|
3163
|
-
|
|
4280
|
+
private updateRectFromQuadPoints;
|
|
4281
|
+
}
|
|
4282
|
+
/**
|
|
4283
|
+
* Highlight annotation - yellow highlighter effect on text.
|
|
4284
|
+
*/
|
|
4285
|
+
declare class PDFHighlightAnnotation extends PDFTextMarkupAnnotation {
|
|
3164
4286
|
/**
|
|
3165
|
-
*
|
|
3166
|
-
*
|
|
3167
|
-
* @param name - The attachment name
|
|
3168
|
-
* @returns True if the attachment was removed, false if not found
|
|
3169
|
-
*
|
|
3170
|
-
* @example
|
|
3171
|
-
* ```typescript
|
|
3172
|
-
* const removed = await pdf.attachments.remove("old-file.txt");
|
|
3173
|
-
* if (removed) {
|
|
3174
|
-
* console.log("Attachment removed");
|
|
3175
|
-
* }
|
|
3176
|
-
* ```
|
|
4287
|
+
* Create a new highlight annotation dictionary.
|
|
3177
4288
|
*/
|
|
3178
|
-
|
|
4289
|
+
static create(options: TextMarkupAnnotationOptions): PdfDict;
|
|
4290
|
+
}
|
|
4291
|
+
/**
|
|
4292
|
+
* Underline annotation - line under text.
|
|
4293
|
+
*/
|
|
4294
|
+
declare class PDFUnderlineAnnotation extends PDFTextMarkupAnnotation {
|
|
4295
|
+
/**
|
|
4296
|
+
* Create a new underline annotation dictionary.
|
|
4297
|
+
*/
|
|
4298
|
+
static create(options: TextMarkupAnnotationOptions): PdfDict;
|
|
4299
|
+
}
|
|
4300
|
+
/**
|
|
4301
|
+
* StrikeOut annotation - line through text.
|
|
4302
|
+
*/
|
|
4303
|
+
declare class PDFStrikeOutAnnotation extends PDFTextMarkupAnnotation {
|
|
4304
|
+
/**
|
|
4305
|
+
* Create a new strikeout annotation dictionary.
|
|
4306
|
+
*/
|
|
4307
|
+
static create(options: TextMarkupAnnotationOptions): PdfDict;
|
|
3179
4308
|
}
|
|
4309
|
+
/**
|
|
4310
|
+
* Squiggly annotation - wavy underline.
|
|
4311
|
+
*/
|
|
4312
|
+
declare class PDFSquigglyAnnotation extends PDFTextMarkupAnnotation {
|
|
4313
|
+
/**
|
|
4314
|
+
* Create a new squiggly annotation dictionary.
|
|
4315
|
+
*/
|
|
4316
|
+
static create(options: TextMarkupAnnotationOptions): PdfDict;
|
|
4317
|
+
}
|
|
4318
|
+
/**
|
|
4319
|
+
* Convert a single rect to QuadPoints format.
|
|
4320
|
+
* Assumes horizontal text.
|
|
4321
|
+
*/
|
|
4322
|
+
declare function rectToQuadPoints(rect: Rect): number[];
|
|
4323
|
+
/**
|
|
4324
|
+
* Convert multiple rects to QuadPoints format.
|
|
4325
|
+
*/
|
|
4326
|
+
declare function rectsToQuadPoints(rects: Rect[]): number[][];
|
|
3180
4327
|
//#endregion
|
|
3181
4328
|
//#region src/fonts/encodings/encoding.d.ts
|
|
3182
4329
|
/**
|
|
@@ -3418,7 +4565,7 @@ interface AppearanceCharacteristics {
|
|
|
3418
4565
|
/**
|
|
3419
4566
|
* Border style from /BS dictionary.
|
|
3420
4567
|
*/
|
|
3421
|
-
interface BorderStyle {
|
|
4568
|
+
interface BorderStyle$1 {
|
|
3422
4569
|
/** Border width in points */
|
|
3423
4570
|
width: number;
|
|
3424
4571
|
/** Border style: S=solid, D=dashed, B=beveled, I=inset, U=underline */
|
|
@@ -3511,7 +4658,7 @@ declare class WidgetAnnotation {
|
|
|
3511
4658
|
/**
|
|
3512
4659
|
* Get border style.
|
|
3513
4660
|
*/
|
|
3514
|
-
getBorderStyle(): BorderStyle | null;
|
|
4661
|
+
getBorderStyle(): BorderStyle$1 | null;
|
|
3515
4662
|
/**
|
|
3516
4663
|
* Get appearance characteristics (/MK dictionary).
|
|
3517
4664
|
*/
|
|
@@ -4014,134 +5161,40 @@ declare class TextField extends TerminalField {
|
|
|
4014
5161
|
* Width tables are stored by glyph name (like pdf.js) which works
|
|
4015
5162
|
* with any encoding. Use getWidthByGlyphName() for lookup.
|
|
4016
5163
|
*
|
|
4017
|
-
* Widths are in glyph units (1000 units = 1 em).
|
|
4018
|
-
*
|
|
4019
|
-
* Data extracted from pdf.js metrics.js (Mozilla, Apache 2.0 License)
|
|
4020
|
-
*/
|
|
4021
|
-
/**
|
|
4022
|
-
* Standard 14 font names.
|
|
4023
|
-
*/
|
|
4024
|
-
declare const STANDARD_14_FONTS: readonly ["Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique", "Helvetica", "Helvetica-Bold", "Helvetica-Oblique", "Helvetica-BoldOblique", "Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic", "Symbol", "ZapfDingbats"];
|
|
4025
|
-
type Standard14FontName = (typeof STANDARD_14_FONTS)[number];
|
|
4026
|
-
/**
|
|
4027
|
-
* Standard 14 fonts enum for convenient access.
|
|
4028
|
-
*
|
|
4029
|
-
* @example
|
|
4030
|
-
* ```typescript
|
|
4031
|
-
* page.drawText("Hello", { font: StandardFonts.Helvetica });
|
|
4032
|
-
* page.drawText("Bold", { font: StandardFonts.HelveticaBold });
|
|
4033
|
-
* ```
|
|
4034
|
-
*/
|
|
4035
|
-
declare const StandardFonts: {
|
|
4036
|
-
readonly Helvetica: "Helvetica";
|
|
4037
|
-
readonly HelveticaBold: "Helvetica-Bold";
|
|
4038
|
-
readonly HelveticaOblique: "Helvetica-Oblique";
|
|
4039
|
-
readonly HelveticaBoldOblique: "Helvetica-BoldOblique";
|
|
4040
|
-
readonly TimesRoman: "Times-Roman";
|
|
4041
|
-
readonly TimesBold: "Times-Bold";
|
|
4042
|
-
readonly TimesItalic: "Times-Italic";
|
|
4043
|
-
readonly TimesBoldItalic: "Times-BoldItalic";
|
|
4044
|
-
readonly Courier: "Courier";
|
|
4045
|
-
readonly CourierBold: "Courier-Bold";
|
|
4046
|
-
readonly CourierOblique: "Courier-Oblique";
|
|
4047
|
-
readonly CourierBoldOblique: "Courier-BoldOblique";
|
|
4048
|
-
readonly Symbol: "Symbol";
|
|
4049
|
-
readonly ZapfDingbats: "ZapfDingbats";
|
|
4050
|
-
};
|
|
4051
|
-
//#endregion
|
|
4052
|
-
//#region src/helpers/colors.d.ts
|
|
4053
|
-
/**
|
|
4054
|
-
* Color types and helper functions for form fields.
|
|
4055
|
-
*
|
|
4056
|
-
* Provides RGB, Grayscale, and CMYK color types for use with form field styling.
|
|
4057
|
-
*/
|
|
4058
|
-
/**
|
|
4059
|
-
* RGB color with values in the 0-1 range.
|
|
4060
|
-
*/
|
|
4061
|
-
interface RGB {
|
|
4062
|
-
type: "RGB";
|
|
4063
|
-
red: number;
|
|
4064
|
-
green: number;
|
|
4065
|
-
blue: number;
|
|
4066
|
-
}
|
|
4067
|
-
/**
|
|
4068
|
-
* Grayscale color with value in the 0-1 range.
|
|
4069
|
-
* 0 = black, 1 = white.
|
|
4070
|
-
*/
|
|
4071
|
-
interface Grayscale {
|
|
4072
|
-
type: "Grayscale";
|
|
4073
|
-
gray: number;
|
|
4074
|
-
}
|
|
4075
|
-
/**
|
|
4076
|
-
* CMYK color with values in the 0-1 range.
|
|
4077
|
-
*/
|
|
4078
|
-
interface CMYK {
|
|
4079
|
-
type: "CMYK";
|
|
4080
|
-
cyan: number;
|
|
4081
|
-
magenta: number;
|
|
4082
|
-
yellow: number;
|
|
4083
|
-
black: number;
|
|
4084
|
-
}
|
|
4085
|
-
/**
|
|
4086
|
-
* Union type for all supported color types.
|
|
4087
|
-
*/
|
|
4088
|
-
type Color = RGB | Grayscale | CMYK;
|
|
4089
|
-
/**
|
|
4090
|
-
* Create an RGB color.
|
|
4091
|
-
*
|
|
4092
|
-
* @param r Red component (0-1)
|
|
4093
|
-
* @param g Green component (0-1)
|
|
4094
|
-
* @param b Blue component (0-1)
|
|
4095
|
-
* @returns RGB color object
|
|
4096
|
-
*
|
|
4097
|
-
* @example
|
|
4098
|
-
* ```typescript
|
|
4099
|
-
* const red = rgb(1, 0, 0);
|
|
4100
|
-
* const gray50 = rgb(0.5, 0.5, 0.5);
|
|
4101
|
-
* const cream = rgb(1, 1, 0.9);
|
|
4102
|
-
* ```
|
|
4103
|
-
*/
|
|
4104
|
-
declare function rgb(r: number, g: number, b: number): RGB;
|
|
4105
|
-
/**
|
|
4106
|
-
* Create a grayscale color.
|
|
4107
|
-
*
|
|
4108
|
-
* @param gray Gray value (0 = black, 1 = white)
|
|
4109
|
-
* @returns Grayscale color object
|
|
5164
|
+
* Widths are in glyph units (1000 units = 1 em).
|
|
4110
5165
|
*
|
|
4111
|
-
*
|
|
4112
|
-
* ```typescript
|
|
4113
|
-
* const black = grayscale(0);
|
|
4114
|
-
* const white = grayscale(1);
|
|
4115
|
-
* const midGray = grayscale(0.5);
|
|
4116
|
-
* ```
|
|
5166
|
+
* Data extracted from pdf.js metrics.js (Mozilla, Apache 2.0 License)
|
|
4117
5167
|
*/
|
|
4118
|
-
declare function grayscale(gray: number): Grayscale;
|
|
4119
5168
|
/**
|
|
4120
|
-
*
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
*
|
|
4126
|
-
* @returns CMYK color object
|
|
5169
|
+
* Standard 14 font names.
|
|
5170
|
+
*/
|
|
5171
|
+
declare const STANDARD_14_FONTS: readonly ["Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique", "Helvetica", "Helvetica-Bold", "Helvetica-Oblique", "Helvetica-BoldOblique", "Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic", "Symbol", "ZapfDingbats"];
|
|
5172
|
+
type Standard14FontName = (typeof STANDARD_14_FONTS)[number];
|
|
5173
|
+
/**
|
|
5174
|
+
* Standard 14 fonts enum for convenient access.
|
|
4127
5175
|
*
|
|
4128
5176
|
* @example
|
|
4129
5177
|
* ```typescript
|
|
4130
|
-
*
|
|
4131
|
-
*
|
|
5178
|
+
* page.drawText("Hello", { font: StandardFonts.Helvetica });
|
|
5179
|
+
* page.drawText("Bold", { font: StandardFonts.HelveticaBold });
|
|
4132
5180
|
* ```
|
|
4133
5181
|
*/
|
|
4134
|
-
declare
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
5182
|
+
declare const StandardFonts: {
|
|
5183
|
+
readonly Helvetica: "Helvetica";
|
|
5184
|
+
readonly HelveticaBold: "Helvetica-Bold";
|
|
5185
|
+
readonly HelveticaOblique: "Helvetica-Oblique";
|
|
5186
|
+
readonly HelveticaBoldOblique: "Helvetica-BoldOblique";
|
|
5187
|
+
readonly TimesRoman: "Times-Roman";
|
|
5188
|
+
readonly TimesBold: "Times-Bold";
|
|
5189
|
+
readonly TimesItalic: "Times-Italic";
|
|
5190
|
+
readonly TimesBoldItalic: "Times-BoldItalic";
|
|
5191
|
+
readonly Courier: "Courier";
|
|
5192
|
+
readonly CourierBold: "Courier-Bold";
|
|
5193
|
+
readonly CourierOblique: "Courier-Oblique";
|
|
5194
|
+
readonly CourierBoldOblique: "Courier-BoldOblique";
|
|
5195
|
+
readonly Symbol: "Symbol";
|
|
5196
|
+
readonly ZapfDingbats: "ZapfDingbats";
|
|
5197
|
+
};
|
|
4145
5198
|
//#endregion
|
|
4146
5199
|
//#region src/api/drawing/types.d.ts
|
|
4147
5200
|
/**
|
|
@@ -4699,10 +5752,6 @@ declare class PDFPage {
|
|
|
4699
5752
|
* Generate appearance stream for a widget.
|
|
4700
5753
|
*/
|
|
4701
5754
|
private generateWidgetAppearance;
|
|
4702
|
-
/**
|
|
4703
|
-
* Add an annotation reference to the page's /Annots array.
|
|
4704
|
-
*/
|
|
4705
|
-
private addAnnotation;
|
|
4706
5755
|
/**
|
|
4707
5756
|
* Draw a rectangle on the page.
|
|
4708
5757
|
*
|
|
@@ -4864,6 +5913,252 @@ declare class PDFPage {
|
|
|
4864
5913
|
* ```
|
|
4865
5914
|
*/
|
|
4866
5915
|
drawPath(): PathBuilder;
|
|
5916
|
+
/** Cached annotations for this page */
|
|
5917
|
+
private _annotationCache;
|
|
5918
|
+
/**
|
|
5919
|
+
* Get all annotations on this page (excludes Widget and Popup annotations).
|
|
5920
|
+
*
|
|
5921
|
+
* Widget annotations are handled by the forms subsystem via PDFForm.
|
|
5922
|
+
* Popup annotations are accessed via annotation.getPopup().
|
|
5923
|
+
*
|
|
5924
|
+
* Results are cached - repeated calls return the same instances.
|
|
5925
|
+
* The cache is invalidated when annotations are added or removed.
|
|
5926
|
+
*
|
|
5927
|
+
* @returns Array of annotation objects
|
|
5928
|
+
*
|
|
5929
|
+
* @example
|
|
5930
|
+
* ```typescript
|
|
5931
|
+
* const annotations = await page.getAnnotations();
|
|
5932
|
+
* for (const annot of annotations) {
|
|
5933
|
+
* console.log(annot.type, annot.contents);
|
|
5934
|
+
* }
|
|
5935
|
+
* ```
|
|
5936
|
+
*/
|
|
5937
|
+
getAnnotations(): Promise<PDFAnnotation[]>;
|
|
5938
|
+
/**
|
|
5939
|
+
* Get all popup annotations on this page.
|
|
5940
|
+
*
|
|
5941
|
+
* Popups are typically accessed via their parent markup annotation
|
|
5942
|
+
* using `annotation.getPopup()`, but this method allows direct access.
|
|
5943
|
+
*/
|
|
5944
|
+
getPopupAnnotations(): Promise<PDFPopupAnnotation[]>;
|
|
5945
|
+
/**
|
|
5946
|
+
* Get all highlight annotations on this page.
|
|
5947
|
+
*/
|
|
5948
|
+
getHighlightAnnotations(): Promise<PDFHighlightAnnotation[]>;
|
|
5949
|
+
/**
|
|
5950
|
+
* Get all underline annotations on this page.
|
|
5951
|
+
*/
|
|
5952
|
+
getUnderlineAnnotations(): Promise<PDFUnderlineAnnotation[]>;
|
|
5953
|
+
/**
|
|
5954
|
+
* Get all strikeout annotations on this page.
|
|
5955
|
+
*/
|
|
5956
|
+
getStrikeOutAnnotations(): Promise<PDFStrikeOutAnnotation[]>;
|
|
5957
|
+
/**
|
|
5958
|
+
* Get all squiggly annotations on this page.
|
|
5959
|
+
*/
|
|
5960
|
+
getSquigglyAnnotations(): Promise<PDFSquigglyAnnotation[]>;
|
|
5961
|
+
/**
|
|
5962
|
+
* Get all link annotations on this page.
|
|
5963
|
+
*/
|
|
5964
|
+
getLinkAnnotations(): Promise<PDFLinkAnnotation[]>;
|
|
5965
|
+
/**
|
|
5966
|
+
* Get all text annotations (sticky notes) on this page.
|
|
5967
|
+
*/
|
|
5968
|
+
getTextAnnotations(): Promise<PDFTextAnnotation[]>;
|
|
5969
|
+
/**
|
|
5970
|
+
* Get all free text annotations on this page.
|
|
5971
|
+
*/
|
|
5972
|
+
getFreeTextAnnotations(): Promise<PDFFreeTextAnnotation[]>;
|
|
5973
|
+
/**
|
|
5974
|
+
* Get all line annotations on this page.
|
|
5975
|
+
*/
|
|
5976
|
+
getLineAnnotations(): Promise<PDFLineAnnotation[]>;
|
|
5977
|
+
/**
|
|
5978
|
+
* Get all square annotations on this page.
|
|
5979
|
+
*/
|
|
5980
|
+
getSquareAnnotations(): Promise<PDFSquareAnnotation[]>;
|
|
5981
|
+
/**
|
|
5982
|
+
* Get all circle annotations on this page.
|
|
5983
|
+
*/
|
|
5984
|
+
getCircleAnnotations(): Promise<PDFCircleAnnotation[]>;
|
|
5985
|
+
/**
|
|
5986
|
+
* Get all stamp annotations on this page.
|
|
5987
|
+
*/
|
|
5988
|
+
getStampAnnotations(): Promise<PDFStampAnnotation[]>;
|
|
5989
|
+
/**
|
|
5990
|
+
* Get all ink annotations on this page.
|
|
5991
|
+
*/
|
|
5992
|
+
getInkAnnotations(): Promise<PDFInkAnnotation[]>;
|
|
5993
|
+
/**
|
|
5994
|
+
* Get all polygon annotations on this page.
|
|
5995
|
+
*/
|
|
5996
|
+
getPolygonAnnotations(): Promise<PDFPolygonAnnotation[]>;
|
|
5997
|
+
/**
|
|
5998
|
+
* Get all polyline annotations on this page.
|
|
5999
|
+
*/
|
|
6000
|
+
getPolylineAnnotations(): Promise<PDFPolylineAnnotation[]>;
|
|
6001
|
+
/**
|
|
6002
|
+
* Get all caret annotations on this page.
|
|
6003
|
+
*/
|
|
6004
|
+
getCaretAnnotations(): Promise<PDFCaretAnnotation[]>;
|
|
6005
|
+
/**
|
|
6006
|
+
* Get all file attachment annotations on this page.
|
|
6007
|
+
*/
|
|
6008
|
+
getFileAttachmentAnnotations(): Promise<PDFFileAttachmentAnnotation[]>;
|
|
6009
|
+
/**
|
|
6010
|
+
* Add a highlight annotation.
|
|
6011
|
+
*
|
|
6012
|
+
* @param options - Highlight options (rect, rects, or quadPoints)
|
|
6013
|
+
* @returns The created annotation
|
|
6014
|
+
*
|
|
6015
|
+
* @example
|
|
6016
|
+
* ```typescript
|
|
6017
|
+
* // Simple rect for horizontal text
|
|
6018
|
+
* page.addHighlightAnnotation({
|
|
6019
|
+
* rect: { x: 100, y: 680, width: 200, height: 20 },
|
|
6020
|
+
* color: rgb(1, 1, 0),
|
|
6021
|
+
* });
|
|
6022
|
+
*
|
|
6023
|
+
* // Multiple rects for multi-line selection
|
|
6024
|
+
* page.addHighlightAnnotation({
|
|
6025
|
+
* rects: [
|
|
6026
|
+
* { x: 100, y: 700, width: 400, height: 14 },
|
|
6027
|
+
* { x: 100, y: 680, width: 250, height: 14 },
|
|
6028
|
+
* ],
|
|
6029
|
+
* color: rgb(1, 1, 0),
|
|
6030
|
+
* });
|
|
6031
|
+
* ```
|
|
6032
|
+
*/
|
|
6033
|
+
addHighlightAnnotation(options: TextMarkupAnnotationOptions): PDFHighlightAnnotation;
|
|
6034
|
+
/**
|
|
6035
|
+
* Add an underline annotation.
|
|
6036
|
+
*/
|
|
6037
|
+
addUnderlineAnnotation(options: TextMarkupAnnotationOptions): PDFUnderlineAnnotation;
|
|
6038
|
+
/**
|
|
6039
|
+
* Add a strikeout annotation.
|
|
6040
|
+
*/
|
|
6041
|
+
addStrikeOutAnnotation(options: TextMarkupAnnotationOptions): PDFStrikeOutAnnotation;
|
|
6042
|
+
/**
|
|
6043
|
+
* Add a squiggly underline annotation.
|
|
6044
|
+
*/
|
|
6045
|
+
addSquigglyAnnotation(options: TextMarkupAnnotationOptions): PDFSquigglyAnnotation;
|
|
6046
|
+
/**
|
|
6047
|
+
* Add a text markup annotation (internal helper).
|
|
6048
|
+
*/
|
|
6049
|
+
private addTextMarkupAnnotation;
|
|
6050
|
+
/**
|
|
6051
|
+
* Add a link annotation.
|
|
6052
|
+
*
|
|
6053
|
+
* @param options - Link options (uri or destination)
|
|
6054
|
+
* @returns The created annotation
|
|
6055
|
+
*
|
|
6056
|
+
* @example
|
|
6057
|
+
* ```typescript
|
|
6058
|
+
* // External link
|
|
6059
|
+
* page.addLinkAnnotation({
|
|
6060
|
+
* rect: { x: 100, y: 600, width: 200, height: 20 },
|
|
6061
|
+
* uri: "https://example.com",
|
|
6062
|
+
* });
|
|
6063
|
+
*
|
|
6064
|
+
* // Internal link to another page (recommended)
|
|
6065
|
+
* page.addLinkAnnotation({
|
|
6066
|
+
* rect: { x: 100, y: 550, width: 200, height: 20 },
|
|
6067
|
+
* destination: { page: otherPage, type: "Fit" },
|
|
6068
|
+
* });
|
|
6069
|
+
*
|
|
6070
|
+
* // Or using a page reference directly
|
|
6071
|
+
* page.addLinkAnnotation({
|
|
6072
|
+
* rect: { x: 100, y: 520, width: 200, height: 20 },
|
|
6073
|
+
* destination: { page: otherPage.ref, type: "Fit" },
|
|
6074
|
+
* });
|
|
6075
|
+
* ```
|
|
6076
|
+
*/
|
|
6077
|
+
addLinkAnnotation(options: LinkAnnotationOptions): PDFLinkAnnotation;
|
|
6078
|
+
/**
|
|
6079
|
+
* Add a text annotation (sticky note).
|
|
6080
|
+
*
|
|
6081
|
+
* @param options - Text annotation options
|
|
6082
|
+
* @returns The created annotation
|
|
6083
|
+
*/
|
|
6084
|
+
addTextAnnotation(options: TextAnnotationOptions): PDFTextAnnotation;
|
|
6085
|
+
/**
|
|
6086
|
+
* Add a line annotation.
|
|
6087
|
+
*
|
|
6088
|
+
* @param options - Line annotation options
|
|
6089
|
+
* @returns The created annotation
|
|
6090
|
+
*/
|
|
6091
|
+
addLineAnnotation(options: LineAnnotationOptions): PDFLineAnnotation;
|
|
6092
|
+
/**
|
|
6093
|
+
* Add a square (rectangle) annotation.
|
|
6094
|
+
*
|
|
6095
|
+
* @param options - Square annotation options
|
|
6096
|
+
* @returns The created annotation
|
|
6097
|
+
*/
|
|
6098
|
+
addSquareAnnotation(options: SquareAnnotationOptions): PDFSquareAnnotation;
|
|
6099
|
+
/**
|
|
6100
|
+
* Add a circle (ellipse) annotation.
|
|
6101
|
+
*
|
|
6102
|
+
* @param options - Circle annotation options
|
|
6103
|
+
* @returns The created annotation
|
|
6104
|
+
*/
|
|
6105
|
+
addCircleAnnotation(options: CircleAnnotationOptions): PDFCircleAnnotation;
|
|
6106
|
+
/**
|
|
6107
|
+
* Add a stamp annotation.
|
|
6108
|
+
*
|
|
6109
|
+
* @param options - Stamp annotation options
|
|
6110
|
+
* @returns The created annotation
|
|
6111
|
+
*/
|
|
6112
|
+
addStampAnnotation(options: StampAnnotationOptions): PDFStampAnnotation;
|
|
6113
|
+
/**
|
|
6114
|
+
* Add an ink (freehand drawing) annotation.
|
|
6115
|
+
*
|
|
6116
|
+
* @param options - Ink annotation options
|
|
6117
|
+
* @returns The created annotation
|
|
6118
|
+
*/
|
|
6119
|
+
addInkAnnotation(options: InkAnnotationOptions): PDFInkAnnotation;
|
|
6120
|
+
/**
|
|
6121
|
+
* Remove a specific annotation from the page.
|
|
6122
|
+
*
|
|
6123
|
+
* Also removes any linked Popup annotation.
|
|
6124
|
+
*
|
|
6125
|
+
* @param annotation - The annotation to remove
|
|
6126
|
+
*
|
|
6127
|
+
* @example
|
|
6128
|
+
* ```typescript
|
|
6129
|
+
* const highlights = await page.getHighlightAnnotations();
|
|
6130
|
+
* await page.removeAnnotation(highlights[0]);
|
|
6131
|
+
* ```
|
|
6132
|
+
*/
|
|
6133
|
+
removeAnnotation(annotation: PDFAnnotation): Promise<void>;
|
|
6134
|
+
/**
|
|
6135
|
+
* Remove annotations from the page.
|
|
6136
|
+
*
|
|
6137
|
+
* Without options, removes all annotations (except Widget annotations).
|
|
6138
|
+
* With type filter, removes only annotations of the specified type.
|
|
6139
|
+
*
|
|
6140
|
+
* @param options - Optional filter by annotation type
|
|
6141
|
+
*
|
|
6142
|
+
* @example
|
|
6143
|
+
* ```typescript
|
|
6144
|
+
* // Remove all highlights
|
|
6145
|
+
* await page.removeAnnotations({ type: "Highlight" });
|
|
6146
|
+
*
|
|
6147
|
+
* // Remove all annotations
|
|
6148
|
+
* await page.removeAnnotations();
|
|
6149
|
+
* ```
|
|
6150
|
+
*/
|
|
6151
|
+
removeAnnotations(options?: RemoveAnnotationsOptions): Promise<void>;
|
|
6152
|
+
/**
|
|
6153
|
+
* Add an annotation reference to the page's /Annots array.
|
|
6154
|
+
* Internal method - also invalidates the annotation cache.
|
|
6155
|
+
*/
|
|
6156
|
+
private addAnnotationRef;
|
|
6157
|
+
/**
|
|
6158
|
+
* Invalidate the annotation cache.
|
|
6159
|
+
* Called when annotations are added or removed.
|
|
6160
|
+
*/
|
|
6161
|
+
private invalidateAnnotationCache;
|
|
4867
6162
|
/**
|
|
4868
6163
|
* Add an XObject reference to the page's resources.
|
|
4869
6164
|
* Returns the name assigned to the XObject.
|
|
@@ -7157,22 +8452,199 @@ declare class CryptoKeySigner implements Signer {
|
|
|
7157
8452
|
*/
|
|
7158
8453
|
constructor(privateKey: CryptoKey, certificate: Uint8Array, keyType: KeyType, signatureAlgorithm: SignatureAlgorithm, certificateChain?: Uint8Array[]);
|
|
7159
8454
|
/**
|
|
7160
|
-
* Sign
|
|
8455
|
+
* Sign data using the private key.
|
|
7161
8456
|
*
|
|
7162
|
-
*
|
|
7163
|
-
*
|
|
8457
|
+
* The data is hashed internally using the specified algorithm.
|
|
8458
|
+
*
|
|
8459
|
+
* @param data - The data to sign
|
|
8460
|
+
* @param algorithm - The digest algorithm to use
|
|
7164
8461
|
* @returns Raw signature bytes
|
|
7165
8462
|
*/
|
|
7166
|
-
sign(
|
|
8463
|
+
sign(data: Uint8Array, algorithm: DigestAlgorithm): Promise<Uint8Array>;
|
|
8464
|
+
/**
|
|
8465
|
+
* Get the hash output length in bytes for a given algorithm.
|
|
8466
|
+
*/
|
|
8467
|
+
private getHashLength;
|
|
8468
|
+
}
|
|
8469
|
+
//#endregion
|
|
8470
|
+
//#region src/signatures/signers/google-kms.d.ts
|
|
8471
|
+
/** KMS client type - dynamically imported */
|
|
8472
|
+
type KeyManagementServiceClient = _google_cloud_kms0.KeyManagementServiceClient;
|
|
8473
|
+
/** Secret Manager client type - dynamically imported */
|
|
8474
|
+
type SecretManagerServiceClient = _google_cloud_secret_manager0.SecretManagerServiceClient;
|
|
8475
|
+
/** Base options shared by both key reference styles */
|
|
8476
|
+
interface GoogleKmsSignerBaseOptions {
|
|
8477
|
+
/** DER-encoded X.509 certificate issued for this KMS key */
|
|
8478
|
+
certificate: Uint8Array;
|
|
8479
|
+
/** Certificate chain [intermediate, ..., root] (optional) */
|
|
8480
|
+
certificateChain?: Uint8Array[];
|
|
8481
|
+
/** Build certificate chain via AIA extensions (default: false) */
|
|
8482
|
+
buildChain?: boolean;
|
|
8483
|
+
/** Timeout for AIA chain building in ms (default: 15000) */
|
|
8484
|
+
chainTimeout?: number;
|
|
8485
|
+
/** Pre-configured KMS client (optional, uses ADC if not provided) */
|
|
8486
|
+
client?: KeyManagementServiceClient;
|
|
8487
|
+
}
|
|
8488
|
+
/** Full resource name style */
|
|
8489
|
+
interface GoogleKmsSignerFullNameOptions extends GoogleKmsSignerBaseOptions {
|
|
8490
|
+
/** Full KMS key version resource name */
|
|
8491
|
+
keyVersionName: string;
|
|
8492
|
+
}
|
|
8493
|
+
/** Shorthand style */
|
|
8494
|
+
interface GoogleKmsSignerShorthandOptions extends GoogleKmsSignerBaseOptions {
|
|
8495
|
+
projectId: string;
|
|
8496
|
+
locationId: string;
|
|
8497
|
+
keyRingId: string;
|
|
8498
|
+
keyId: string;
|
|
8499
|
+
/** Key version number (default: "1") */
|
|
8500
|
+
keyVersion?: string;
|
|
8501
|
+
}
|
|
8502
|
+
/** Options for GoogleKmsSigner.create() */
|
|
8503
|
+
type GoogleKmsSignerOptions = GoogleKmsSignerFullNameOptions | GoogleKmsSignerShorthandOptions;
|
|
8504
|
+
/** Mapped algorithm info from KMS algorithm */
|
|
8505
|
+
|
|
8506
|
+
/**
|
|
8507
|
+
* Signer that uses Google Cloud KMS for signing operations.
|
|
8508
|
+
*
|
|
8509
|
+
* Supports RSA and ECDSA keys stored in Cloud KMS, including HSM-backed keys.
|
|
8510
|
+
* The private key never leaves KMS - only the digest is sent for signing.
|
|
8511
|
+
*
|
|
8512
|
+
* **Performance note:** Each `sign()` call makes a network request to KMS
|
|
8513
|
+
* (~50-200ms latency). For bulk signing, consider the performance implications.
|
|
8514
|
+
*
|
|
8515
|
+
* @example
|
|
8516
|
+
* ```typescript
|
|
8517
|
+
* const signer = await GoogleKmsSigner.create({
|
|
8518
|
+
* keyVersionName: "projects/my-project/locations/us/keyRings/ring/cryptoKeys/key/cryptoKeyVersions/1",
|
|
8519
|
+
* certificate: certificateDer,
|
|
8520
|
+
* });
|
|
8521
|
+
*
|
|
8522
|
+
* const pdf = await PDF.load(pdfBytes);
|
|
8523
|
+
* const { bytes } = await pdf.sign({ signer });
|
|
8524
|
+
* ```
|
|
8525
|
+
*/
|
|
8526
|
+
declare class GoogleKmsSigner implements Signer {
|
|
8527
|
+
readonly certificate: Uint8Array;
|
|
8528
|
+
readonly certificateChain: Uint8Array[];
|
|
8529
|
+
readonly keyType: KeyType;
|
|
8530
|
+
readonly signatureAlgorithm: SignatureAlgorithm;
|
|
8531
|
+
/** The digest algorithm this KMS key uses (locked at key creation) */
|
|
8532
|
+
readonly digestAlgorithm: DigestAlgorithm;
|
|
8533
|
+
/** Full resource name of the KMS key version (for logging/debugging) */
|
|
8534
|
+
readonly keyVersionName: string;
|
|
8535
|
+
private readonly client;
|
|
8536
|
+
private constructor();
|
|
8537
|
+
/**
|
|
8538
|
+
* Create a GoogleKmsSigner from KMS key reference.
|
|
8539
|
+
*
|
|
8540
|
+
* @param options - Configuration options (key reference, certificate, etc.)
|
|
8541
|
+
* @returns A new GoogleKmsSigner instance
|
|
8542
|
+
* @throws {KmsSignerError} if key is invalid, disabled, or certificate doesn't match
|
|
8543
|
+
*
|
|
8544
|
+
* @example
|
|
8545
|
+
* ```typescript
|
|
8546
|
+
* // Full resource name
|
|
8547
|
+
* const signer = await GoogleKmsSigner.create({
|
|
8548
|
+
* keyVersionName: "projects/my-project/locations/us-east1/keyRings/my-ring/cryptoKeys/my-key/cryptoKeyVersions/1",
|
|
8549
|
+
* certificate: certificateDer,
|
|
8550
|
+
* });
|
|
8551
|
+
*
|
|
8552
|
+
* // Shorthand
|
|
8553
|
+
* const signer = await GoogleKmsSigner.create({
|
|
8554
|
+
* projectId: "my-project",
|
|
8555
|
+
* locationId: "us-east1",
|
|
8556
|
+
* keyRingId: "my-ring",
|
|
8557
|
+
* keyId: "my-key",
|
|
8558
|
+
* certificate: certificateDer,
|
|
8559
|
+
* buildChain: true,
|
|
8560
|
+
* });
|
|
8561
|
+
* ```
|
|
8562
|
+
*/
|
|
8563
|
+
static create(options: GoogleKmsSignerOptions): Promise<GoogleKmsSigner>;
|
|
8564
|
+
/**
|
|
8565
|
+
* Load a certificate from Google Secret Manager.
|
|
8566
|
+
*
|
|
8567
|
+
* The secret must contain a DER-encoded certificate. PEM format is NOT supported -
|
|
8568
|
+
* convert to DER before storing in Secret Manager.
|
|
8569
|
+
*
|
|
8570
|
+
* Supports cross-project access: the secret can be in a different GCP project
|
|
8571
|
+
* than the KMS key.
|
|
8572
|
+
*
|
|
8573
|
+
* @param secretVersionName - Full resource name, e.g.
|
|
8574
|
+
* "projects/my-project/secrets/my-cert/versions/latest"
|
|
8575
|
+
* @param options - Optional client configuration
|
|
8576
|
+
* @throws {KmsSignerError} if @google-cloud/secret-manager is not installed
|
|
8577
|
+
*
|
|
8578
|
+
* @example
|
|
8579
|
+
* ```typescript
|
|
8580
|
+
* // From same project
|
|
8581
|
+
* const cert = await GoogleKmsSigner.getCertificateFromSecretManager(
|
|
8582
|
+
* "projects/my-project/secrets/signing-cert/versions/latest"
|
|
8583
|
+
* );
|
|
8584
|
+
*
|
|
8585
|
+
* // From different project (cross-project access)
|
|
8586
|
+
* const cert = await GoogleKmsSigner.getCertificateFromSecretManager(
|
|
8587
|
+
* "projects/shared-certs-project/secrets/signing-cert/versions/1"
|
|
8588
|
+
* );
|
|
8589
|
+
* ```
|
|
8590
|
+
*/
|
|
8591
|
+
static getCertificateFromSecretManager(secretVersionName: string, options?: {
|
|
8592
|
+
client?: SecretManagerServiceClient;
|
|
8593
|
+
}): Promise<Uint8Array>;
|
|
8594
|
+
/**
|
|
8595
|
+
* Sign data using the KMS key.
|
|
8596
|
+
*
|
|
8597
|
+
* The data is hashed locally using the key's digest algorithm before being
|
|
8598
|
+
* sent to KMS for signing. This is more efficient than sending the full data.
|
|
8599
|
+
*
|
|
8600
|
+
* @param data - The data to sign
|
|
8601
|
+
* @param algorithm - The digest algorithm to use (must match the key's algorithm)
|
|
8602
|
+
* @returns The signature bytes
|
|
8603
|
+
* @throws {KmsSignerError} if digest algorithm doesn't match the key's algorithm
|
|
8604
|
+
*/
|
|
8605
|
+
sign(data: Uint8Array, algorithm: DigestAlgorithm): Promise<Uint8Array>;
|
|
8606
|
+
/**
|
|
8607
|
+
* Hash data using the specified algorithm.
|
|
8608
|
+
*
|
|
8609
|
+
* @returns The digest bytes and the KMS digest key name
|
|
8610
|
+
*/
|
|
8611
|
+
private hashData;
|
|
7167
8612
|
}
|
|
7168
8613
|
//#endregion
|
|
7169
8614
|
//#region src/signatures/signers/p12.d.ts
|
|
8615
|
+
/**
|
|
8616
|
+
* Options for creating a P12Signer.
|
|
8617
|
+
*/
|
|
8618
|
+
interface P12SignerOptions {
|
|
8619
|
+
/**
|
|
8620
|
+
* Build complete certificate chain using AIA (Authority Information Access).
|
|
8621
|
+
*
|
|
8622
|
+
* When enabled, the signer will fetch missing intermediate certificates
|
|
8623
|
+
* from URLs embedded in the certificates. This ensures the CMS signature
|
|
8624
|
+
* contains the full chain, which is important for validation.
|
|
8625
|
+
*
|
|
8626
|
+
* @default false
|
|
8627
|
+
*/
|
|
8628
|
+
buildChain?: boolean;
|
|
8629
|
+
/**
|
|
8630
|
+
* Timeout for AIA certificate fetching in milliseconds.
|
|
8631
|
+
* Only used when `buildChain` is true.
|
|
8632
|
+
*
|
|
8633
|
+
* @default 15000
|
|
8634
|
+
*/
|
|
8635
|
+
chainTimeout?: number;
|
|
8636
|
+
}
|
|
7170
8637
|
/**
|
|
7171
8638
|
* Signer that uses a PKCS#12 (.p12/.pfx) file.
|
|
7172
8639
|
*
|
|
7173
8640
|
* @example
|
|
7174
8641
|
* ```typescript
|
|
8642
|
+
* // Basic usage
|
|
7175
8643
|
* const signer = await P12Signer.create(p12Bytes, "password");
|
|
8644
|
+
*
|
|
8645
|
+
* // With automatic chain building via AIA
|
|
8646
|
+
* const signer = await P12Signer.create(p12Bytes, "password", { buildChain: true });
|
|
8647
|
+
*
|
|
7176
8648
|
* const signature = await signer.sign(digest, "SHA-256");
|
|
7177
8649
|
* ```
|
|
7178
8650
|
*/
|
|
@@ -7188,10 +8660,22 @@ declare class P12Signer implements Signer {
|
|
|
7188
8660
|
*
|
|
7189
8661
|
* @param p12Bytes - The .p12/.pfx file contents
|
|
7190
8662
|
* @param password - Password to decrypt the file
|
|
8663
|
+
* @param options - Optional configuration
|
|
7191
8664
|
* @returns A new P12Signer instance
|
|
7192
8665
|
* @throws {SignerError} if the file is invalid or password is wrong
|
|
8666
|
+
*
|
|
8667
|
+
* @example
|
|
8668
|
+
* ```typescript
|
|
8669
|
+
* // Basic usage
|
|
8670
|
+
* const signer = await P12Signer.create(p12Bytes, "password");
|
|
8671
|
+
*
|
|
8672
|
+
* // With automatic chain building (recommended for B-LT/B-LTA)
|
|
8673
|
+
* const signer = await P12Signer.create(p12Bytes, "password", {
|
|
8674
|
+
* buildChain: true,
|
|
8675
|
+
* });
|
|
8676
|
+
* ```
|
|
7193
8677
|
*/
|
|
7194
|
-
static create(p12Bytes: Uint8Array, password: string): Promise<P12Signer>;
|
|
8678
|
+
static create(p12Bytes: Uint8Array, password: string, options?: P12SignerOptions): Promise<P12Signer>;
|
|
7195
8679
|
/**
|
|
7196
8680
|
* Extract private key from a shrouded key bag.
|
|
7197
8681
|
*/
|
|
@@ -7385,5 +8869,28 @@ declare function layoutText(text: string, font: FontInput, fontSize: number, max
|
|
|
7385
8869
|
*/
|
|
7386
8870
|
declare function layoutJustifiedLine(words: string[], font: FontInput, fontSize: number, targetWidth: number): PositionedWord[];
|
|
7387
8871
|
//#endregion
|
|
7388
|
-
|
|
8872
|
+
//#region src/annotations/factory.d.ts
|
|
8873
|
+
/**
|
|
8874
|
+
* Unknown annotation - fallback for unsupported types.
|
|
8875
|
+
*/
|
|
8876
|
+
declare class PDFUnknownAnnotation extends PDFAnnotation {}
|
|
8877
|
+
/**
|
|
8878
|
+
* Create an annotation object from a PDF dictionary.
|
|
8879
|
+
*
|
|
8880
|
+
* @param dict - The annotation dictionary
|
|
8881
|
+
* @param ref - The reference to the annotation object
|
|
8882
|
+
* @param registry - The object registry for resolving references
|
|
8883
|
+
* @returns The appropriate annotation class instance
|
|
8884
|
+
*/
|
|
8885
|
+
declare function createAnnotation(dict: PdfDict, ref: PdfRef | null, registry: ObjectRegistry): PDFAnnotation;
|
|
8886
|
+
/**
|
|
8887
|
+
* Check if an annotation is a Widget (form field).
|
|
8888
|
+
*/
|
|
8889
|
+
declare function isWidgetAnnotation(dict: PdfDict): boolean;
|
|
8890
|
+
/**
|
|
8891
|
+
* Check if an annotation is a Popup.
|
|
8892
|
+
*/
|
|
8893
|
+
declare function isPopupAnnotation(dict: PdfDict): boolean;
|
|
8894
|
+
//#endregion
|
|
8895
|
+
export { AnnotationFlags, type AnnotationSubtype, type AuthenticationResult, type BorderStyle, type BorderStyleType, type ButtonField, type CMYK, type CaretAnnotationOptions, type CaretSymbol, CertificateChainError, type CheckboxField, type CheckboxOptions, type CheckboxSymbol, type CircleAnnotationOptions, type Color, type CopyPagesOptions, CryptoKeySigner, type Degrees, type DestinationType, type DigestAlgorithm, type DocumentMetadata, type DrawCircleOptions, type DrawEllipseOptions, type DrawFieldOptions, type DrawImageOptions, type DrawLineOptions, type DrawPageOptions, type DrawRectangleOptions, type DrawTextOptions, type DropdownField, type DropdownOptions, type EmbedFontOptions, type EmbeddedFont, type EncryptionAlgorithmOption, type ExtractPagesOptions, type FieldOptions, type FieldType, type FieldValue, type FileAttachmentIcon, type FlattenAnnotationsOptions, type FlattenLayersResult, type FlattenOptions, type FontInput, type FormField, type FormProperties, type FreeTextAnnotationOptions, type FreeTextJustification, GoogleKmsSigner, type Grayscale, type HighlightMode, HttpTimestampAuthority, type HttpTimestampAuthorityOptions, type InkAnnotationOptions, type KeyType, KmsSignerError, type LayerInfo, type LayoutResult, type LineAnnotationOptions, type LineCap, type LineEndingStyle, type LineJoin, type LinkAction, type LinkAnnotationOptions, type LinkDestination, type ListBoxField, type ListboxOptions, type LoadOptions, type MergeOptions, P12Signer, type PAdESLevel, PDF, PDFAnnotation, PDFCaretAnnotation, PDFCircleAnnotation, PDFEmbeddedPage, PDFFileAttachmentAnnotation, PDFForm, PDFFreeTextAnnotation, PDFHighlightAnnotation, PDFImage, PDFInkAnnotation, PDFLineAnnotation, PDFLinkAnnotation, PDFMarkupAnnotation, PDFPage, PDFPolygonAnnotation, PDFPolylineAnnotation, PDFPopupAnnotation, PDFSquareAnnotation, PDFSquigglyAnnotation, PDFStampAnnotation, PDFStrikeOutAnnotation, PDFTextAnnotation, PDFTextMarkupAnnotation, PDFUnderlineAnnotation, PDFUnknownAnnotation, PathBuilder, type PathOptions, PdfArray, PdfBool, PdfDict, PdfName, PdfNull, PdfNumber, type PdfObject, PdfRef, PdfStream, PdfString, PermissionDeniedError, type PermissionOptions, type Permissions, PlaceholderError, type Point, type PolygonAnnotationOptions, type PolylineAnnotationOptions, type PopupOptions, type PositionedWord, type ProtectionOptions, type RGB, type RadioField, type RadioGroupOptions, type RadioSymbol, type Rect, type Rectangle, type RemoveAnnotationsOptions, RevocationError, type RevocationProvider, type Rotation, STANDARD_STAMPS, type SaveOptions, SecurityError, type SecurityInfo, type SetTitleOptions, type SignOptions, type SignResult, type SignWarning, type SignatureAlgorithm, SignatureError, type SignatureField, type SignatureFieldOptions, type Signer, SignerError, type SquareAnnotationOptions, type StampAnnotationOptions, type StampName, type Standard14FontName, StandardFonts, type SubFilter, TextAlignment, type TextAnnotationIcon, type TextAnnotationOptions, type TextAnnotationState, type TextAnnotationStateModel, type TextField, type TextFieldOptions, type TextLine, type TextMarkupAnnotationOptions, type TimestampAuthority, TimestampError, type TrappedStatus, black, blue, cmyk, createAnnotation, degrees, grayscale, green, isPopupAnnotation, isWidgetAnnotation, layoutJustifiedLine, layoutText, lineCapToNumber, lineJoinToNumber, measureText, rectToQuadPoints, rectsToQuadPoints, red, rgb, version, white };
|
|
7389
8896
|
//# sourceMappingURL=index.d.mts.map
|