muhammara 2.4.0 → 3.0.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/CHANGELOG.md +43 -1
- package/README.md +7 -0
- package/muhammara.d.ts +264 -242
- package/muhammara.js +1 -1
- package/node_modules/minipass/LICENSE +1 -1
- package/node_modules/minipass/README.md +122 -7
- package/node_modules/minipass/index.d.ts +149 -0
- package/node_modules/minipass/index.js +191 -102
- package/node_modules/minipass/package.json +23 -7
- package/node_modules/safe-buffer/package.json +1 -0
- package/node_modules/set-blocking/package.json +1 -2
- package/node_modules/string-width/package.json +4 -1
- package/node_modules/strip-ansi/package.json +3 -1
- package/node_modules/tr46/package.json +1 -1
- package/node_modules/util-deprecate/package.json +1 -1
- package/node_modules/webidl-conversions/package.json +1 -1
- package/node_modules/whatwg-url/package.json +1 -1
- package/node_modules/wrappy/package.json +1 -1
- package/package.json +6 -5
- package/src/AbstractContentContextDriver.cpp +104 -35
- package/src/DocumentCopyingContextDriver.cpp +9 -9
- package/src/ObjectByteWriterWithPosition.cpp +15 -7
- package/src/ObjectsContextDriver.cpp +1 -1
- package/src/deps/PDFWriter/CFFANSIFontWriter.cpp +1 -1
- package/src/deps/PDFWriter/ETokenSeparator.h +1 -1
- package/src/deps/PDFWriter/ObjectsContext.h +1 -1
- package/src/deps/PDFWriter/PDFDocumentHandler.cpp +6 -2
- package/src/deps/PDFWriter/PrimitiveObjectsWriter.h +1 -1
- package/src/muhammara.cpp +1 -1
package/muhammara.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
declare module 'muhammara' {
|
|
2
|
+
import EventEmitter = require("events");
|
|
2
3
|
export type PosX = number;
|
|
3
4
|
export type PosY = number;
|
|
4
5
|
export type Width = number;
|
|
@@ -39,10 +40,10 @@ declare module 'muhammara' {
|
|
|
39
40
|
options?: PDFRecryptOptions,
|
|
40
41
|
): void;
|
|
41
42
|
export function recrypt(
|
|
42
|
-
originalPdfStream:
|
|
43
|
-
newPdfStream:
|
|
43
|
+
originalPdfStream: PDFRStreamForFile | PDFRStreamForBuffer,
|
|
44
|
+
newPdfStream: PDFWStreamForFile | PDFWStreamForBuffer,
|
|
44
45
|
options?: PDFRecryptOptions,
|
|
45
|
-
): void;
|
|
46
|
+
): void;
|
|
46
47
|
|
|
47
48
|
export interface WriteStream {
|
|
48
49
|
write(inBytesArray: any[]): number;
|
|
@@ -87,8 +88,10 @@ declare module 'muhammara' {
|
|
|
87
88
|
writePage(): this;
|
|
88
89
|
}
|
|
89
90
|
|
|
91
|
+
export type PDFImageType = 'JPG' | 'PDF' | 'PNG' | 'TIFF'
|
|
92
|
+
|
|
90
93
|
export interface PDFRStreamForFile extends ReadStream {
|
|
91
|
-
new (inPath:
|
|
94
|
+
new (inPath: FilePath): PDFRStreamForFile;
|
|
92
95
|
close(inCallback?: () => void): void;
|
|
93
96
|
}
|
|
94
97
|
|
|
@@ -106,6 +109,36 @@ declare module 'muhammara' {
|
|
|
106
109
|
width?: number;
|
|
107
110
|
close?: boolean;
|
|
108
111
|
}
|
|
112
|
+
export type TransformationMatrix = [a: number, b: number, c: number, d: number, e: number, f: number]
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
enum LineJoinStyle {
|
|
116
|
+
LINEJOIN_ROUND,
|
|
117
|
+
LINEJOIN_BEVEL,
|
|
118
|
+
LINEJOIN_MITER_VARIABLE,
|
|
119
|
+
LINEJOIN_MITER = 2,
|
|
120
|
+
LINEJOIN_MITER_FIXED = 3
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
enum EEncoding
|
|
124
|
+
{
|
|
125
|
+
EEncodingText = 'text',
|
|
126
|
+
EEncodingCode = 'code',
|
|
127
|
+
EEncodingHex = 'hex'
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
enum LineCapStyle {
|
|
131
|
+
LINECAP_BUTT = 0,
|
|
132
|
+
LINECAP_ROUND,
|
|
133
|
+
LINECAP_SQUARE
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface TextRenderOptions {
|
|
137
|
+
encoding?: EEncoding
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export type Glyph = Array<[number, number]>;
|
|
141
|
+
|
|
109
142
|
|
|
110
143
|
export interface AbstractContentContext {
|
|
111
144
|
b(): this;
|
|
@@ -118,13 +151,13 @@ declare module 'muhammara' {
|
|
|
118
151
|
F(): this;
|
|
119
152
|
fStar(): this;
|
|
120
153
|
n(): this;
|
|
121
|
-
m(x:
|
|
122
|
-
l(x:
|
|
123
|
-
c(x1:
|
|
124
|
-
v(x2:
|
|
125
|
-
y(x1:
|
|
154
|
+
m(x: PosX, y: PosY): this;
|
|
155
|
+
l(x: PosX, y: PosY): this;
|
|
156
|
+
c(x1: PosX, y1: PosY, x2: PosX, y2: PosY, x3: PosX, y3: PosY): number;
|
|
157
|
+
v(x2: PosX, y2: PosY, x3: PosX, y3: PosY): this;
|
|
158
|
+
y(x1: PosX, y1: PosY, x3: PosX, y3: PosY): this;
|
|
126
159
|
h(): this;
|
|
127
|
-
re(left: number, bottom: number, width:
|
|
160
|
+
re(left: number, bottom: number, width: Width, height: Height): this;
|
|
128
161
|
q(): this;
|
|
129
162
|
Q(): this;
|
|
130
163
|
/**
|
|
@@ -132,10 +165,10 @@ declare module 'muhammara' {
|
|
|
132
165
|
* c d 0
|
|
133
166
|
* e f 1
|
|
134
167
|
*/
|
|
135
|
-
cm(
|
|
136
|
-
w(lineWidth:
|
|
137
|
-
J(lineCapStyle:
|
|
138
|
-
j(lineJoinStyle:
|
|
168
|
+
cm(...args: TransformationMatrix): this;
|
|
169
|
+
w(lineWidth: Width): this;
|
|
170
|
+
J(lineCapStyle: LineCapStyle): this;
|
|
171
|
+
j(lineJoinStyle: LineJoinStyle): this;
|
|
139
172
|
M(miterLimit: number): this;
|
|
140
173
|
d(miterLimit: number[], dashPhase: number): this;
|
|
141
174
|
ri(renderingIntentName: string): this;
|
|
@@ -146,9 +179,11 @@ declare module 'muhammara' {
|
|
|
146
179
|
SC(...colorComponents: number[]): this;
|
|
147
180
|
SCN(...parameters: any[]): this; // This can't be materialized in TypeScript
|
|
148
181
|
////SCN(...colorComponents: number[], patternName?: string): this;
|
|
182
|
+
SCN(colorComponents: number[], patternName?: string): this;
|
|
149
183
|
sc(...colorComponents: number[]): this;
|
|
150
184
|
scn(...parameters: any[]): this; // This can't be materialized in TypeScript
|
|
151
185
|
////scn(...colorComponents: number[], patternName?: string): this;
|
|
186
|
+
scn(colorComponents: number[], patternName?: string): this;
|
|
152
187
|
G(gray: number): this;
|
|
153
188
|
g(gray: number): this;
|
|
154
189
|
RG(r: number, g: number, b: number): this;
|
|
@@ -157,7 +192,7 @@ declare module 'muhammara' {
|
|
|
157
192
|
k(c: number, m: number, y: number, k: number): this;
|
|
158
193
|
W(): this;
|
|
159
194
|
WStar(): this;
|
|
160
|
-
doXObject(xObject: string |
|
|
195
|
+
doXObject(xObject: string | FormXObject | ImageXObject): this;
|
|
161
196
|
Tc(characterSpace: number): this;
|
|
162
197
|
Tw(wordSpace: number): this;
|
|
163
198
|
Tz(horizontalScaling: number): this;
|
|
@@ -171,18 +206,19 @@ declare module 'muhammara' {
|
|
|
171
206
|
Tm(a: number, b: number, c: number, d: number, e: number, f: number): this;
|
|
172
207
|
TStar(): this;
|
|
173
208
|
Tf(fontReferenced: UsedFont | string, fontSize: number): this;
|
|
174
|
-
Tj(text: string |
|
|
175
|
-
Quote(text: string |
|
|
176
|
-
DoubleQuote(wordSpacing: number, characterString: number, text: string |
|
|
177
|
-
TJ(
|
|
209
|
+
Tj(text: string | Glyph): this;
|
|
210
|
+
Quote(text: string | Glyph): this;
|
|
211
|
+
DoubleQuote(wordSpacing: number, characterString: number, text: string | Glyph): this;
|
|
212
|
+
TJ(value: string | Glyph, options?: TextRenderOptions): this;
|
|
178
213
|
writeFreeCode(freeCode: string): this;
|
|
179
214
|
drawPath(...parameters: any[]): this; // This can't be materialized in TypeScript
|
|
180
215
|
////drawPath(...xyPairs: number[], options: GraphicOptions): this;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
216
|
+
drawPath(xyPairs: Array<[number, number]>, options: GraphicOptions): this;
|
|
217
|
+
drawCircle(x: PosX, y: PosY, r: number, options: GraphicOptions): this;
|
|
218
|
+
drawSquare(x: PosX, y: PosY, l: number, options: GraphicOptions): this;
|
|
219
|
+
drawRectangle(x: PosX, y: PosY, w: number, h: number, options: GraphicOptions): this;
|
|
220
|
+
writeText(text: string, x: PosX, y: PosY, options?: WriteTextOptions): this;
|
|
221
|
+
drawImage(x: PosX, y: PosY, imagePath: string, options?: ImageOptions): this;
|
|
186
222
|
}
|
|
187
223
|
|
|
188
224
|
export interface TransformationObject {
|
|
@@ -215,7 +251,7 @@ declare module 'muhammara' {
|
|
|
215
251
|
}
|
|
216
252
|
|
|
217
253
|
export interface PDFStreamForResponse extends WriteStream {
|
|
218
|
-
new (res:
|
|
254
|
+
new (res: PDFRStreamForFile): PDFStreamForResponse;
|
|
219
255
|
}
|
|
220
256
|
|
|
221
257
|
export interface PDFWStreamForBuffer extends WriteStream {
|
|
@@ -233,7 +269,7 @@ declare module 'muhammara' {
|
|
|
233
269
|
|
|
234
270
|
export interface PDFWriterToContinueOptions {
|
|
235
271
|
modifiedFilePath?: string;
|
|
236
|
-
|
|
272
|
+
modifiedStream?: PDFRStreamForFile; // TODO
|
|
237
273
|
log?: string;
|
|
238
274
|
}
|
|
239
275
|
|
|
@@ -272,6 +308,10 @@ declare module 'muhammara' {
|
|
|
272
308
|
export const ePDFPageBoxArtBox = 4;
|
|
273
309
|
export type PDFPageBoxType = 0 | 1 | 2 | 3 | 4;
|
|
274
310
|
|
|
311
|
+
export const eRangeTypeAll = 0;
|
|
312
|
+
export const eRangeTypeSpecific = 1;
|
|
313
|
+
export type eRangeType = 0 | 1;
|
|
314
|
+
|
|
275
315
|
export interface PDFWriterOptions {
|
|
276
316
|
version?: EPDFVersion;
|
|
277
317
|
log?: string;
|
|
@@ -289,18 +329,17 @@ declare module 'muhammara' {
|
|
|
289
329
|
}
|
|
290
330
|
|
|
291
331
|
export interface ResourcesDictionary {
|
|
292
|
-
addFormXObjectMapping(formXObject: FormXObject):
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
*/
|
|
332
|
+
addFormXObjectMapping(formXObject: FormXObject): string;
|
|
333
|
+
addImageXObjectMapping(imageXObject: ImageXObject|number): string;
|
|
334
|
+
addProcsetResource(procSetName: string): void;
|
|
335
|
+
addExtGStateMapping(stateObjectId: number): string;
|
|
336
|
+
addFontMapping(fontObjectId: number): string;
|
|
337
|
+
addColorSpaceMapping(colorSpaceId: number): string;
|
|
338
|
+
addPatternMapping(colorSpaceId: number): string;
|
|
339
|
+
addPatternMapping(patternObjectId: number): string;
|
|
340
|
+
addPropertyMapping(propertyObjectId: number): string;
|
|
341
|
+
addXObjectMapping(xObjectId: number): string;
|
|
342
|
+
addShadingMapping(xObjectId: number): string;
|
|
304
343
|
}
|
|
305
344
|
|
|
306
345
|
export type PDFBox = [PosX, PosY, Width, Height];
|
|
@@ -313,16 +352,6 @@ declare module 'muhammara' {
|
|
|
313
352
|
artBox?: PDFBox;
|
|
314
353
|
rotate?: number;
|
|
315
354
|
getResourcesDictionary(): ResourcesDictionary;
|
|
316
|
-
|
|
317
|
-
/*
|
|
318
|
-
SET_ACCESSOR_METHODS(t, "mediaBox", GetMediaBox, SetMediaBox);
|
|
319
|
-
SET_ACCESSOR_METHODS(t, "cropBox", GetCropBox, SetCropBox);
|
|
320
|
-
SET_ACCESSOR_METHODS(t, "bleedBox", GetBleedBox, SetBleedBox);
|
|
321
|
-
SET_ACCESSOR_METHODS(t, "trimBox", GetTrimBox, SetTrimBox);
|
|
322
|
-
SET_ACCESSOR_METHODS(t, "artBox", GetArtBox, SetArtBox);
|
|
323
|
-
SET_ACCESSOR_METHODS(t, "rotate",GetRotate, SetRotate);
|
|
324
|
-
SET_PROTOTYPE_METHOD(t, "getResourcesDictionary", GetResourcesDictionary);
|
|
325
|
-
*/
|
|
326
355
|
}
|
|
327
356
|
|
|
328
357
|
export interface TextDimension {
|
|
@@ -348,21 +377,17 @@ declare module 'muhammara' {
|
|
|
348
377
|
}
|
|
349
378
|
|
|
350
379
|
export interface ByteReader {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
SET_PROTOTYPE_METHOD(t, "notEnded", NotEnded);
|
|
354
|
-
*/
|
|
380
|
+
read(length: number): Array<number>;
|
|
381
|
+
notEnded(): boolean;
|
|
355
382
|
}
|
|
356
383
|
|
|
357
384
|
export interface ByteReaderWithPosition {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
SET_PROTOTYPE_METHOD(t, "skip", Skip);
|
|
365
|
-
*/
|
|
385
|
+
read(length: number): Array<number>;
|
|
386
|
+
notEnded(): boolean;
|
|
387
|
+
getCurrentPosition(): number;
|
|
388
|
+
skip(length: number): this;
|
|
389
|
+
setPosition(position: number): this;
|
|
390
|
+
setPositionFromEnd(position: number): this;
|
|
366
391
|
}
|
|
367
392
|
|
|
368
393
|
export interface PDFReader {
|
|
@@ -370,24 +395,19 @@ declare module 'muhammara' {
|
|
|
370
395
|
getPagesCount(): number;
|
|
371
396
|
getTrailer(): PDFDictionary;
|
|
372
397
|
queryDictionaryObject(dictionary: PDFDictionary, name: string): PDFObject;
|
|
373
|
-
|
|
374
|
-
SET_PROTOTYPE_METHOD(t, "queryArrayObject", QueryArrayObject);
|
|
375
|
-
*/
|
|
398
|
+
queryArrayObject(objectList: PDFArray, index: number): undefined|PDFObject;
|
|
376
399
|
parseNewObject(objectId: number): PDFObject;
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
SET_PROTOTYPE_METHOD(t, "parsePageDictionary", ParsePageDictionary);
|
|
380
|
-
*/
|
|
400
|
+
getPageObjectID(objectId: number): number;
|
|
401
|
+
parsePageDictionary(objectId: number): PDFDictionary;
|
|
381
402
|
parsePage(page: number): PDFPageInput;
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
*/
|
|
403
|
+
getObjectsCount(): number;
|
|
404
|
+
isEncrypted(): boolean;
|
|
405
|
+
getXrefSize(): number;
|
|
406
|
+
getXrefEntry(objectId: number): { objectPosition: number, revision: number, type: number };
|
|
407
|
+
getXrefSize(): number;
|
|
408
|
+
getXrefPosition(objectId: number): number;
|
|
409
|
+
startReadingFromStream(inputStream: PDFStreamInput): ByteReader;
|
|
410
|
+
getParserStream(): ByteReaderWithPosition;
|
|
391
411
|
}
|
|
392
412
|
|
|
393
413
|
export interface PDFStream {
|
|
@@ -395,15 +415,11 @@ declare module 'muhammara' {
|
|
|
395
415
|
}
|
|
396
416
|
|
|
397
417
|
export interface PDFNull extends PDFObject {
|
|
398
|
-
|
|
399
|
-
SET_ACCESSOR_METHOD(t, "value", GetValue);
|
|
400
|
-
*/
|
|
418
|
+
value: void;
|
|
401
419
|
}
|
|
402
420
|
|
|
403
421
|
export interface PDFName extends PDFObject {
|
|
404
|
-
|
|
405
|
-
SET_ACCESSOR_METHOD(t, "value", GetValue);
|
|
406
|
-
*/
|
|
422
|
+
value: string;
|
|
407
423
|
}
|
|
408
424
|
|
|
409
425
|
export interface PDFLiteralString extends PDFObject {
|
|
@@ -412,9 +428,7 @@ declare module 'muhammara' {
|
|
|
412
428
|
}
|
|
413
429
|
|
|
414
430
|
export interface PDFInteger extends PDFObject {
|
|
415
|
-
|
|
416
|
-
SET_ACCESSOR_METHOD(t, "value", GetValue);
|
|
417
|
-
*/
|
|
431
|
+
value: number;
|
|
418
432
|
}
|
|
419
433
|
|
|
420
434
|
export interface PDFIndirectObjectReference extends PDFObject {
|
|
@@ -423,9 +437,7 @@ declare module 'muhammara' {
|
|
|
423
437
|
}
|
|
424
438
|
|
|
425
439
|
export interface PDFHexString extends PDFObject {
|
|
426
|
-
|
|
427
|
-
SET_ACCESSOR_METHOD(t, "value", GetValue);
|
|
428
|
-
*/
|
|
440
|
+
value: string;
|
|
429
441
|
}
|
|
430
442
|
|
|
431
443
|
export interface PDFDictionary extends PDFObject {
|
|
@@ -435,151 +447,145 @@ declare module 'muhammara' {
|
|
|
435
447
|
}
|
|
436
448
|
|
|
437
449
|
export interface PDFDate {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
SET_PROTOTYPE_METHOD(t, "setToCurrentTime", SetToCurrentTime);
|
|
441
|
-
*/
|
|
450
|
+
toString(): string;
|
|
451
|
+
setToCurrentTime(): this;
|
|
442
452
|
}
|
|
443
453
|
|
|
444
454
|
export interface PDFBoolean extends PDFObject {
|
|
445
|
-
|
|
446
|
-
SET_ACCESSOR_METHOD(t, "value", GetValue);
|
|
447
|
-
*/
|
|
455
|
+
value: boolean;
|
|
448
456
|
}
|
|
449
457
|
|
|
450
458
|
export interface PDFArray extends PDFObject {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
SET_PROTOTYPE_METHOD(t, "getLength", GetLength);
|
|
455
|
-
*/
|
|
459
|
+
toJSArray(): Array<any>;
|
|
460
|
+
queryObject(index: number): any;
|
|
461
|
+
getLength(): number;
|
|
456
462
|
}
|
|
457
463
|
|
|
458
464
|
export interface OutputFile {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
SET_PROTOTYPE_METHOD(t, "getOutputStream", GetOutputStream);
|
|
464
|
-
*/
|
|
465
|
+
openFile(filePath: FilePath, append?: boolean): void;
|
|
466
|
+
closeFile(): void;
|
|
467
|
+
getFilePath(): string|undefined;
|
|
468
|
+
getOutputStream(): ByteWriterWithPosition|undefined;
|
|
465
469
|
}
|
|
466
470
|
|
|
467
471
|
export interface InputFile {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
SET_PROTOTYPE_METHOD(t, "getInputStream", GetInputStream);
|
|
474
|
-
*/
|
|
472
|
+
openFile(filePath: FilePath): void;
|
|
473
|
+
closeFile(): void;
|
|
474
|
+
getFilePath(): string|undefined;
|
|
475
|
+
getFileSize(): number|undefined;
|
|
476
|
+
getInputStream(): ByteReaderWithPosition|undefined;
|
|
475
477
|
}
|
|
476
478
|
|
|
479
|
+
export enum EInfoTrapped {
|
|
480
|
+
EInfoTrappedTrue,
|
|
481
|
+
EInfoTrappedFalse,
|
|
482
|
+
EInfoTrappedUnknown
|
|
483
|
+
}
|
|
484
|
+
|
|
477
485
|
export interface InfoDictionary {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
*/
|
|
486
|
+
addAdditionalInfoEntry(key: string, value: string): void;
|
|
487
|
+
removeAdditionalInfoEntry(key: string): void;
|
|
488
|
+
clearAdditionalInfoEntries(): void;
|
|
489
|
+
getAdditionalInfoEntry(key: string): string;
|
|
490
|
+
getAdditionalInfoEntries(key: string): {[key: string]: string}
|
|
491
|
+
setCreationDate(date: string | Date): void;
|
|
492
|
+
setModDate(date: string | Date): void;
|
|
493
|
+
|
|
494
|
+
title: string;
|
|
495
|
+
author: string;
|
|
496
|
+
subject: string;
|
|
497
|
+
keywords: string;
|
|
498
|
+
creator: string;
|
|
499
|
+
producer: string;
|
|
500
|
+
trapped: EInfoTrapped;
|
|
494
501
|
}
|
|
495
502
|
|
|
496
503
|
export interface ImageXObject {
|
|
497
|
-
|
|
498
|
-
SET_ACCESSOR_METHOD(t, "id", GetID);
|
|
499
|
-
*/
|
|
504
|
+
id: number;
|
|
500
505
|
}
|
|
501
506
|
|
|
502
507
|
export interface FormObject {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
SET_PROTOTYPE_METHOD(t, "getContentStream", GetContentStream);
|
|
508
|
-
*/
|
|
508
|
+
id: number;
|
|
509
|
+
getContentContext(): XObjectContentContext;
|
|
510
|
+
getResourcesDictinary(): ResourcesDictionary;
|
|
511
|
+
getContentStream(): PDFStream;
|
|
509
512
|
}
|
|
510
513
|
|
|
511
514
|
export interface DocumentCopyingContext {
|
|
512
515
|
createFormXObjectFromPDFPage(
|
|
513
516
|
sourcePageIndex: number,
|
|
514
517
|
ePDFPageBox: PDFPageBoxType | PDFBox,
|
|
518
|
+
transformation?: TransformationMatrix
|
|
515
519
|
): number;
|
|
516
520
|
mergePDFPageToPage(target: PDFPage, sourcePageIndex: number): void;
|
|
517
521
|
appendPDFPageFromPDF(sourcePageNumber: number): number; // stream start bytes?
|
|
518
|
-
mergePDFPageToFormXObject(sourcePage: PDFPage, targetPageNumber: number):
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
SET_PROTOTYPE_METHOD(t, "getSourceDocumentStream", GetSourceDocumentStream);
|
|
529
|
-
*/
|
|
522
|
+
mergePDFPageToFormXObject(sourcePage: PDFPage, targetPageNumber: number): void;
|
|
523
|
+
getSourceDocumentParser(input: FilePath | ReadStream, options?: PDFReaderOptions): PDFReader;
|
|
524
|
+
copyDirectObjectAsIs(objectToCopy: PDFObject): void;
|
|
525
|
+
copyObject(objectId: number): number;
|
|
526
|
+
copyDirectObjectWithDeepCopy(objectToCopy: PDFObject): Array<number>;
|
|
527
|
+
copyNewObjectsForDirectObject(objectIds: Array<number>): void;
|
|
528
|
+
getCopiedObjectID(objectId: number): number;
|
|
529
|
+
getCopiedObjects(): {[key: string]: number};
|
|
530
|
+
replaceSourceObjects(replaceMap: {[key: string]: number}): void;
|
|
531
|
+
getSourceDocumentStream(): ByteReaderWithPosition;
|
|
530
532
|
}
|
|
531
533
|
|
|
532
534
|
export interface DocumentContext {
|
|
533
|
-
|
|
534
|
-
SET_PROTOTYPE_METHOD(t, "getInfoDictionary", GetInfoDictionary);
|
|
535
|
-
*/
|
|
535
|
+
getInfoDictionary(): InfoDictionary;
|
|
536
536
|
}
|
|
537
537
|
|
|
538
538
|
export interface DictionaryContext {
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
*/
|
|
539
|
+
writeKey(): DictionaryContext;
|
|
540
|
+
writeNameValue(nameValue: string): this;
|
|
541
|
+
writeRectangleValue(values: Array<number>): this;
|
|
542
|
+
writeRectangleValue(a: number, b: number, c: number, d: number): this;
|
|
543
|
+
writeLiteralStringValue(literal: Array<number>|string): this;
|
|
544
|
+
writeBooleanValue(boolValue: boolean): this;
|
|
545
|
+
writeObjectReferenceValue(objectId: number): this;
|
|
547
546
|
}
|
|
548
547
|
|
|
549
548
|
export interface ByteWriterWithPosition {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
549
|
+
write(bytes: Array<number>): number;
|
|
550
|
+
getCurrentPosition(): number;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
export type eTokenSeparatorSpace = 0;
|
|
554
|
+
export type eTokenSeparatorEndLine = 1;
|
|
555
|
+
export type eTokenSeparatorNone = 2;
|
|
556
|
+
|
|
557
|
+
enum ETokenSeparator {
|
|
558
|
+
eTokenSeparatorSpace,
|
|
559
|
+
eTokenSeparatorEndLine,
|
|
560
|
+
eTokenSeparatorNone
|
|
554
561
|
}
|
|
555
562
|
|
|
556
563
|
export interface ObjectsContext {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
*/
|
|
564
|
+
allocateNewObjectID(): FormXObjectId;
|
|
565
|
+
startDictionary(): DictionaryContext;
|
|
566
|
+
startArray(): this;
|
|
567
|
+
writeNumber(value: number): this;
|
|
568
|
+
endArray(endType?: ETokenSeparator): this;
|
|
569
|
+
endLine(): this;
|
|
570
|
+
endDictionary(dictionary: DictionaryContext): this;
|
|
571
|
+
endIndirectObject(): this;
|
|
572
|
+
writeIndirectObjectReference(objectId: FormXObjectId, generationNumber?: number): this;
|
|
573
|
+
startNewIndirectObject(objectId: FormXObjectId): this;
|
|
574
|
+
startNewIndirectObject(): FormXObjectId;
|
|
575
|
+
startModifiedIndirectObject(objectId: FormXObjectId): this;
|
|
576
|
+
deleteObject(objectId: FormXObjectId): this;
|
|
577
|
+
writeName(name: string): this;
|
|
578
|
+
writeLiteralString(literal: string | number[]): this;
|
|
579
|
+
writeHexString(hex: string | number[]): this;
|
|
580
|
+
writeBoolean(bool: boolean): this;
|
|
581
|
+
writeKeyword(keyword: string): this;
|
|
582
|
+
writeComment(comment: string): this;
|
|
583
|
+
setCompressStreams(compress: true): this;
|
|
584
|
+
startPDFStream(dictionaryContext: DictionaryContext): PDFStream;
|
|
585
|
+
startUnfilteredPDFStream(stream: DictionaryContext): PDFStream;
|
|
586
|
+
endPDFStream(stream: PDFStream): this;
|
|
587
|
+
startFreeContext(): ByteWriterWithPosition;
|
|
588
|
+
endFreeContext(): this;
|
|
583
589
|
}
|
|
584
590
|
|
|
585
591
|
export interface PDFObject {
|
|
@@ -601,30 +607,22 @@ SET_PROTOTYPE_METHOD(t, "allocateNewObjectID", AllocateNewObjectID);
|
|
|
601
607
|
}
|
|
602
608
|
|
|
603
609
|
export interface PDFReal extends PDFObject {
|
|
604
|
-
|
|
605
|
-
SET_ACCESSOR_METHOD(t, "value", GetValue);
|
|
606
|
-
*/
|
|
610
|
+
value: number;
|
|
607
611
|
}
|
|
608
612
|
|
|
609
613
|
export interface PDFSymbol extends PDFObject {
|
|
610
|
-
|
|
611
|
-
SET_ACCESSOR_METHOD(t, "value", GetValue);
|
|
612
|
-
*/
|
|
614
|
+
value: string;
|
|
613
615
|
}
|
|
614
616
|
|
|
615
617
|
export interface PDFStreamInput extends PDFObject {
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
SET_PROTOTYPE_METHOD(t, "getStreamContentStart", GetStreamContentStart);
|
|
619
|
-
*/
|
|
618
|
+
getDictionary(): PDFDictionary;
|
|
619
|
+
getStreamContentStart(): number;
|
|
620
620
|
}
|
|
621
621
|
|
|
622
622
|
export interface PDFTextString {
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
SET_PROTOTYPE_METHOD(t, "fromString", FromString);
|
|
627
|
-
*/
|
|
623
|
+
toBytesArray(): Array<number>;
|
|
624
|
+
toString(): string;
|
|
625
|
+
fromString(value: string): void;
|
|
628
626
|
}
|
|
629
627
|
|
|
630
628
|
export interface PageContentContext extends AbstractContentContext {
|
|
@@ -632,56 +630,80 @@ SET_PROTOTYPE_METHOD(t, "allocateNewObjectID", AllocateNewObjectID);
|
|
|
632
630
|
getAssociatedPage(): PDFPage;
|
|
633
631
|
}
|
|
634
632
|
|
|
633
|
+
export interface JPEGInformation {
|
|
634
|
+
samplesWidth: number;
|
|
635
|
+
samplesHeight: number;
|
|
636
|
+
colorComponentsCount: number;
|
|
637
|
+
JFIFInformationExists: boolean;
|
|
638
|
+
JFIFUnit?: number;
|
|
639
|
+
JFIFXDensity?: number;
|
|
640
|
+
JFIFYDensity?: number;
|
|
641
|
+
ExifInformationExists: boolean;
|
|
642
|
+
ExifUnit?: number;
|
|
643
|
+
ExifXDensity?: number;
|
|
644
|
+
ExifYDensity?: number;
|
|
645
|
+
PhotoshopInformationExists: boolean;
|
|
646
|
+
PhotoshopXDensity?: number;
|
|
647
|
+
PhotoshopYDensity?: number;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
export type PDFRectangle = [lowerLeftX: number, lowerLeftY: number, upperRightX: number, upperRightY: number];
|
|
651
|
+
|
|
652
|
+
export interface MergeOptions {
|
|
653
|
+
password?: string;
|
|
654
|
+
type?: eRangeType;
|
|
655
|
+
specificRanges?: [[number, number]];
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
export interface AppendOptions extends MergeOptions {}
|
|
659
|
+
|
|
660
|
+
export type inInterPagesCallback = () => {}
|
|
661
|
+
|
|
662
|
+
|
|
635
663
|
export interface PDFWriter {
|
|
636
664
|
end(): PDFWriter;
|
|
637
|
-
createPage(x:
|
|
665
|
+
createPage(x: PosX, y: PosY, width: Width, height: Height): PDFPage;
|
|
638
666
|
createPage(): PDFPage;
|
|
639
667
|
writePage(page: PDFPage): this;
|
|
640
668
|
writePageAndReturnID(page: PDFPage): number;
|
|
641
669
|
startPageContentContext(page: PDFPage): PageContentContext;
|
|
642
670
|
pausePageContentContext(pageContextContext: PageContentContext): this;
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
createFormXObjectFromJPG();
|
|
647
|
-
*/
|
|
648
|
-
// TODO: test streamas
|
|
649
|
-
createFormXObjectFromPNG(filePath: FilePath | PDFRStreamForFile): FormXObject;
|
|
650
|
-
|
|
671
|
+
createFormXObject(x: PosX, y: PosY, width: Width, height: Height, objectId?: FormXObjectId): FormXObject;
|
|
672
|
+
endFormXObject(formXObject: FormXObject): this;
|
|
673
|
+
createFormXObjectFromJPG(file: FilePath | PDFRStreamForFile, objectId?: FormXObjectId): FormXObject;
|
|
651
674
|
getFontForFile(inFontFilePath: FilePath, index?: number): UsedFont;
|
|
652
675
|
getFontForFile(
|
|
653
676
|
inFontFilePath: FilePath,
|
|
654
677
|
inOptionalMetricsFile?: string,
|
|
655
678
|
index?: number,
|
|
656
679
|
): UsedFont;
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
retrieveJPGImageInformation();
|
|
663
|
-
getObjectsContext();
|
|
664
|
-
getDocumentContext();
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
mergePDFPagesToPage();
|
|
669
|
-
*/
|
|
680
|
+
attachURLLinktoCurrentPage(url: string, x: PosX, y: PosY, width: Width, height: Height): this;
|
|
681
|
+
shutdown(outputFilePath: FilePath): this;
|
|
682
|
+
createFormXObjectFromTIFF(filePath: FilePath | PDFRStreamForFile, objectId?: FormXObjectId): FormXObject;
|
|
683
|
+
createImageXObjectFromJPG(filePath: FilePath | PDFRStreamForFile, objectId?: FormXObjectId): ImageXObject;
|
|
684
|
+
createFormXObjectFromPNG(filePath: FilePath | PDFRStreamForFile, objectId?: FormXObjectId): FormXObject;
|
|
685
|
+
retrieveJPGImageInformation(filePath: FilePath): JPEGInformation;
|
|
686
|
+
getObjectsContext(): ObjectsContext;
|
|
687
|
+
getDocumentContext(): DocumentContext;
|
|
688
|
+
appendPDFPagesFromPDF(source: FilePath | ReadStream, options?: AppendOptions): number[];
|
|
689
|
+
mergePDFPagesToPage(page: PDFPage, file: FilePath | PDFRStreamForFile, options?: MergeOptions, callback?: inInterPagesCallback): this;
|
|
690
|
+
mergePDFPagesToPage(page: PDFPage, file: FilePath | PDFRStreamForFile, callback?: inInterPagesCallback) : this;
|
|
670
691
|
createPDFCopyingContext(source: FilePath | ReadStream): DocumentCopyingContext;
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
createPDFDate();
|
|
676
|
-
*/
|
|
692
|
+
createFormXObjectsFromPDF(file: FilePath, box?: PDFBox | PDFPageBoxType, options?: MergeOptions, transformation?: TransformationMatrix, objectIds?: FormXObjectId[]): FormXObjectId[];
|
|
693
|
+
createPDFCopyingContextForModifiedFile(): DocumentCopyingContext;
|
|
694
|
+
createPDFTextString(): PDFTextString;
|
|
695
|
+
createPDFDate(): PDFDate;
|
|
677
696
|
getImageDimensions(inFontFilePath: FilePath | ReadStream): RectangleDimension;
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
697
|
+
getImagePagesCount(imagePath: FilePath, options?: {password?: string}): number;
|
|
698
|
+
getImageType(imagePath: FilePath): PDFImageType | undefined;
|
|
699
|
+
getModifiedFileParser(): PDFReader;
|
|
700
|
+
getModifiedInputFile(): InputFile;
|
|
701
|
+
getOutputFile(): OutputFile;
|
|
702
|
+
registerAnnotationReferenceForNextPageWrite(annotationId: number): this;
|
|
703
|
+
requireCatalogUpdate(): void;
|
|
704
|
+
|
|
705
|
+
/* Js Extensions (in muhammara.js) */
|
|
706
|
+
getEvents(): EventEmitter;
|
|
707
|
+
triggerDocumentExtensionEvent(eventName: string | symbol, eventParams: any): void;
|
|
686
708
|
}
|
|
687
709
|
}
|