@libpdf/core 0.0.1-beta.5 → 0.0.1-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +177 -126
- package/dist/index.mjs +893 -805
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.d.mts
CHANGED
|
@@ -1212,7 +1212,7 @@ declare class PdfStream extends PdfDict {
|
|
|
1212
1212
|
* @returns Decoded data
|
|
1213
1213
|
* @throws {Error} if a filter fails or is unknown
|
|
1214
1214
|
*/
|
|
1215
|
-
getDecodedData():
|
|
1215
|
+
getDecodedData(): Uint8Array;
|
|
1216
1216
|
/**
|
|
1217
1217
|
* Get the encoded (compressed) stream data.
|
|
1218
1218
|
*
|
|
@@ -1228,7 +1228,7 @@ declare class PdfStream extends PdfDict {
|
|
|
1228
1228
|
*
|
|
1229
1229
|
* @returns Encoded data (compressed if filters are specified)
|
|
1230
1230
|
*/
|
|
1231
|
-
getEncodedData():
|
|
1231
|
+
getEncodedData(): Uint8Array;
|
|
1232
1232
|
/**
|
|
1233
1233
|
* Build filter specs from /Filter and /DecodeParms entries.
|
|
1234
1234
|
*/
|
|
@@ -2478,8 +2478,8 @@ interface SignOptions {
|
|
|
2478
2478
|
* Warning emitted during signing.
|
|
2479
2479
|
*/
|
|
2480
2480
|
interface SignWarning {
|
|
2481
|
-
/** Warning code */
|
|
2482
|
-
code: "MDP_VIOLATION" | "CHAIN_INCOMPLETE" | string;
|
|
2481
|
+
/** Warning code (e.g., "MDP_VIOLATION", "CHAIN_INCOMPLETE") */
|
|
2482
|
+
code: "MDP_VIOLATION" | "CHAIN_INCOMPLETE" | (string & {});
|
|
2483
2483
|
/** Human-readable message */
|
|
2484
2484
|
message: string;
|
|
2485
2485
|
}
|
|
@@ -2699,8 +2699,12 @@ interface FindTextOptions {
|
|
|
2699
2699
|
/**
|
|
2700
2700
|
* Function to resolve objects not yet in the registry.
|
|
2701
2701
|
* Called when resolve() encounters an unknown reference.
|
|
2702
|
+
*
|
|
2703
|
+
* This is synchronous because all PDF data is loaded into memory
|
|
2704
|
+
* at parse time. The resolver simply parses objects on demand from
|
|
2705
|
+
* the in-memory buffer.
|
|
2702
2706
|
*/
|
|
2703
|
-
type ObjectResolver = (ref: PdfRef) =>
|
|
2707
|
+
type ObjectResolver = (ref: PdfRef) => PdfObject | null;
|
|
2704
2708
|
/**
|
|
2705
2709
|
* Registry for managing PDF objects and their references.
|
|
2706
2710
|
*
|
|
@@ -2795,7 +2799,7 @@ declare class ObjectRegistry {
|
|
|
2795
2799
|
* @param ref - The reference to resolve
|
|
2796
2800
|
* @returns The object, or null if not found
|
|
2797
2801
|
*/
|
|
2798
|
-
resolve(ref: PdfRef):
|
|
2802
|
+
resolve(ref: PdfRef): PdfObject | null;
|
|
2799
2803
|
/**
|
|
2800
2804
|
* Add a warning message.
|
|
2801
2805
|
*/
|
|
@@ -2836,8 +2840,10 @@ declare class ObjectRegistry {
|
|
|
2836
2840
|
//#region src/document/name-tree.d.ts
|
|
2837
2841
|
/**
|
|
2838
2842
|
* Function to resolve a reference to its object.
|
|
2843
|
+
*
|
|
2844
|
+
* Synchronous because all PDF data is loaded into memory at parse time.
|
|
2839
2845
|
*/
|
|
2840
|
-
type Resolver = (ref: PdfRef) =>
|
|
2846
|
+
type Resolver = (ref: PdfRef) => PdfObject | null;
|
|
2841
2847
|
/**
|
|
2842
2848
|
* PDF Name Tree reader.
|
|
2843
2849
|
*
|
|
@@ -2855,20 +2861,20 @@ declare class NameTree {
|
|
|
2855
2861
|
*
|
|
2856
2862
|
* @returns The value if found, null otherwise
|
|
2857
2863
|
*/
|
|
2858
|
-
get(key: string):
|
|
2864
|
+
get(key: string): PdfObject | null;
|
|
2859
2865
|
/**
|
|
2860
2866
|
* Check if a key exists in the tree.
|
|
2861
2867
|
*/
|
|
2862
|
-
has(key: string):
|
|
2868
|
+
has(key: string): boolean;
|
|
2863
2869
|
/**
|
|
2864
2870
|
* Iterate all entries (lazy, yields [key, value] pairs).
|
|
2865
2871
|
* Uses BFS traversal with cycle detection.
|
|
2866
2872
|
*/
|
|
2867
|
-
entries():
|
|
2873
|
+
entries(): Generator<[string, PdfObject]>;
|
|
2868
2874
|
/**
|
|
2869
2875
|
* Load all entries into a Map (cached after first call).
|
|
2870
2876
|
*/
|
|
2871
|
-
getAll():
|
|
2877
|
+
getAll(): ReadonlyMap<string, PdfObject>;
|
|
2872
2878
|
/**
|
|
2873
2879
|
* Check if all entries have been loaded into cache.
|
|
2874
2880
|
*/
|
|
@@ -2903,24 +2909,24 @@ declare class PDFCatalog {
|
|
|
2903
2909
|
/**
|
|
2904
2910
|
* Get the /Names dictionary.
|
|
2905
2911
|
*/
|
|
2906
|
-
getNames():
|
|
2912
|
+
getNames(): PdfDict | null;
|
|
2907
2913
|
/**
|
|
2908
2914
|
* Get or create the /Names dictionary.
|
|
2909
2915
|
*/
|
|
2910
|
-
getOrCreateNames():
|
|
2916
|
+
getOrCreateNames(): PdfDict;
|
|
2911
2917
|
/**
|
|
2912
2918
|
* Get the EmbeddedFiles name tree.
|
|
2913
2919
|
* Caches the result for repeated access.
|
|
2914
2920
|
*/
|
|
2915
|
-
getEmbeddedFilesTree():
|
|
2921
|
+
getEmbeddedFilesTree(): NameTree | null;
|
|
2916
2922
|
/**
|
|
2917
2923
|
* Set the EmbeddedFiles name tree.
|
|
2918
2924
|
*/
|
|
2919
|
-
setEmbeddedFilesTree(treeDict: PdfDict):
|
|
2925
|
+
setEmbeddedFilesTree(treeDict: PdfDict): void;
|
|
2920
2926
|
/**
|
|
2921
2927
|
* Remove the EmbeddedFiles entry from /Names.
|
|
2922
2928
|
*/
|
|
2923
|
-
removeEmbeddedFilesTree():
|
|
2929
|
+
removeEmbeddedFilesTree(): void;
|
|
2924
2930
|
/**
|
|
2925
2931
|
* Clear all cached name trees.
|
|
2926
2932
|
* Call this after modifying the catalog structure.
|
|
@@ -2954,9 +2960,8 @@ declare class PDFPageTree {
|
|
|
2954
2960
|
private constructor();
|
|
2955
2961
|
/**
|
|
2956
2962
|
* Load and build the page tree by walking from the root.
|
|
2957
|
-
* This is the only async operation.
|
|
2958
2963
|
*/
|
|
2959
|
-
static load(pagesRef: PdfRef, getObject: (ref: PdfRef) =>
|
|
2964
|
+
static load(pagesRef: PdfRef, getObject: (ref: PdfRef) => PdfObject | null): PDFPageTree;
|
|
2960
2965
|
/**
|
|
2961
2966
|
* Create an empty page tree.
|
|
2962
2967
|
* Note: This creates a minimal tree without a backing PDF structure.
|
|
@@ -3080,9 +3085,13 @@ declare class PDFContext {
|
|
|
3080
3085
|
*/
|
|
3081
3086
|
register(obj: PdfObject): PdfRef;
|
|
3082
3087
|
/**
|
|
3083
|
-
* Resolve an object by reference
|
|
3088
|
+
* Resolve an object by reference.
|
|
3089
|
+
*
|
|
3090
|
+
* Synchronously resolves the reference, parsing from the in-memory
|
|
3091
|
+
* buffer if not already cached. All PDF data is loaded at parse time,
|
|
3092
|
+
* so this operation never requires I/O.
|
|
3084
3093
|
*/
|
|
3085
|
-
resolve(ref: PdfRef):
|
|
3094
|
+
resolve(ref: PdfRef): PdfObject | null;
|
|
3086
3095
|
/**
|
|
3087
3096
|
* Get an object by reference (sync, only if already loaded).
|
|
3088
3097
|
*/
|
|
@@ -3122,7 +3131,7 @@ declare class PDFAttachments {
|
|
|
3122
3131
|
* }
|
|
3123
3132
|
* ```
|
|
3124
3133
|
*/
|
|
3125
|
-
list():
|
|
3134
|
+
list(): Map<string, AttachmentInfo>;
|
|
3126
3135
|
/**
|
|
3127
3136
|
* Get the raw bytes of an attachment.
|
|
3128
3137
|
*
|
|
@@ -3138,7 +3147,7 @@ declare class PDFAttachments {
|
|
|
3138
3147
|
* }
|
|
3139
3148
|
* ```
|
|
3140
3149
|
*/
|
|
3141
|
-
get(name: string):
|
|
3150
|
+
get(name: string): Uint8Array | null;
|
|
3142
3151
|
/**
|
|
3143
3152
|
* Check if an attachment exists.
|
|
3144
3153
|
*
|
|
@@ -3152,7 +3161,7 @@ declare class PDFAttachments {
|
|
|
3152
3161
|
* }
|
|
3153
3162
|
* ```
|
|
3154
3163
|
*/
|
|
3155
|
-
has(name: string):
|
|
3164
|
+
has(name: string): boolean;
|
|
3156
3165
|
/**
|
|
3157
3166
|
* Add a file attachment to the document.
|
|
3158
3167
|
*
|
|
@@ -3176,7 +3185,7 @@ declare class PDFAttachments {
|
|
|
3176
3185
|
* await pdf.attachments.add("report.pdf", newBytes, { overwrite: true });
|
|
3177
3186
|
* ```
|
|
3178
3187
|
*/
|
|
3179
|
-
add(name: string, data: Uint8Array, options?: AddAttachmentOptions):
|
|
3188
|
+
add(name: string, data: Uint8Array, options?: AddAttachmentOptions): void;
|
|
3180
3189
|
/**
|
|
3181
3190
|
* Remove an attachment from the document.
|
|
3182
3191
|
*
|
|
@@ -3191,7 +3200,7 @@ declare class PDFAttachments {
|
|
|
3191
3200
|
* }
|
|
3192
3201
|
* ```
|
|
3193
3202
|
*/
|
|
3194
|
-
remove(name: string):
|
|
3203
|
+
remove(name: string): boolean;
|
|
3195
3204
|
}
|
|
3196
3205
|
//#endregion
|
|
3197
3206
|
//#region src/helpers/colors.d.ts
|
|
@@ -3566,8 +3575,8 @@ interface PolylineAnnotationOptions {
|
|
|
3566
3575
|
interface StampAnnotationOptions {
|
|
3567
3576
|
/** Annotation rectangle */
|
|
3568
3577
|
rect: Rect;
|
|
3569
|
-
/**
|
|
3570
|
-
name?: StampName | string;
|
|
3578
|
+
/** Stamp name (use StampName constants for standard stamps, or any string for custom) */
|
|
3579
|
+
name?: StampName | (string & {});
|
|
3571
3580
|
/** Text content/comment */
|
|
3572
3581
|
contents?: string;
|
|
3573
3582
|
}
|
|
@@ -3722,15 +3731,15 @@ declare class PDFAnnotation {
|
|
|
3722
3731
|
/**
|
|
3723
3732
|
* Get the normal appearance stream.
|
|
3724
3733
|
*/
|
|
3725
|
-
getNormalAppearance():
|
|
3734
|
+
getNormalAppearance(): PdfStream | null;
|
|
3726
3735
|
/**
|
|
3727
3736
|
* Get the rollover appearance stream.
|
|
3728
3737
|
*/
|
|
3729
|
-
getRolloverAppearance():
|
|
3738
|
+
getRolloverAppearance(): PdfStream | null;
|
|
3730
3739
|
/**
|
|
3731
3740
|
* Get the down appearance stream.
|
|
3732
3741
|
*/
|
|
3733
|
-
getDownAppearance():
|
|
3742
|
+
getDownAppearance(): PdfStream | null;
|
|
3734
3743
|
/**
|
|
3735
3744
|
* Set the normal appearance stream.
|
|
3736
3745
|
*/
|
|
@@ -3829,7 +3838,7 @@ declare class PDFMarkupAnnotation extends PDFAnnotation {
|
|
|
3829
3838
|
/**
|
|
3830
3839
|
* Get the associated popup annotation, if any.
|
|
3831
3840
|
*/
|
|
3832
|
-
getPopup():
|
|
3841
|
+
getPopup(): PDFPopupAnnotation | null;
|
|
3833
3842
|
/**
|
|
3834
3843
|
* Create a popup annotation associated with this annotation.
|
|
3835
3844
|
* The popup is added to the parent annotation and registered.
|
|
@@ -3885,11 +3894,11 @@ declare class PDFFileAttachmentAnnotation extends PDFMarkupAnnotation {
|
|
|
3885
3894
|
/**
|
|
3886
3895
|
* Get the file specification dictionary.
|
|
3887
3896
|
*/
|
|
3888
|
-
getFileSpec():
|
|
3897
|
+
getFileSpec(): PdfDict | null;
|
|
3889
3898
|
/**
|
|
3890
3899
|
* Get the file name from the file specification.
|
|
3891
3900
|
*/
|
|
3892
|
-
getFileName():
|
|
3901
|
+
getFileName(): string | null;
|
|
3893
3902
|
}
|
|
3894
3903
|
//#endregion
|
|
3895
3904
|
//#region src/annotations/free-text.d.ts
|
|
@@ -4062,7 +4071,7 @@ declare class PDFLinkAnnotation extends PDFAnnotation {
|
|
|
4062
4071
|
/**
|
|
4063
4072
|
* Get the parsed link action.
|
|
4064
4073
|
*/
|
|
4065
|
-
getAction():
|
|
4074
|
+
getAction(): LinkAction;
|
|
4066
4075
|
/**
|
|
4067
4076
|
* Highlight mode when the link is clicked.
|
|
4068
4077
|
*/
|
|
@@ -4194,7 +4203,7 @@ declare class PDFStampAnnotation extends PDFMarkupAnnotation {
|
|
|
4194
4203
|
/**
|
|
4195
4204
|
* Set the stamp name.
|
|
4196
4205
|
*/
|
|
4197
|
-
setStampName(name: StampName | string): void;
|
|
4206
|
+
setStampName(name: StampName | (string & {})): void;
|
|
4198
4207
|
/**
|
|
4199
4208
|
* Check if this is a standard stamp.
|
|
4200
4209
|
*/
|
|
@@ -4646,15 +4655,15 @@ declare class WidgetAnnotation {
|
|
|
4646
4655
|
* Get normal appearance stream.
|
|
4647
4656
|
* For stateful widgets (checkbox/radio), pass the state name.
|
|
4648
4657
|
*/
|
|
4649
|
-
getNormalAppearance(state?: string):
|
|
4658
|
+
getNormalAppearance(state?: string): PdfStream | null;
|
|
4650
4659
|
/**
|
|
4651
4660
|
* Get rollover appearance stream (shown on mouse hover).
|
|
4652
4661
|
*/
|
|
4653
|
-
getRolloverAppearance(state?: string):
|
|
4662
|
+
getRolloverAppearance(state?: string): PdfStream | null;
|
|
4654
4663
|
/**
|
|
4655
4664
|
* Get down appearance stream (shown when clicked).
|
|
4656
4665
|
*/
|
|
4657
|
-
getDownAppearance(state?: string):
|
|
4666
|
+
getDownAppearance(state?: string): PdfStream | null;
|
|
4658
4667
|
/**
|
|
4659
4668
|
* Get border style.
|
|
4660
4669
|
*/
|
|
@@ -4676,7 +4685,7 @@ declare class WidgetAnnotation {
|
|
|
4676
4685
|
*/
|
|
4677
4686
|
interface AcroFormLike {
|
|
4678
4687
|
defaultQuadding: number;
|
|
4679
|
-
updateFieldAppearance?(field: TerminalField):
|
|
4688
|
+
updateFieldAppearance?(field: TerminalField): void;
|
|
4680
4689
|
}
|
|
4681
4690
|
/**
|
|
4682
4691
|
* Field type identifiers.
|
|
@@ -4865,7 +4874,7 @@ declare abstract class TerminalField extends FormField {
|
|
|
4865
4874
|
*
|
|
4866
4875
|
* @internal
|
|
4867
4876
|
*/
|
|
4868
|
-
resolveWidgets():
|
|
4877
|
+
resolveWidgets(): void;
|
|
4869
4878
|
/**
|
|
4870
4879
|
* Resolve MK dictionary if it's a reference.
|
|
4871
4880
|
* This ensures getAppearanceCharacteristics() can work synchronously.
|
|
@@ -4887,7 +4896,7 @@ declare abstract class TerminalField extends FormField {
|
|
|
4887
4896
|
* This method is async because it regenerates the field's appearance
|
|
4888
4897
|
* stream after resetting the value.
|
|
4889
4898
|
*/
|
|
4890
|
-
resetValue():
|
|
4899
|
+
resetValue(): void;
|
|
4891
4900
|
/**
|
|
4892
4901
|
* Check read-only and throw if set.
|
|
4893
4902
|
*/
|
|
@@ -4900,7 +4909,7 @@ declare abstract class TerminalField extends FormField {
|
|
|
4900
4909
|
*
|
|
4901
4910
|
* @internal
|
|
4902
4911
|
*/
|
|
4903
|
-
protected applyChange():
|
|
4912
|
+
protected applyChange(): void;
|
|
4904
4913
|
}
|
|
4905
4914
|
//#endregion
|
|
4906
4915
|
//#region src/document/forms/fields/checkbox-field.d.ts
|
|
@@ -4936,11 +4945,11 @@ declare class CheckboxField extends TerminalField {
|
|
|
4936
4945
|
/**
|
|
4937
4946
|
* Check the checkbox (sets to the on-value).
|
|
4938
4947
|
*/
|
|
4939
|
-
check():
|
|
4948
|
+
check(): void;
|
|
4940
4949
|
/**
|
|
4941
4950
|
* Uncheck the checkbox (sets to "Off").
|
|
4942
4951
|
*/
|
|
4943
|
-
uncheck():
|
|
4952
|
+
uncheck(): void;
|
|
4944
4953
|
/**
|
|
4945
4954
|
* Set the checkbox value.
|
|
4946
4955
|
*
|
|
@@ -4950,7 +4959,7 @@ declare class CheckboxField extends TerminalField {
|
|
|
4950
4959
|
* @param value "Off" or one of the on-values
|
|
4951
4960
|
* @throws {Error} if field is read-only or value is invalid
|
|
4952
4961
|
*/
|
|
4953
|
-
setValue(value: string):
|
|
4962
|
+
setValue(value: string): void;
|
|
4954
4963
|
}
|
|
4955
4964
|
//#endregion
|
|
4956
4965
|
//#region src/document/forms/fields/choice-fields.d.ts
|
|
@@ -4992,7 +5001,7 @@ declare class DropdownField extends TerminalField {
|
|
|
4992
5001
|
* @param value The value to select
|
|
4993
5002
|
* @throws {Error} if field is read-only or value is invalid (for non-editable dropdowns)
|
|
4994
5003
|
*/
|
|
4995
|
-
setValue(value: string):
|
|
5004
|
+
setValue(value: string): void;
|
|
4996
5005
|
}
|
|
4997
5006
|
/**
|
|
4998
5007
|
* List box field.
|
|
@@ -5035,7 +5044,7 @@ declare class ListBoxField extends TerminalField {
|
|
|
5035
5044
|
* @param values Array of values to select
|
|
5036
5045
|
* @throws {Error} if field is read-only, multiple selection not allowed, or values are invalid
|
|
5037
5046
|
*/
|
|
5038
|
-
setValue(values: string[]):
|
|
5047
|
+
setValue(values: string[]): void;
|
|
5039
5048
|
}
|
|
5040
5049
|
//#endregion
|
|
5041
5050
|
//#region src/document/forms/fields/other-fields.d.ts
|
|
@@ -5108,7 +5117,7 @@ declare class RadioField extends TerminalField {
|
|
|
5108
5117
|
* @param option One of getOptions() or null to deselect
|
|
5109
5118
|
* @throws {Error} if field is read-only, option is invalid, or deselection not allowed
|
|
5110
5119
|
*/
|
|
5111
|
-
setValue(option: string | null):
|
|
5120
|
+
setValue(option: string | null): void;
|
|
5112
5121
|
}
|
|
5113
5122
|
//#endregion
|
|
5114
5123
|
//#region src/document/forms/fields/text-field.d.ts
|
|
@@ -5148,7 +5157,7 @@ declare class TextField extends TerminalField {
|
|
|
5148
5157
|
* @param value The new text value
|
|
5149
5158
|
* @throws {Error} if field is read-only
|
|
5150
5159
|
*/
|
|
5151
|
-
setValue(value: string):
|
|
5160
|
+
setValue(value: string): void;
|
|
5152
5161
|
}
|
|
5153
5162
|
//#endregion
|
|
5154
5163
|
//#region src/fonts/standard-14.d.ts
|
|
@@ -5535,13 +5544,13 @@ declare class PathBuilder {
|
|
|
5535
5544
|
*/
|
|
5536
5545
|
interface Rectangle {
|
|
5537
5546
|
/** Left x coordinate */
|
|
5538
|
-
|
|
5547
|
+
x: number;
|
|
5539
5548
|
/** Bottom y coordinate */
|
|
5540
|
-
|
|
5541
|
-
/**
|
|
5542
|
-
|
|
5543
|
-
/**
|
|
5544
|
-
|
|
5549
|
+
y: number;
|
|
5550
|
+
/** Width */
|
|
5551
|
+
width: number;
|
|
5552
|
+
/** Height */
|
|
5553
|
+
height: number;
|
|
5545
5554
|
}
|
|
5546
5555
|
/**
|
|
5547
5556
|
* Options for drawing an embedded page.
|
|
@@ -5743,7 +5752,7 @@ declare class PDFPage {
|
|
|
5743
5752
|
* await page.drawField(paymentRadio, { x: 100, y: 520, width: 16, height: 16, option: "PayPal" });
|
|
5744
5753
|
* ```
|
|
5745
5754
|
*/
|
|
5746
|
-
drawField(field: FormField, options: DrawFieldOptions):
|
|
5755
|
+
drawField(field: FormField, options: DrawFieldOptions): void;
|
|
5747
5756
|
/**
|
|
5748
5757
|
* Build a widget annotation dictionary for a field.
|
|
5749
5758
|
*/
|
|
@@ -5928,84 +5937,84 @@ declare class PDFPage {
|
|
|
5928
5937
|
*
|
|
5929
5938
|
* @example
|
|
5930
5939
|
* ```typescript
|
|
5931
|
-
* const annotations =
|
|
5940
|
+
* const annotations = page.getAnnotations();
|
|
5932
5941
|
* for (const annot of annotations) {
|
|
5933
5942
|
* console.log(annot.type, annot.contents);
|
|
5934
5943
|
* }
|
|
5935
5944
|
* ```
|
|
5936
5945
|
*/
|
|
5937
|
-
getAnnotations():
|
|
5946
|
+
getAnnotations(): PDFAnnotation[];
|
|
5938
5947
|
/**
|
|
5939
5948
|
* Get all popup annotations on this page.
|
|
5940
5949
|
*
|
|
5941
5950
|
* Popups are typically accessed via their parent markup annotation
|
|
5942
5951
|
* using `annotation.getPopup()`, but this method allows direct access.
|
|
5943
5952
|
*/
|
|
5944
|
-
getPopupAnnotations():
|
|
5953
|
+
getPopupAnnotations(): PDFPopupAnnotation[];
|
|
5945
5954
|
/**
|
|
5946
5955
|
* Get all highlight annotations on this page.
|
|
5947
5956
|
*/
|
|
5948
|
-
getHighlightAnnotations():
|
|
5957
|
+
getHighlightAnnotations(): PDFHighlightAnnotation[];
|
|
5949
5958
|
/**
|
|
5950
5959
|
* Get all underline annotations on this page.
|
|
5951
5960
|
*/
|
|
5952
|
-
getUnderlineAnnotations():
|
|
5961
|
+
getUnderlineAnnotations(): PDFUnderlineAnnotation[];
|
|
5953
5962
|
/**
|
|
5954
5963
|
* Get all strikeout annotations on this page.
|
|
5955
5964
|
*/
|
|
5956
|
-
getStrikeOutAnnotations():
|
|
5965
|
+
getStrikeOutAnnotations(): PDFStrikeOutAnnotation[];
|
|
5957
5966
|
/**
|
|
5958
5967
|
* Get all squiggly annotations on this page.
|
|
5959
5968
|
*/
|
|
5960
|
-
getSquigglyAnnotations():
|
|
5969
|
+
getSquigglyAnnotations(): PDFSquigglyAnnotation[];
|
|
5961
5970
|
/**
|
|
5962
5971
|
* Get all link annotations on this page.
|
|
5963
5972
|
*/
|
|
5964
|
-
getLinkAnnotations():
|
|
5973
|
+
getLinkAnnotations(): PDFLinkAnnotation[];
|
|
5965
5974
|
/**
|
|
5966
5975
|
* Get all text annotations (sticky notes) on this page.
|
|
5967
5976
|
*/
|
|
5968
|
-
getTextAnnotations():
|
|
5977
|
+
getTextAnnotations(): PDFTextAnnotation[];
|
|
5969
5978
|
/**
|
|
5970
5979
|
* Get all free text annotations on this page.
|
|
5971
5980
|
*/
|
|
5972
|
-
getFreeTextAnnotations():
|
|
5981
|
+
getFreeTextAnnotations(): PDFFreeTextAnnotation[];
|
|
5973
5982
|
/**
|
|
5974
5983
|
* Get all line annotations on this page.
|
|
5975
5984
|
*/
|
|
5976
|
-
getLineAnnotations():
|
|
5985
|
+
getLineAnnotations(): PDFLineAnnotation[];
|
|
5977
5986
|
/**
|
|
5978
5987
|
* Get all square annotations on this page.
|
|
5979
5988
|
*/
|
|
5980
|
-
getSquareAnnotations():
|
|
5989
|
+
getSquareAnnotations(): PDFSquareAnnotation[];
|
|
5981
5990
|
/**
|
|
5982
5991
|
* Get all circle annotations on this page.
|
|
5983
5992
|
*/
|
|
5984
|
-
getCircleAnnotations():
|
|
5993
|
+
getCircleAnnotations(): PDFCircleAnnotation[];
|
|
5985
5994
|
/**
|
|
5986
5995
|
* Get all stamp annotations on this page.
|
|
5987
5996
|
*/
|
|
5988
|
-
getStampAnnotations():
|
|
5997
|
+
getStampAnnotations(): PDFStampAnnotation[];
|
|
5989
5998
|
/**
|
|
5990
5999
|
* Get all ink annotations on this page.
|
|
5991
6000
|
*/
|
|
5992
|
-
getInkAnnotations():
|
|
6001
|
+
getInkAnnotations(): PDFInkAnnotation[];
|
|
5993
6002
|
/**
|
|
5994
6003
|
* Get all polygon annotations on this page.
|
|
5995
6004
|
*/
|
|
5996
|
-
getPolygonAnnotations():
|
|
6005
|
+
getPolygonAnnotations(): PDFPolygonAnnotation[];
|
|
5997
6006
|
/**
|
|
5998
6007
|
* Get all polyline annotations on this page.
|
|
5999
6008
|
*/
|
|
6000
|
-
getPolylineAnnotations():
|
|
6009
|
+
getPolylineAnnotations(): PDFPolylineAnnotation[];
|
|
6001
6010
|
/**
|
|
6002
6011
|
* Get all caret annotations on this page.
|
|
6003
6012
|
*/
|
|
6004
|
-
getCaretAnnotations():
|
|
6013
|
+
getCaretAnnotations(): PDFCaretAnnotation[];
|
|
6005
6014
|
/**
|
|
6006
6015
|
* Get all file attachment annotations on this page.
|
|
6007
6016
|
*/
|
|
6008
|
-
getFileAttachmentAnnotations():
|
|
6017
|
+
getFileAttachmentAnnotations(): PDFFileAttachmentAnnotation[];
|
|
6009
6018
|
/**
|
|
6010
6019
|
* Add a highlight annotation.
|
|
6011
6020
|
*
|
|
@@ -6126,11 +6135,11 @@ declare class PDFPage {
|
|
|
6126
6135
|
*
|
|
6127
6136
|
* @example
|
|
6128
6137
|
* ```typescript
|
|
6129
|
-
* const highlights =
|
|
6130
|
-
*
|
|
6138
|
+
* const highlights = page.getHighlightAnnotations();
|
|
6139
|
+
* page.removeAnnotation(highlights[0]);
|
|
6131
6140
|
* ```
|
|
6132
6141
|
*/
|
|
6133
|
-
removeAnnotation(annotation: PDFAnnotation):
|
|
6142
|
+
removeAnnotation(annotation: PDFAnnotation): void;
|
|
6134
6143
|
/**
|
|
6135
6144
|
* Remove annotations from the page.
|
|
6136
6145
|
*
|
|
@@ -6142,13 +6151,13 @@ declare class PDFPage {
|
|
|
6142
6151
|
* @example
|
|
6143
6152
|
* ```typescript
|
|
6144
6153
|
* // Remove all highlights
|
|
6145
|
-
*
|
|
6154
|
+
* page.removeAnnotations({ type: "Highlight" });
|
|
6146
6155
|
*
|
|
6147
6156
|
* // Remove all annotations
|
|
6148
|
-
*
|
|
6157
|
+
* page.removeAnnotations();
|
|
6149
6158
|
* ```
|
|
6150
6159
|
*/
|
|
6151
|
-
removeAnnotations(options?: RemoveAnnotationsOptions):
|
|
6160
|
+
removeAnnotations(options?: RemoveAnnotationsOptions): void;
|
|
6152
6161
|
/**
|
|
6153
6162
|
* Add an annotation reference to the page's /Annots array.
|
|
6154
6163
|
* Internal method - also invalidates the annotation cache.
|
|
@@ -6227,7 +6236,7 @@ declare class PDFPage {
|
|
|
6227
6236
|
*
|
|
6228
6237
|
* @example
|
|
6229
6238
|
* ```typescript
|
|
6230
|
-
* const pageText =
|
|
6239
|
+
* const pageText = page.extractText();
|
|
6231
6240
|
* console.log(pageText.text); // Plain text
|
|
6232
6241
|
*
|
|
6233
6242
|
* // Access structured content
|
|
@@ -6236,7 +6245,7 @@ declare class PDFPage {
|
|
|
6236
6245
|
* }
|
|
6237
6246
|
* ```
|
|
6238
6247
|
*/
|
|
6239
|
-
extractText(_options?: ExtractTextOptions):
|
|
6248
|
+
extractText(_options?: ExtractTextOptions): PageText;
|
|
6240
6249
|
/**
|
|
6241
6250
|
* Search for text on this page.
|
|
6242
6251
|
*
|
|
@@ -6247,16 +6256,16 @@ declare class PDFPage {
|
|
|
6247
6256
|
* @example
|
|
6248
6257
|
* ```typescript
|
|
6249
6258
|
* // String search
|
|
6250
|
-
* const matches =
|
|
6259
|
+
* const matches = page.findText("{{ name }}");
|
|
6251
6260
|
* for (const match of matches) {
|
|
6252
6261
|
* console.log(`Found at:`, match.bbox);
|
|
6253
6262
|
* }
|
|
6254
6263
|
*
|
|
6255
6264
|
* // Regex search
|
|
6256
|
-
* const placeholders =
|
|
6265
|
+
* const placeholders = page.findText(/\{\{\s*\w+\s*\}\}/g);
|
|
6257
6266
|
* ```
|
|
6258
6267
|
*/
|
|
6259
|
-
findText(query: string | RegExp, options?: FindTextOptions):
|
|
6268
|
+
findText(query: string | RegExp, options?: FindTextOptions): TextMatch[];
|
|
6260
6269
|
/**
|
|
6261
6270
|
* Get the concatenated content stream bytes.
|
|
6262
6271
|
*/
|
|
@@ -6373,11 +6382,11 @@ declare class PDFFonts {
|
|
|
6373
6382
|
*
|
|
6374
6383
|
* @param subsetFonts - Whether to subset fonts (only include used glyphs)
|
|
6375
6384
|
*/
|
|
6376
|
-
finalize(subsetFonts: boolean):
|
|
6385
|
+
finalize(subsetFonts: boolean): void;
|
|
6377
6386
|
/**
|
|
6378
6387
|
* @deprecated Use `finalize()` instead. This method exists for backwards compatibility.
|
|
6379
6388
|
*/
|
|
6380
|
-
prepare():
|
|
6389
|
+
prepare(): void;
|
|
6381
6390
|
}
|
|
6382
6391
|
//#endregion
|
|
6383
6392
|
//#region src/document/forms/field-tree.d.ts
|
|
@@ -6387,7 +6396,7 @@ declare class PDFFonts {
|
|
|
6387
6396
|
interface FieldTreeSource {
|
|
6388
6397
|
getDict(): PdfDict;
|
|
6389
6398
|
defaultQuadding: number;
|
|
6390
|
-
updateFieldAppearance?(field: TerminalField):
|
|
6399
|
+
updateFieldAppearance?(field: TerminalField): void;
|
|
6391
6400
|
}
|
|
6392
6401
|
/**
|
|
6393
6402
|
* FieldTree provides safe, synchronous iteration over the form field hierarchy.
|
|
@@ -6426,7 +6435,7 @@ declare class FieldTree implements Iterable<FormField> {
|
|
|
6426
6435
|
* @param registry The object registry for resolving references
|
|
6427
6436
|
* @returns A fully-loaded FieldTree
|
|
6428
6437
|
*/
|
|
6429
|
-
static load(acroForm: FieldTreeSource, registry: ObjectRegistry):
|
|
6438
|
+
static load(acroForm: FieldTreeSource, registry: ObjectRegistry): FieldTree;
|
|
6430
6439
|
/**
|
|
6431
6440
|
* Iterate over all fields (terminal and non-terminal).
|
|
6432
6441
|
* Fields are yielded in breadth-first order.
|
|
@@ -6509,11 +6518,11 @@ declare class AcroForm implements AcroFormLike {
|
|
|
6509
6518
|
* @param registry The object registry for resolving references
|
|
6510
6519
|
* @param pageTree Optional page tree for efficient page lookups during flattening
|
|
6511
6520
|
*/
|
|
6512
|
-
static load(catalog: PdfDict, registry: ObjectRegistry, pageTree?: PDFPageTree):
|
|
6521
|
+
static load(catalog: PdfDict, registry: ObjectRegistry, pageTree?: PDFPageTree): AcroForm | null;
|
|
6513
6522
|
/**
|
|
6514
6523
|
* Default resources dictionary (fonts, etc.).
|
|
6515
6524
|
*/
|
|
6516
|
-
getDefaultResources():
|
|
6525
|
+
getDefaultResources(): PdfDict | null;
|
|
6517
6526
|
/**
|
|
6518
6527
|
* Default appearance string.
|
|
6519
6528
|
*/
|
|
@@ -6546,16 +6555,16 @@ declare class AcroForm implements AcroFormLike {
|
|
|
6546
6555
|
* Get all terminal fields (flattened).
|
|
6547
6556
|
* Non-terminal fields (containers) are not included.
|
|
6548
6557
|
*/
|
|
6549
|
-
getFields():
|
|
6558
|
+
getFields(): TerminalField[];
|
|
6550
6559
|
/**
|
|
6551
6560
|
* Get field by fully-qualified name.
|
|
6552
6561
|
* Returns null if not found.
|
|
6553
6562
|
*/
|
|
6554
|
-
getField(name: string):
|
|
6563
|
+
getField(name: string): TerminalField | null;
|
|
6555
6564
|
/**
|
|
6556
6565
|
* Get all fields of a specific type.
|
|
6557
6566
|
*/
|
|
6558
|
-
getFieldsOfType<T extends TerminalField>(type: T["type"]):
|
|
6567
|
+
getFieldsOfType<T extends TerminalField>(type: T["type"]): T[];
|
|
6559
6568
|
/**
|
|
6560
6569
|
* Get the underlying dictionary.
|
|
6561
6570
|
*/
|
|
@@ -6584,7 +6593,7 @@ declare class AcroForm implements AcroFormLike {
|
|
|
6584
6593
|
* }
|
|
6585
6594
|
* ```
|
|
6586
6595
|
*/
|
|
6587
|
-
getFieldTree():
|
|
6596
|
+
getFieldTree(): FieldTree;
|
|
6588
6597
|
/**
|
|
6589
6598
|
* Clear the fields cache.
|
|
6590
6599
|
* Call this after modifying the form structure.
|
|
@@ -6635,7 +6644,7 @@ declare class AcroForm implements AcroFormLike {
|
|
|
6635
6644
|
*
|
|
6636
6645
|
* @internal
|
|
6637
6646
|
*/
|
|
6638
|
-
updateFieldAppearance(field: TerminalField):
|
|
6647
|
+
updateFieldAppearance(field: TerminalField): void;
|
|
6639
6648
|
/**
|
|
6640
6649
|
* Update appearances for all fields that need it.
|
|
6641
6650
|
*
|
|
@@ -6646,11 +6655,11 @@ declare class AcroForm implements AcroFormLike {
|
|
|
6646
6655
|
*/
|
|
6647
6656
|
updateAppearances(options?: {
|
|
6648
6657
|
forceRegenerate?: boolean;
|
|
6649
|
-
}):
|
|
6658
|
+
}): void;
|
|
6650
6659
|
/**
|
|
6651
6660
|
* Mark all fields as needing appearance update.
|
|
6652
6661
|
*/
|
|
6653
|
-
markAllNeedAppearanceUpdate():
|
|
6662
|
+
markAllNeedAppearanceUpdate(): void;
|
|
6654
6663
|
/**
|
|
6655
6664
|
* Collect all terminal fields from a /Kids or /Fields array.
|
|
6656
6665
|
*/
|
|
@@ -6684,6 +6693,16 @@ declare class AcroForm implements AcroFormLike {
|
|
|
6684
6693
|
* @param fieldRef Reference to the field dictionary
|
|
6685
6694
|
*/
|
|
6686
6695
|
addField(fieldRef: PdfRef): void;
|
|
6696
|
+
/**
|
|
6697
|
+
* Remove a field reference from the Fields array.
|
|
6698
|
+
*
|
|
6699
|
+
* This only removes the field from the AcroForm's /Fields array.
|
|
6700
|
+
* Widget removal from pages must be handled separately.
|
|
6701
|
+
*
|
|
6702
|
+
* @param fieldRef Reference to the field dictionary to remove
|
|
6703
|
+
* @returns true if the field was found and removed, false otherwise
|
|
6704
|
+
*/
|
|
6705
|
+
removeField(fieldRef: PdfRef): boolean;
|
|
6687
6706
|
/**
|
|
6688
6707
|
* Flatten all form fields into static page content.
|
|
6689
6708
|
*
|
|
@@ -6699,7 +6718,7 @@ declare class AcroForm implements AcroFormLike {
|
|
|
6699
6718
|
*
|
|
6700
6719
|
* @param options Flattening options
|
|
6701
6720
|
*/
|
|
6702
|
-
flatten(options?: FlattenOptions):
|
|
6721
|
+
flatten(options?: FlattenOptions): void;
|
|
6703
6722
|
}
|
|
6704
6723
|
//#endregion
|
|
6705
6724
|
//#region src/helpers/rotations.d.ts
|
|
@@ -6881,7 +6900,7 @@ declare class PDFForm {
|
|
|
6881
6900
|
* @param ctx The PDF context
|
|
6882
6901
|
* @returns PDFForm instance, or null if no form exists
|
|
6883
6902
|
*/
|
|
6884
|
-
static load(ctx: PDFContext):
|
|
6903
|
+
static load(ctx: PDFContext): PDFForm | null;
|
|
6885
6904
|
/**
|
|
6886
6905
|
* Get all form fields.
|
|
6887
6906
|
*/
|
|
@@ -7101,6 +7120,30 @@ declare class PDFForm {
|
|
|
7101
7120
|
* ```
|
|
7102
7121
|
*/
|
|
7103
7122
|
createListbox(name: string, options: ListboxOptions): ListBoxField;
|
|
7123
|
+
/**
|
|
7124
|
+
* Remove a form field from the document.
|
|
7125
|
+
*
|
|
7126
|
+
* This removes the field from the AcroForm and all its widget annotations
|
|
7127
|
+
* from their respective pages.
|
|
7128
|
+
*
|
|
7129
|
+
* @param fieldOrName - The field instance or field name to remove
|
|
7130
|
+
* @returns true if the field was found and removed, false otherwise
|
|
7131
|
+
*
|
|
7132
|
+
* @example
|
|
7133
|
+
* ```typescript
|
|
7134
|
+
* // Remove by field instance
|
|
7135
|
+
* const nameField = form.getTextField("name");
|
|
7136
|
+
* form.removeField(nameField);
|
|
7137
|
+
*
|
|
7138
|
+
* // Remove by name
|
|
7139
|
+
* form.removeField("email");
|
|
7140
|
+
* ```
|
|
7141
|
+
*/
|
|
7142
|
+
removeField(fieldOrName: FormField | string): boolean;
|
|
7143
|
+
/**
|
|
7144
|
+
* Remove all widgets of a field from their respective pages.
|
|
7145
|
+
*/
|
|
7146
|
+
private removeWidgetsFromPages;
|
|
7104
7147
|
/**
|
|
7105
7148
|
* Validate that a field name is unique.
|
|
7106
7149
|
*/
|
|
@@ -7139,14 +7182,14 @@ declare class PDFForm {
|
|
|
7139
7182
|
* // result.skipped: ["nonexistent"]
|
|
7140
7183
|
* ```
|
|
7141
7184
|
*/
|
|
7142
|
-
fill(values: Record<string, FieldValue>):
|
|
7185
|
+
fill(values: Record<string, FieldValue>): {
|
|
7143
7186
|
filled: string[];
|
|
7144
7187
|
skipped: string[];
|
|
7145
|
-
}
|
|
7188
|
+
};
|
|
7146
7189
|
/**
|
|
7147
7190
|
* Reset all fields to their default values.
|
|
7148
7191
|
*/
|
|
7149
|
-
resetAll():
|
|
7192
|
+
resetAll(): void;
|
|
7150
7193
|
/**
|
|
7151
7194
|
* Get form-level properties.
|
|
7152
7195
|
*/
|
|
@@ -7176,14 +7219,14 @@ declare class PDFForm {
|
|
|
7176
7219
|
* Call this if the form structure has been modified externally
|
|
7177
7220
|
* (e.g., fields added or removed via low-level API).
|
|
7178
7221
|
*/
|
|
7179
|
-
reloadFields():
|
|
7222
|
+
reloadFields(): void;
|
|
7180
7223
|
/**
|
|
7181
7224
|
* Update appearance streams for all modified fields.
|
|
7182
7225
|
*
|
|
7183
7226
|
* This regenerates the visual appearance of fields whose values have changed.
|
|
7184
7227
|
* Called automatically during `flatten()`.
|
|
7185
7228
|
*/
|
|
7186
|
-
updateAppearances():
|
|
7229
|
+
updateAppearances(): void;
|
|
7187
7230
|
/**
|
|
7188
7231
|
* Flatten all form fields into static page content.
|
|
7189
7232
|
*
|
|
@@ -7203,7 +7246,7 @@ declare class PDFForm {
|
|
|
7203
7246
|
* const bytes = await pdf.save();
|
|
7204
7247
|
* ```
|
|
7205
7248
|
*/
|
|
7206
|
-
flatten(options?: FlattenOptions):
|
|
7249
|
+
flatten(options?: FlattenOptions): void;
|
|
7207
7250
|
/**
|
|
7208
7251
|
* Get the underlying AcroForm for low-level operations.
|
|
7209
7252
|
*
|
|
@@ -7862,18 +7905,18 @@ declare class PDF {
|
|
|
7862
7905
|
*
|
|
7863
7906
|
* Objects are cached and tracked for modifications.
|
|
7864
7907
|
*/
|
|
7865
|
-
getObject(ref: PdfRef):
|
|
7908
|
+
getObject(ref: PdfRef): PdfObject | null;
|
|
7866
7909
|
/**
|
|
7867
7910
|
* Get the document catalog dictionary.
|
|
7868
7911
|
*
|
|
7869
7912
|
* Note: For internal use, prefer accessing the catalog via context which
|
|
7870
7913
|
* provides higher-level methods for working with catalog structures.
|
|
7871
7914
|
*/
|
|
7872
|
-
getCatalog():
|
|
7915
|
+
getCatalog(): PdfDict;
|
|
7873
7916
|
/**
|
|
7874
7917
|
* Get all pages in document order.
|
|
7875
7918
|
*/
|
|
7876
|
-
getPages():
|
|
7919
|
+
getPages(): PDFPage[];
|
|
7877
7920
|
/**
|
|
7878
7921
|
* Get page count.
|
|
7879
7922
|
*/
|
|
@@ -7882,7 +7925,15 @@ declare class PDF {
|
|
|
7882
7925
|
* Get a single page by index (0-based).
|
|
7883
7926
|
* Returns null if index out of bounds.
|
|
7884
7927
|
*/
|
|
7885
|
-
getPage(index: number):
|
|
7928
|
+
getPage(index: number): PDFPage | null;
|
|
7929
|
+
/**
|
|
7930
|
+
* Ensure page resources are resolved (not a reference).
|
|
7931
|
+
*
|
|
7932
|
+
* Pages may have Resources as a PdfRef pointing to a shared resources dict.
|
|
7933
|
+
* The sync getResources() method on PDFPage needs the actual dict, not a ref.
|
|
7934
|
+
* This resolves the reference and replaces it in the page dict.
|
|
7935
|
+
*/
|
|
7936
|
+
private ensurePageResourcesResolved;
|
|
7886
7937
|
/**
|
|
7887
7938
|
* Add a new blank page.
|
|
7888
7939
|
*
|
|
@@ -8075,7 +8126,7 @@ declare class PDF {
|
|
|
8075
8126
|
* page.drawImage(image, { x: 50, y: 500 });
|
|
8076
8127
|
* ```
|
|
8077
8128
|
*/
|
|
8078
|
-
embedImage(bytes: Uint8Array):
|
|
8129
|
+
embedImage(bytes: Uint8Array): PDFImage;
|
|
8079
8130
|
/**
|
|
8080
8131
|
* Embed a JPEG image into the document.
|
|
8081
8132
|
*
|
|
@@ -8096,7 +8147,7 @@ declare class PDF {
|
|
|
8096
8147
|
* });
|
|
8097
8148
|
* ```
|
|
8098
8149
|
*/
|
|
8099
|
-
embedJpeg(bytes: Uint8Array):
|
|
8150
|
+
embedJpeg(bytes: Uint8Array): PDFImage;
|
|
8100
8151
|
/**
|
|
8101
8152
|
* Embed a PNG image into the document.
|
|
8102
8153
|
*
|
|
@@ -8115,7 +8166,7 @@ declare class PDF {
|
|
|
8115
8166
|
* page.drawImage(logo, { x: 100, y: 700, width: 150 });
|
|
8116
8167
|
* ```
|
|
8117
8168
|
*/
|
|
8118
|
-
embedPng(bytes: Uint8Array):
|
|
8169
|
+
embedPng(bytes: Uint8Array): PDFImage;
|
|
8119
8170
|
/**
|
|
8120
8171
|
* Access the attachments API for managing file attachments.
|
|
8121
8172
|
*
|
|
@@ -8144,7 +8195,7 @@ declare class PDF {
|
|
|
8144
8195
|
*
|
|
8145
8196
|
* @returns Map of attachment name to attachment info
|
|
8146
8197
|
*/
|
|
8147
|
-
getAttachments():
|
|
8198
|
+
getAttachments(): Map<string, AttachmentInfo>;
|
|
8148
8199
|
/**
|
|
8149
8200
|
* Get the raw bytes of an attachment.
|
|
8150
8201
|
*
|
|
@@ -8153,7 +8204,7 @@ declare class PDF {
|
|
|
8153
8204
|
* @param name The attachment name (key in the EmbeddedFiles tree)
|
|
8154
8205
|
* @returns The attachment bytes, or null if not found
|
|
8155
8206
|
*/
|
|
8156
|
-
getAttachment(name: string):
|
|
8207
|
+
getAttachment(name: string): Uint8Array | null;
|
|
8157
8208
|
/**
|
|
8158
8209
|
* Check if an attachment exists.
|
|
8159
8210
|
*
|
|
@@ -8162,7 +8213,7 @@ declare class PDF {
|
|
|
8162
8213
|
* @param name The attachment name
|
|
8163
8214
|
* @returns True if the attachment exists
|
|
8164
8215
|
*/
|
|
8165
|
-
hasAttachment(name: string):
|
|
8216
|
+
hasAttachment(name: string): boolean;
|
|
8166
8217
|
/**
|
|
8167
8218
|
* Add a file attachment to the document.
|
|
8168
8219
|
*
|
|
@@ -8173,7 +8224,7 @@ declare class PDF {
|
|
|
8173
8224
|
* @param options - Attachment options (description, MIME type, dates)
|
|
8174
8225
|
* @throws {Error} If name already exists and overwrite !== true
|
|
8175
8226
|
*/
|
|
8176
|
-
addAttachment(name: string, data: Uint8Array, options?: AddAttachmentOptions):
|
|
8227
|
+
addAttachment(name: string, data: Uint8Array, options?: AddAttachmentOptions): void;
|
|
8177
8228
|
/**
|
|
8178
8229
|
* Remove an attachment from the document.
|
|
8179
8230
|
*
|
|
@@ -8182,7 +8233,7 @@ declare class PDF {
|
|
|
8182
8233
|
* @param name The attachment name
|
|
8183
8234
|
* @returns True if the attachment was removed, false if not found
|
|
8184
8235
|
*/
|
|
8185
|
-
removeAttachment(name: string):
|
|
8236
|
+
removeAttachment(name: string): boolean;
|
|
8186
8237
|
/**
|
|
8187
8238
|
* Check if the document has an interactive form (AcroForm).
|
|
8188
8239
|
*
|
|
@@ -8230,7 +8281,7 @@ declare class PDF {
|
|
|
8230
8281
|
* await pdf.save({ incremental: true });
|
|
8231
8282
|
* ```
|
|
8232
8283
|
*/
|
|
8233
|
-
getForm():
|
|
8284
|
+
getForm(): PDFForm | null;
|
|
8234
8285
|
/**
|
|
8235
8286
|
* Get or create the document's interactive form.
|
|
8236
8287
|
*
|
|
@@ -8246,7 +8297,7 @@ declare class PDF {
|
|
|
8246
8297
|
* const nameField = form.createTextField("name", { fontSize: 12 });
|
|
8247
8298
|
* ```
|
|
8248
8299
|
*/
|
|
8249
|
-
getOrCreateForm():
|
|
8300
|
+
getOrCreateForm(): PDFForm;
|
|
8250
8301
|
/**
|
|
8251
8302
|
* Sign the PDF document.
|
|
8252
8303
|
*
|
|
@@ -8296,7 +8347,7 @@ declare class PDF {
|
|
|
8296
8347
|
* }
|
|
8297
8348
|
* ```
|
|
8298
8349
|
*/
|
|
8299
|
-
hasLayers():
|
|
8350
|
+
hasLayers(): boolean;
|
|
8300
8351
|
/**
|
|
8301
8352
|
* Get information about all layers in the document.
|
|
8302
8353
|
*
|
|
@@ -8313,7 +8364,7 @@ declare class PDF {
|
|
|
8313
8364
|
* }
|
|
8314
8365
|
* ```
|
|
8315
8366
|
*/
|
|
8316
|
-
getLayers():
|
|
8367
|
+
getLayers(): LayerInfo[];
|
|
8317
8368
|
/**
|
|
8318
8369
|
* Flatten all Optional Content Groups (layers) in the document.
|
|
8319
8370
|
*
|
|
@@ -8343,7 +8394,7 @@ declare class PDF {
|
|
|
8343
8394
|
* await pdf.sign({ signer });
|
|
8344
8395
|
* ```
|
|
8345
8396
|
*/
|
|
8346
|
-
flattenLayers():
|
|
8397
|
+
flattenLayers(): FlattenLayersResult;
|
|
8347
8398
|
/**
|
|
8348
8399
|
* Extract text from all pages in the document.
|
|
8349
8400
|
*
|
|
@@ -8360,7 +8411,7 @@ declare class PDF {
|
|
|
8360
8411
|
* }
|
|
8361
8412
|
* ```
|
|
8362
8413
|
*/
|
|
8363
|
-
extractText():
|
|
8414
|
+
extractText(): PageText[];
|
|
8364
8415
|
/**
|
|
8365
8416
|
* Search for text across all pages in the document.
|
|
8366
8417
|
*
|
|
@@ -8383,7 +8434,7 @@ declare class PDF {
|
|
|
8383
8434
|
* const placeholders = await pdf.findText(/\{\{\s*\w+\s*\}\}/g);
|
|
8384
8435
|
* ```
|
|
8385
8436
|
*/
|
|
8386
|
-
findText(query: string | RegExp, options?: FindTextOptions):
|
|
8437
|
+
findText(query: string | RegExp, options?: FindTextOptions): TextMatch[];
|
|
8387
8438
|
/**
|
|
8388
8439
|
* Check if the document has unsaved changes.
|
|
8389
8440
|
*/
|