pdf-lite 1.5.0 → 1.6.1
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/pdf-button-appearance-stream.d.ts +1 -1
- package/dist/acroform/appearance/pdf-button-appearance-stream.js +6 -2
- package/dist/acroform/fields/pdf-button-form-field.d.ts +0 -9
- package/dist/acroform/fields/pdf-button-form-field.js +7 -39
- package/dist/acroform/fields/pdf-choice-form-field.d.ts +2 -1
- package/dist/acroform/fields/pdf-choice-form-field.js +19 -38
- package/dist/acroform/fields/pdf-default-appearance.js +1 -1
- package/dist/acroform/fields/pdf-form-field.d.ts +27 -32
- package/dist/acroform/fields/pdf-form-field.js +180 -94
- package/dist/acroform/fields/pdf-text-form-field.js +6 -33
- package/dist/acroform/fields/types.d.ts +1 -1
- package/dist/acroform/index.d.ts +0 -2
- package/dist/acroform/index.js +0 -2
- package/dist/acroform/pdf-acro-form.d.ts +12 -36
- package/dist/acroform/pdf-acro-form.js +111 -201
- package/dist/acroform/xfa/pdf-xfa-data.d.ts +4 -3
- package/dist/acroform/xfa/pdf-xfa-data.js +16 -12
- package/dist/acroform/xfa/pdf-xfa-form.d.ts +9 -4
- package/dist/acroform/xfa/pdf-xfa-form.js +17 -39
- package/dist/annotations/index.d.ts +0 -1
- package/dist/annotations/index.js +0 -1
- package/dist/annotations/pdf-annotation.d.ts +7 -2
- package/dist/annotations/pdf-annotation.js +30 -19
- package/dist/annotations/pdf-default-resources.d.ts +11 -0
- package/dist/annotations/pdf-default-resources.js +3 -0
- 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 +47 -7
- package/dist/core/objects/pdf-stream.js +301 -32
- 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/ref.d.ts +3 -1
- package/dist/core/ref.js +8 -5
- package/dist/core/tokens/token.d.ts +2 -1
- package/dist/core/tokens/token.js +3 -0
- package/dist/fonts/index.d.ts +0 -1
- package/dist/fonts/index.js +0 -1
- package/dist/fonts/pdf-font.d.ts +32 -27
- package/dist/fonts/pdf-font.js +115 -77
- package/dist/pdf/index.d.ts +2 -0
- package/dist/pdf/index.js +2 -0
- package/dist/pdf/pdf-document.d.ts +63 -37
- package/dist/pdf/pdf-document.js +351 -135
- 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/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/needsCentralWhitespace.d.ts +10 -0
- package/dist/utils/needsCentralWhitespace.js +34 -0
- package/package.json +3 -3
- package/dist/acroform/acroform.d.ts +0 -9
- package/dist/acroform/acroform.js +0 -7
- package/dist/acroform/manager.d.ts +0 -37
- package/dist/acroform/manager.js +0 -57
- package/dist/acroform/pdf-font-encoding-cache.d.ts +0 -27
- package/dist/acroform/pdf-font-encoding-cache.js +0 -188
- package/dist/annotations/pdf-annotation-writer.d.ts +0 -20
- package/dist/annotations/pdf-annotation-writer.js +0 -76
- package/dist/fonts/manager.d.ts +0 -127
- package/dist/fonts/manager.js +0 -378
- package/dist/utils/predictors.d.ts +0 -113
- package/dist/utils/predictors.js +0 -279
|
@@ -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,23 @@ import { PdfFontManager } from '../fonts/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 _objStreamCache;
|
|
46
|
+
private _committing;
|
|
47
|
+
private _updating;
|
|
48
|
+
private _finalized;
|
|
49
|
+
private _signed;
|
|
46
50
|
/**
|
|
47
51
|
* Creates a new PDF document instance.
|
|
48
52
|
*
|
|
@@ -62,6 +66,9 @@ export declare class PdfDocument extends PdfObject {
|
|
|
62
66
|
securityHandler?: PdfSecurityHandler;
|
|
63
67
|
signer?: PdfSigner;
|
|
64
68
|
});
|
|
69
|
+
resolve(objectNumber: number, generationNumber: number): PdfIndirectObject;
|
|
70
|
+
get acroform(): PdfAcroForm | null;
|
|
71
|
+
get pages(): PdfPages;
|
|
65
72
|
get header(): PdfComment | undefined;
|
|
66
73
|
set header(comment: PdfComment | undefined);
|
|
67
74
|
/**
|
|
@@ -79,6 +86,7 @@ export declare class PdfDocument extends PdfObject {
|
|
|
79
86
|
* @returns The document instance for method chaining
|
|
80
87
|
*/
|
|
81
88
|
startNewRevision(): PdfDocument;
|
|
89
|
+
hasObjectInLatestRevision(obj: PdfObject): boolean;
|
|
82
90
|
/**
|
|
83
91
|
* Adds objects to the document's latest revision.
|
|
84
92
|
* Automatically starts a new revision if the current one is locked.
|
|
@@ -142,6 +150,7 @@ export declare class PdfDocument extends PdfObject {
|
|
|
142
150
|
* @returns The metadata stream reference or undefined if not present
|
|
143
151
|
*/
|
|
144
152
|
get metadataStreamReference(): PdfObjectReference | undefined;
|
|
153
|
+
resetSecurityHandler(): void;
|
|
145
154
|
private getSecurityHandler;
|
|
146
155
|
private initSecurityHandler;
|
|
147
156
|
/**
|
|
@@ -166,14 +175,28 @@ export declare class PdfDocument extends PdfObject {
|
|
|
166
175
|
*/
|
|
167
176
|
hasObject(obj: PdfObject): boolean;
|
|
168
177
|
private isObjectEncryptable;
|
|
178
|
+
commitIncrementalUpdates(): void;
|
|
179
|
+
/**
|
|
180
|
+
* Decrypts all encrypted object data in-place without removing
|
|
181
|
+
* the encryption infrastructure. Useful in incremental mode where
|
|
182
|
+
* the original (encrypted) bytes are preserved via cached tokens
|
|
183
|
+
* but the live object data needs to be readable.
|
|
184
|
+
*/
|
|
185
|
+
decryptObjects(): Promise<void>;
|
|
186
|
+
/**
|
|
187
|
+
* Re-encrypts all objects and updates the document structure.
|
|
188
|
+
* No-op if the document has no security handler (unencrypted document).
|
|
189
|
+
*/
|
|
190
|
+
finalize(): Promise<void>;
|
|
169
191
|
/**
|
|
170
192
|
* Decrypts all encrypted objects in the document.
|
|
171
193
|
* Removes the security handler and encryption dictionary after decryption.
|
|
172
194
|
*/
|
|
173
195
|
decrypt(): Promise<void>;
|
|
174
196
|
/**
|
|
175
|
-
* Encrypts all objects
|
|
176
|
-
*
|
|
197
|
+
* Encrypts all encryptable objects using the security handler.
|
|
198
|
+
* Re-uses the existing encryption dictionary or creates one if needed,
|
|
199
|
+
* propagating it to all revisions.
|
|
177
200
|
*/
|
|
178
201
|
encrypt(): Promise<void>;
|
|
179
202
|
/**
|
|
@@ -186,7 +209,7 @@ export declare class PdfDocument extends PdfObject {
|
|
|
186
209
|
findCompressedObject(options: {
|
|
187
210
|
objectNumber: number;
|
|
188
211
|
generationNumber?: number;
|
|
189
|
-
} | PdfObjectReference):
|
|
212
|
+
} | PdfObjectReference): PdfIndirectObject | undefined;
|
|
190
213
|
/**
|
|
191
214
|
* Finds an uncompressed indirect object by its object number.
|
|
192
215
|
*
|
|
@@ -212,13 +235,21 @@ export declare class PdfDocument extends PdfObject {
|
|
|
212
235
|
objectNumber: number;
|
|
213
236
|
generationNumber?: number;
|
|
214
237
|
allowUnindexed?: boolean;
|
|
215
|
-
|
|
238
|
+
cloned?: boolean;
|
|
239
|
+
}): PdfIndirectObject | undefined;
|
|
240
|
+
/**
|
|
241
|
+
* Finds the revision that contains a given PDF object.
|
|
242
|
+
* Useful for determining the origin of an object across multiple revisions.
|
|
243
|
+
* @param obj - The PDF object to find the revision for
|
|
244
|
+
* @returns The PdfRevision that contains the object, or undefined if not found in any revision
|
|
245
|
+
*/
|
|
246
|
+
findRevisionForObject(obj: PdfObject): PdfRevision | undefined;
|
|
216
247
|
/**
|
|
217
248
|
* Deletes an object from all revisions in the document.
|
|
218
249
|
*
|
|
219
250
|
* @param obj - The PDF object to delete
|
|
220
251
|
*/
|
|
221
|
-
deleteObject(obj: PdfObject | undefined):
|
|
252
|
+
deleteObject(obj: PdfObject | undefined): void;
|
|
222
253
|
/**
|
|
223
254
|
* Sets the PDF version for the document.
|
|
224
255
|
*
|
|
@@ -239,22 +270,6 @@ export declare class PdfDocument extends PdfObject {
|
|
|
239
270
|
* @returns True if all revisions are locked for incremental updates
|
|
240
271
|
*/
|
|
241
272
|
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
|
-
private ensureEncryptionDictionary;
|
|
250
|
-
/**
|
|
251
|
-
* Sets the Document Security Store (DSS) for the document.
|
|
252
|
-
* Used for long-term validation of digital signatures.
|
|
253
|
-
*
|
|
254
|
-
* @param dss - The Document Security Store object to set
|
|
255
|
-
* @throws Error if the document has no root dictionary
|
|
256
|
-
*/
|
|
257
|
-
setDocumentSecurityStore(dss: PdfDocumentSecurityStoreObject): Promise<void>;
|
|
258
273
|
/**
|
|
259
274
|
* Returns tokens paired with their source objects.
|
|
260
275
|
* Useful for debugging and analysis of document structure.
|
|
@@ -266,23 +281,30 @@ export declare class PdfDocument extends PdfObject {
|
|
|
266
281
|
object: PdfObject | undefined;
|
|
267
282
|
}[];
|
|
268
283
|
protected tokenize(): PdfToken[];
|
|
284
|
+
private wireResolvers;
|
|
285
|
+
private collectMissingReferences;
|
|
269
286
|
private linkRevisions;
|
|
270
287
|
private linkOffsets;
|
|
271
288
|
private calculateOffsets;
|
|
272
289
|
private updateRevisions;
|
|
290
|
+
/**
|
|
291
|
+
* Performs a full update cycle to ensure all revisions are consistent and offsets are correct.
|
|
292
|
+
*/
|
|
273
293
|
private update;
|
|
294
|
+
/**
|
|
295
|
+
* Walks all objects in the document and registers any newly created
|
|
296
|
+
* PdfIndirectObjects that are referenced but not yet part of the document
|
|
297
|
+
* (e.g. appearance streams created by generateAppearance).
|
|
298
|
+
*/
|
|
299
|
+
private registerNewReferences;
|
|
300
|
+
private flushResolvedCache;
|
|
301
|
+
sign(): Promise<void>;
|
|
274
302
|
/**
|
|
275
303
|
* Serializes the document to a byte array.
|
|
276
304
|
*
|
|
277
305
|
* @returns The PDF document as a Uint8Array
|
|
278
306
|
*/
|
|
279
307
|
toBytes(): ByteArray;
|
|
280
|
-
/**
|
|
281
|
-
* Serializes the document to a Base64-encoded string.
|
|
282
|
-
*
|
|
283
|
-
* @returns A promise that resolves to the PDF document as a Base64 string
|
|
284
|
-
*/
|
|
285
|
-
toBase64(): string;
|
|
286
308
|
/**
|
|
287
309
|
* Creates a deep copy of the document.
|
|
288
310
|
*
|
|
@@ -295,7 +317,11 @@ export declare class PdfDocument extends PdfObject {
|
|
|
295
317
|
* @param input - Async or sync iterable of byte arrays
|
|
296
318
|
* @returns A promise that resolves to the parsed PdfDocument
|
|
297
319
|
*/
|
|
298
|
-
static fromBytes(input: AsyncIterable<ByteArray> | Iterable<ByteArray
|
|
320
|
+
static fromBytes(input: AsyncIterable<ByteArray> | Iterable<ByteArray>, options?: {
|
|
321
|
+
password?: string;
|
|
322
|
+
ownerPassword?: string;
|
|
323
|
+
incremental?: boolean;
|
|
324
|
+
}): Promise<PdfDocument>;
|
|
299
325
|
isModified(): boolean;
|
|
300
326
|
/**
|
|
301
327
|
* Verifies all digital signatures in the document.
|