pdf-lite 1.6.2 → 1.6.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/EXAMPLES.md +289 -0
- package/README.md +33 -9
- package/dist/acroform/fields/pdf-button-form-field.js +1 -1
- package/dist/acroform/fields/pdf-form-field.d.ts +5 -0
- package/dist/acroform/fields/pdf-form-field.js +33 -1
- package/dist/acroform/index.d.ts +1 -0
- package/dist/acroform/index.js +1 -0
- package/dist/acroform/js/index.d.ts +5 -0
- package/dist/acroform/js/index.js +5 -0
- package/dist/acroform/js/pdf-field-actions.d.ts +17 -0
- package/dist/acroform/js/pdf-field-actions.js +52 -0
- package/dist/acroform/js/pdf-javascript-action.d.ts +17 -0
- package/dist/acroform/js/pdf-javascript-action.js +38 -0
- package/dist/acroform/js/pdf-js-builtins.d.ts +12 -0
- package/dist/acroform/js/pdf-js-builtins.js +454 -0
- package/dist/acroform/js/pdf-js-engine-impl.d.ts +18 -0
- package/dist/acroform/js/pdf-js-engine-impl.js +22 -0
- package/dist/acroform/js/pdf-js-engine.d.ts +10 -0
- package/dist/acroform/js/pdf-js-engine.js +1 -0
- package/dist/acroform/pdf-acro-form.d.ts +4 -0
- package/dist/acroform/pdf-acro-form.js +58 -2
- package/dist/annotations/pdf-annotation.d.ts +20 -0
- package/dist/core/generators.js +12 -6
- package/dist/core/objects/pdf-dictionary.d.ts +3 -0
- package/dist/core/objects/pdf-dictionary.js +17 -0
- package/dist/core/parser/incremental-parser.d.ts +7 -2
- package/dist/core/parser/incremental-parser.js +9 -3
- package/package.json +1 -1
|
@@ -16,6 +16,9 @@ export class PdfDictionary extends PdfObject {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
+
keys() {
|
|
20
|
+
return Array.from(this.#entries.keys());
|
|
21
|
+
}
|
|
19
22
|
get(key) {
|
|
20
23
|
if (key instanceof PdfName) {
|
|
21
24
|
return this.#entries.get(key);
|
|
@@ -131,6 +134,20 @@ export class PdfDictionary extends PdfObject {
|
|
|
131
134
|
new PdfEndDictionaryToken(),
|
|
132
135
|
];
|
|
133
136
|
}
|
|
137
|
+
/** Factory-style type conversion: constructs a new instance passing `this` as the first argument */
|
|
138
|
+
becomes(cls, ...args) {
|
|
139
|
+
if (this instanceof cls)
|
|
140
|
+
return this;
|
|
141
|
+
const donor = new cls(this, ...args);
|
|
142
|
+
Object.setPrototypeOf(this, cls.prototype);
|
|
143
|
+
for (const key of Object.getOwnPropertyNames(donor)) {
|
|
144
|
+
if (!Object.prototype.hasOwnProperty.call(this, key)) {
|
|
145
|
+
;
|
|
146
|
+
this[key] = donor[key];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
134
151
|
copyFrom(other) {
|
|
135
152
|
for (const [key, value] of other.#entries) {
|
|
136
153
|
this.#entries.set(key, value);
|
|
@@ -70,8 +70,13 @@ export declare abstract class IncrementalParser<I, O> extends Parser<I, O> {
|
|
|
70
70
|
*/
|
|
71
71
|
protected compact(): void;
|
|
72
72
|
/**
|
|
73
|
-
* Override to customize when to compact the buffer
|
|
74
|
-
*
|
|
73
|
+
* Override to customize when to compact the buffer.
|
|
74
|
+
* Compacts when more than 1000 items have been consumed AND we've consumed
|
|
75
|
+
* at least half the buffer. The second condition prevents O(n²) behaviour
|
|
76
|
+
* when a single large chunk is fed all at once: without it, compact() is
|
|
77
|
+
* called O(n/1000) times, each copying O(n) elements → O(n²) total.
|
|
78
|
+
* By requiring bufferIndex ≥ buffer.length/2 we ensure at most O(log n)
|
|
79
|
+
* compactions, for O(n) total copies.
|
|
75
80
|
*
|
|
76
81
|
* @returns boolean indicating whether to compact the buffer
|
|
77
82
|
*/
|
|
@@ -139,13 +139,19 @@ export class IncrementalParser extends Parser {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
|
-
* Override to customize when to compact the buffer
|
|
143
|
-
*
|
|
142
|
+
* Override to customize when to compact the buffer.
|
|
143
|
+
* Compacts when more than 1000 items have been consumed AND we've consumed
|
|
144
|
+
* at least half the buffer. The second condition prevents O(n²) behaviour
|
|
145
|
+
* when a single large chunk is fed all at once: without it, compact() is
|
|
146
|
+
* called O(n/1000) times, each copying O(n) elements → O(n²) total.
|
|
147
|
+
* By requiring bufferIndex ≥ buffer.length/2 we ensure at most O(log n)
|
|
148
|
+
* compactions, for O(n) total copies.
|
|
144
149
|
*
|
|
145
150
|
* @returns boolean indicating whether to compact the buffer
|
|
146
151
|
*/
|
|
147
152
|
canCompact() {
|
|
148
|
-
return this.bufferIndex
|
|
153
|
+
return (this.bufferIndex >= 1000 &&
|
|
154
|
+
this.bufferIndex >= this.buffer.length >> 1);
|
|
149
155
|
}
|
|
150
156
|
/**
|
|
151
157
|
* Generates parsed output items from the buffer.
|