pdf-lite 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/EXAMPLES.md +51 -70
- package/README.md +1 -1
- package/dist/acroform/appearance/index.d.ts +4 -4
- package/dist/acroform/appearance/index.js +4 -4
- package/dist/acroform/appearance/{PdfAppearanceStream.d.ts → pdf-appearance-stream.d.ts} +9 -3
- package/dist/acroform/appearance/{PdfAppearanceStream.js → pdf-appearance-stream.js} +14 -5
- package/dist/acroform/appearance/{PdfButtonAppearanceStream.d.ts → pdf-button-appearance-stream.d.ts} +3 -2
- package/dist/acroform/appearance/pdf-button-appearance-stream.js +58 -0
- package/dist/acroform/appearance/pdf-choice-appearance-stream.d.ts +22 -0
- package/dist/acroform/appearance/pdf-choice-appearance-stream.js +75 -0
- package/dist/acroform/appearance/pdf-graphics.d.ts +51 -0
- package/dist/acroform/appearance/pdf-graphics.js +239 -0
- package/dist/acroform/appearance/{PdfTextAppearanceStream.d.ts → pdf-text-appearance-stream.d.ts} +7 -2
- package/dist/acroform/appearance/pdf-text-appearance-stream.js +104 -0
- package/dist/acroform/fields/index.d.ts +7 -7
- package/dist/acroform/fields/index.js +7 -7
- package/dist/acroform/fields/pdf-button-form-field.d.ts +14 -0
- package/dist/acroform/fields/pdf-button-form-field.js +70 -0
- package/dist/acroform/fields/pdf-choice-form-field.d.ts +19 -0
- package/dist/acroform/fields/pdf-choice-form-field.js +112 -0
- package/dist/acroform/fields/{PdfFormFieldFlags.d.ts → pdf-form-field-flags.d.ts} +5 -6
- package/dist/acroform/fields/{PdfFormFieldFlags.js → pdf-form-field-flags.js} +12 -18
- package/dist/acroform/fields/{PdfFormField.d.ts → pdf-form-field.d.ts} +37 -38
- package/dist/acroform/fields/pdf-form-field.js +519 -0
- package/dist/acroform/fields/{PdfSignatureFormField.d.ts → pdf-signature-form-field.d.ts} +1 -1
- package/dist/acroform/fields/{PdfSignatureFormField.js → pdf-signature-form-field.js} +1 -1
- package/dist/acroform/fields/{PdfTextFormField.d.ts → pdf-text-form-field.d.ts} +1 -1
- package/dist/acroform/fields/{PdfTextFormField.js → pdf-text-form-field.js} +11 -13
- package/dist/acroform/fields/types.d.ts +6 -1
- package/dist/acroform/index.d.ts +1 -3
- package/dist/acroform/index.js +1 -3
- package/dist/acroform/pdf-acro-form.d.ts +45 -0
- package/dist/acroform/pdf-acro-form.js +203 -0
- package/dist/acroform/xfa/index.d.ts +3 -3
- package/dist/acroform/xfa/index.js +2 -2
- package/dist/acroform/xfa/{PdfXfaData.d.ts → pdf-xfa-data.d.ts} +4 -3
- package/dist/acroform/xfa/{PdfXfaData.js → pdf-xfa-data.js} +16 -12
- package/dist/acroform/xfa/pdf-xfa-form.d.ts +16 -0
- package/dist/acroform/xfa/pdf-xfa-form.js +34 -0
- package/dist/annotations/index.d.ts +3 -4
- package/dist/annotations/index.js +3 -4
- package/dist/annotations/{PdfAnnotationFlags.d.ts → pdf-annotation-flags.d.ts} +3 -4
- package/dist/annotations/{PdfAnnotationFlags.js → pdf-annotation-flags.js} +5 -6
- package/dist/annotations/{PdfAnnotation.d.ts → pdf-annotation.d.ts} +31 -5
- package/dist/annotations/{PdfAnnotation.js → pdf-annotation.js} +31 -19
- package/dist/annotations/pdf-default-resources.d.ts +11 -0
- package/dist/annotations/pdf-default-resources.js +3 -0
- package/dist/annotations/{PdfWidgetAnnotation.d.ts → pdf-widget-annotation.d.ts} +1 -1
- package/dist/annotations/{PdfWidgetAnnotation.js → pdf-widget-annotation.js} +1 -1
- package/dist/core/decoder.js +1 -1
- package/dist/core/objects/pdf-array.d.ts +8 -1
- package/dist/core/objects/pdf-array.js +31 -0
- package/dist/core/objects/pdf-dictionary.d.ts +2 -0
- package/dist/core/objects/pdf-dictionary.js +14 -7
- package/dist/core/objects/pdf-hexadecimal.d.ts +1 -0
- package/dist/core/objects/pdf-hexadecimal.js +3 -3
- package/dist/core/objects/pdf-indirect-object.d.ts +18 -9
- package/dist/core/objects/pdf-indirect-object.js +75 -16
- package/dist/core/objects/pdf-number.d.ts +1 -0
- package/dist/core/objects/pdf-number.js +5 -4
- package/dist/core/objects/pdf-object-reference.d.ts +8 -1
- package/dist/core/objects/pdf-object-reference.js +14 -0
- package/dist/core/objects/pdf-object.d.ts +14 -0
- package/dist/core/objects/pdf-object.js +36 -0
- package/dist/core/objects/pdf-start-xref.d.ts +1 -0
- package/dist/core/objects/pdf-start-xref.js +4 -0
- package/dist/core/objects/pdf-stream.d.ts +44 -7
- package/dist/core/objects/pdf-stream.js +284 -26
- package/dist/core/objects/pdf-string.d.ts +1 -0
- package/dist/core/objects/pdf-string.js +3 -6
- package/dist/core/objects/pdf-trailer.d.ts +1 -0
- package/dist/core/objects/pdf-trailer.js +6 -3
- package/dist/core/objects/pdf-xref-table.js +1 -1
- package/dist/core/parser/incremental-parser.d.ts +0 -13
- package/dist/core/parser/incremental-parser.js +1 -18
- package/dist/core/ref.d.ts +3 -1
- package/dist/core/ref.js +8 -5
- package/dist/core/streams/object-stream.d.ts +1 -1
- package/dist/core/streams/object-stream.js +1 -1
- package/dist/core/tokens/token.d.ts +2 -1
- package/dist/core/tokens/token.js +3 -0
- package/dist/errors.d.ts +22 -0
- package/dist/errors.js +24 -0
- package/dist/fonts/index.d.ts +0 -1
- package/dist/fonts/index.js +0 -1
- package/dist/fonts/pdf-font.d.ts +94 -32
- package/dist/fonts/pdf-font.js +301 -83
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/pdf/index.d.ts +2 -1
- package/dist/pdf/index.js +2 -1
- package/dist/pdf/pdf-document.d.ts +61 -36
- package/dist/pdf/pdf-document.js +315 -117
- package/dist/pdf/pdf-page.d.ts +50 -0
- package/dist/pdf/pdf-page.js +144 -0
- package/dist/pdf/pdf-pages.d.ts +28 -0
- package/dist/pdf/pdf-pages.js +94 -0
- package/dist/pdf/pdf-reader.d.ts +5 -1
- package/dist/pdf/pdf-reader.js +36 -2
- package/dist/pdf/pdf-revision.d.ts +3 -3
- package/dist/pdf/pdf-revision.js +7 -7
- package/dist/pdf/pdf-xref-lookup.js +34 -14
- package/dist/signing/document-security-store.d.ts +14 -17
- package/dist/signing/document-security-store.js +19 -34
- package/dist/signing/signer.d.ts +23 -8
- package/dist/signing/signer.js +51 -17
- package/dist/utils/encodePdfText.d.ts +17 -0
- package/dist/utils/encodePdfText.js +61 -0
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/index.js +1 -2
- package/dist/utils/needsCentralWhitespace.d.ts +10 -0
- package/dist/utils/needsCentralWhitespace.js +34 -0
- package/package.json +3 -3
- package/dist/acroform/PdfAcroForm.d.ts +0 -63
- package/dist/acroform/PdfAcroForm.js +0 -279
- package/dist/acroform/PdfFontEncodingCache.d.ts +0 -16
- package/dist/acroform/PdfFontEncodingCache.js +0 -75
- package/dist/acroform/acroform.d.ts +0 -9
- package/dist/acroform/acroform.js +0 -7
- package/dist/acroform/appearance/PdfButtonAppearanceStream.js +0 -54
- package/dist/acroform/appearance/PdfChoiceAppearanceStream.d.ts +0 -15
- package/dist/acroform/appearance/PdfChoiceAppearanceStream.js +0 -48
- package/dist/acroform/appearance/PdfTextAppearanceStream.js +0 -75
- package/dist/acroform/fields/PdfButtonFormField.d.ts +0 -9
- package/dist/acroform/fields/PdfButtonFormField.js +0 -35
- package/dist/acroform/fields/PdfChoiceFormField.d.ts +0 -9
- package/dist/acroform/fields/PdfChoiceFormField.js +0 -46
- package/dist/acroform/fields/PdfFormField.js +0 -499
- package/dist/acroform/manager.d.ts +0 -33
- package/dist/acroform/manager.js +0 -51
- package/dist/acroform/xfa/PdfXfaForm.d.ts +0 -12
- package/dist/acroform/xfa/PdfXfaForm.js +0 -64
- package/dist/annotations/PdfAnnotationWriter.d.ts +0 -20
- package/dist/annotations/PdfAnnotationWriter.js +0 -76
- package/dist/fonts/font-manager.d.ts +0 -127
- package/dist/fonts/font-manager.js +0 -378
- package/dist/pdf/errors.d.ts +0 -6
- package/dist/pdf/errors.js +0 -6
- package/dist/utils/predictors.d.ts +0 -113
- package/dist/utils/predictors.js +0 -279
- /package/dist/acroform/fields/{PdfDefaultAppearance.d.ts → pdf-default-appearance.d.ts} +0 -0
- /package/dist/acroform/fields/{PdfDefaultAppearance.js → pdf-default-appearance.js} +0 -0
- /package/dist/utils/{IterableReadableStream.d.ts → iterable-readable-stream.d.ts} +0 -0
- /package/dist/utils/{IterableReadableStream.js → iterable-readable-stream.js} +0 -0
|
@@ -4,16 +4,15 @@ import { PdfIndirectObject } from '../core/objects/pdf-indirect-object.js';
|
|
|
4
4
|
import { PdfComment } from '../core/objects/pdf-comment.js';
|
|
5
5
|
import { PdfToken } from '../core/tokens/token.js';
|
|
6
6
|
import { PdfDictionary } from '../core/objects/pdf-dictionary.js';
|
|
7
|
-
import { PdfObjectReference } from '../core/objects/pdf-object-reference.js';
|
|
7
|
+
import { IPdfObjectResolver, PdfObjectReference } from '../core/objects/pdf-object-reference.js';
|
|
8
8
|
import { PdfXrefLookup } from './pdf-xref-lookup.js';
|
|
9
9
|
import { PdfRevision } from './pdf-revision.js';
|
|
10
10
|
import { PdfEncryptionDictionaryObject } from '../security/types.js';
|
|
11
11
|
import { PdfTrailerEntries } from '../core/objects/pdf-trailer.js';
|
|
12
|
-
import { PdfDocumentSecurityStoreObject } from '../signing/document-security-store.js';
|
|
13
12
|
import { ByteArray } from '../types.js';
|
|
14
13
|
import { PdfDocumentVerificationResult, PdfSigner } from '../signing/signer.js';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
14
|
+
import { PdfAcroForm } from '../acroform/pdf-acro-form.js';
|
|
15
|
+
import { PdfPages } from './pdf-pages.js';
|
|
17
16
|
/**
|
|
18
17
|
* Represents a PDF document with support for reading, writing, and modifying PDF files.
|
|
19
18
|
* Handles document structure, revisions, encryption, and digital signatures.
|
|
@@ -31,18 +30,21 @@ import { PdfFontManager } from '../fonts/font-manager.js';
|
|
|
31
30
|
* await document.commit()
|
|
32
31
|
* ```
|
|
33
32
|
*/
|
|
34
|
-
export declare class PdfDocument extends PdfObject {
|
|
33
|
+
export declare class PdfDocument extends PdfObject implements IPdfObjectResolver {
|
|
35
34
|
/** List of document revisions for incremental updates */
|
|
36
35
|
revisions: PdfRevision[];
|
|
37
36
|
/** Signer instance for digital signature operations */
|
|
38
37
|
signer: PdfSigner;
|
|
39
38
|
/** Security handler for encryption/decryption operations */
|
|
40
39
|
securityHandler?: PdfSecurityHandler;
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
/** Whether the document is currently in incremental mode (appending changes as a new revision) */
|
|
41
|
+
private incremental;
|
|
42
|
+
private originalSecurityHandler?;
|
|
44
43
|
private hasEncryptionDictionary?;
|
|
45
|
-
private
|
|
44
|
+
private _resolvedCache;
|
|
45
|
+
private _committing;
|
|
46
|
+
private _finalized;
|
|
47
|
+
private _signed;
|
|
46
48
|
/**
|
|
47
49
|
* Creates a new PDF document instance.
|
|
48
50
|
*
|
|
@@ -62,6 +64,9 @@ export declare class PdfDocument extends PdfObject {
|
|
|
62
64
|
securityHandler?: PdfSecurityHandler;
|
|
63
65
|
signer?: PdfSigner;
|
|
64
66
|
});
|
|
67
|
+
resolve(objectNumber: number, generationNumber: number): PdfIndirectObject;
|
|
68
|
+
get acroform(): PdfAcroForm | null;
|
|
69
|
+
get pages(): PdfPages;
|
|
65
70
|
get header(): PdfComment | undefined;
|
|
66
71
|
set header(comment: PdfComment | undefined);
|
|
67
72
|
/**
|
|
@@ -79,6 +84,7 @@ export declare class PdfDocument extends PdfObject {
|
|
|
79
84
|
* @returns The document instance for method chaining
|
|
80
85
|
*/
|
|
81
86
|
startNewRevision(): PdfDocument;
|
|
87
|
+
hasObjectInLatestRevision(obj: PdfObject): boolean;
|
|
82
88
|
/**
|
|
83
89
|
* Adds objects to the document's latest revision.
|
|
84
90
|
* Automatically starts a new revision if the current one is locked.
|
|
@@ -142,6 +148,7 @@ export declare class PdfDocument extends PdfObject {
|
|
|
142
148
|
* @returns The metadata stream reference or undefined if not present
|
|
143
149
|
*/
|
|
144
150
|
get metadataStreamReference(): PdfObjectReference | undefined;
|
|
151
|
+
resetSecurityHandler(): void;
|
|
145
152
|
private getSecurityHandler;
|
|
146
153
|
private initSecurityHandler;
|
|
147
154
|
/**
|
|
@@ -166,14 +173,28 @@ export declare class PdfDocument extends PdfObject {
|
|
|
166
173
|
*/
|
|
167
174
|
hasObject(obj: PdfObject): boolean;
|
|
168
175
|
private isObjectEncryptable;
|
|
176
|
+
commitIncrementalUpdates(): void;
|
|
177
|
+
/**
|
|
178
|
+
* Decrypts all encrypted object data in-place without removing
|
|
179
|
+
* the encryption infrastructure. Useful in incremental mode where
|
|
180
|
+
* the original (encrypted) bytes are preserved via cached tokens
|
|
181
|
+
* but the live object data needs to be readable.
|
|
182
|
+
*/
|
|
183
|
+
decryptObjects(): Promise<void>;
|
|
184
|
+
/**
|
|
185
|
+
* Re-encrypts all objects and updates the document structure.
|
|
186
|
+
* No-op if the document has no security handler (unencrypted document).
|
|
187
|
+
*/
|
|
188
|
+
finalize(): Promise<void>;
|
|
169
189
|
/**
|
|
170
190
|
* Decrypts all encrypted objects in the document.
|
|
171
191
|
* Removes the security handler and encryption dictionary after decryption.
|
|
172
192
|
*/
|
|
173
193
|
decrypt(): Promise<void>;
|
|
174
194
|
/**
|
|
175
|
-
* Encrypts all objects
|
|
176
|
-
*
|
|
195
|
+
* Encrypts all encryptable objects using the security handler.
|
|
196
|
+
* Re-uses the existing encryption dictionary or creates one if needed,
|
|
197
|
+
* propagating it to all revisions.
|
|
177
198
|
*/
|
|
178
199
|
encrypt(): Promise<void>;
|
|
179
200
|
/**
|
|
@@ -186,7 +207,7 @@ export declare class PdfDocument extends PdfObject {
|
|
|
186
207
|
findCompressedObject(options: {
|
|
187
208
|
objectNumber: number;
|
|
188
209
|
generationNumber?: number;
|
|
189
|
-
} | PdfObjectReference):
|
|
210
|
+
} | PdfObjectReference): PdfIndirectObject | undefined;
|
|
190
211
|
/**
|
|
191
212
|
* Finds an uncompressed indirect object by its object number.
|
|
192
213
|
*
|
|
@@ -212,13 +233,21 @@ export declare class PdfDocument extends PdfObject {
|
|
|
212
233
|
objectNumber: number;
|
|
213
234
|
generationNumber?: number;
|
|
214
235
|
allowUnindexed?: boolean;
|
|
215
|
-
|
|
236
|
+
cloned?: boolean;
|
|
237
|
+
}): PdfIndirectObject | undefined;
|
|
238
|
+
/**
|
|
239
|
+
* Finds the revision that contains a given PDF object.
|
|
240
|
+
* Useful for determining the origin of an object across multiple revisions.
|
|
241
|
+
* @param obj - The PDF object to find the revision for
|
|
242
|
+
* @returns The PdfRevision that contains the object, or undefined if not found in any revision
|
|
243
|
+
*/
|
|
244
|
+
findRevisionForObject(obj: PdfObject): PdfRevision | undefined;
|
|
216
245
|
/**
|
|
217
246
|
* Deletes an object from all revisions in the document.
|
|
218
247
|
*
|
|
219
248
|
* @param obj - The PDF object to delete
|
|
220
249
|
*/
|
|
221
|
-
deleteObject(obj: PdfObject | undefined):
|
|
250
|
+
deleteObject(obj: PdfObject | undefined): void;
|
|
222
251
|
/**
|
|
223
252
|
* Sets the PDF version for the document.
|
|
224
253
|
*
|
|
@@ -239,21 +268,6 @@ export declare class PdfDocument extends PdfObject {
|
|
|
239
268
|
* @returns True if all revisions are locked for incremental updates
|
|
240
269
|
*/
|
|
241
270
|
isIncremental(): boolean;
|
|
242
|
-
/**
|
|
243
|
-
* Commits pending objects to the document.
|
|
244
|
-
* Adds objects, applies encryption if configured, and updates the document structure.
|
|
245
|
-
*
|
|
246
|
-
* @param newObjects - Additional objects to add before committing
|
|
247
|
-
*/
|
|
248
|
-
commit(...newObjects: PdfObject[]): Promise<void>;
|
|
249
|
-
/**
|
|
250
|
-
* Sets the Document Security Store (DSS) for the document.
|
|
251
|
-
* Used for long-term validation of digital signatures.
|
|
252
|
-
*
|
|
253
|
-
* @param dss - The Document Security Store object to set
|
|
254
|
-
* @throws Error if the document has no root dictionary
|
|
255
|
-
*/
|
|
256
|
-
setDocumentSecurityStore(dss: PdfDocumentSecurityStoreObject): Promise<void>;
|
|
257
271
|
/**
|
|
258
272
|
* Returns tokens paired with their source objects.
|
|
259
273
|
* Useful for debugging and analysis of document structure.
|
|
@@ -265,23 +279,30 @@ export declare class PdfDocument extends PdfObject {
|
|
|
265
279
|
object: PdfObject | undefined;
|
|
266
280
|
}[];
|
|
267
281
|
protected tokenize(): PdfToken[];
|
|
282
|
+
private wireResolvers;
|
|
283
|
+
private collectMissingReferences;
|
|
268
284
|
private linkRevisions;
|
|
269
285
|
private linkOffsets;
|
|
270
286
|
private calculateOffsets;
|
|
271
287
|
private updateRevisions;
|
|
288
|
+
/**
|
|
289
|
+
* Performs a full update cycle to ensure all revisions are consistent and offsets are correct.
|
|
290
|
+
*/
|
|
272
291
|
private update;
|
|
292
|
+
/**
|
|
293
|
+
* Walks all objects in the document and registers any newly created
|
|
294
|
+
* PdfIndirectObjects that are referenced but not yet part of the document
|
|
295
|
+
* (e.g. appearance streams created by generateAppearance).
|
|
296
|
+
*/
|
|
297
|
+
private registerNewReferences;
|
|
298
|
+
private flushResolvedCache;
|
|
299
|
+
sign(): Promise<void>;
|
|
273
300
|
/**
|
|
274
301
|
* Serializes the document to a byte array.
|
|
275
302
|
*
|
|
276
303
|
* @returns The PDF document as a Uint8Array
|
|
277
304
|
*/
|
|
278
305
|
toBytes(): ByteArray;
|
|
279
|
-
/**
|
|
280
|
-
* Serializes the document to a Base64-encoded string.
|
|
281
|
-
*
|
|
282
|
-
* @returns A promise that resolves to the PDF document as a Base64 string
|
|
283
|
-
*/
|
|
284
|
-
toBase64(): string;
|
|
285
306
|
/**
|
|
286
307
|
* Creates a deep copy of the document.
|
|
287
308
|
*
|
|
@@ -294,7 +315,11 @@ export declare class PdfDocument extends PdfObject {
|
|
|
294
315
|
* @param input - Async or sync iterable of byte arrays
|
|
295
316
|
* @returns A promise that resolves to the parsed PdfDocument
|
|
296
317
|
*/
|
|
297
|
-
static fromBytes(input: AsyncIterable<ByteArray> | Iterable<ByteArray
|
|
318
|
+
static fromBytes(input: AsyncIterable<ByteArray> | Iterable<ByteArray>, options?: {
|
|
319
|
+
password?: string;
|
|
320
|
+
ownerPassword?: string;
|
|
321
|
+
incremental?: boolean;
|
|
322
|
+
}): Promise<PdfDocument>;
|
|
298
323
|
isModified(): boolean;
|
|
299
324
|
/**
|
|
300
325
|
* Verifies all digital signatures in the document.
|