@f-o-t/pdf 0.3.8 → 0.3.9
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/plugins/editing/document.d.ts +55 -0
- package/dist/plugins/editing/document.d.ts.map +1 -0
- package/dist/plugins/editing/index.d.ts +19 -0
- package/dist/plugins/editing/index.d.ts.map +1 -0
- package/dist/plugins/editing/page.d.ts +46 -0
- package/dist/plugins/editing/page.d.ts.map +1 -0
- package/dist/plugins/editing/parser.d.ts +90 -0
- package/dist/plugins/editing/parser.d.ts.map +1 -0
- package/dist/plugins/editing/types.d.ts +102 -0
- package/dist/plugins/editing/types.d.ts.map +1 -0
- package/package.json +9 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PdfDocument implementation for the editing plugin
|
|
3
|
+
*
|
|
4
|
+
* Manages loading an existing PDF, tracking modifications, and producing an
|
|
5
|
+
* incremental update (appended after the original %%EOF) that adds or
|
|
6
|
+
* overrides objects without rewriting the original content.
|
|
7
|
+
*/
|
|
8
|
+
import type { PdfDocument, PdfImage, PdfPage, SignaturePlaceholderOptions } from "./types.ts";
|
|
9
|
+
export declare class PdfDocumentImpl implements PdfDocument {
|
|
10
|
+
private originalData;
|
|
11
|
+
private pdfStr;
|
|
12
|
+
private structure;
|
|
13
|
+
private pages;
|
|
14
|
+
private nextObjNum;
|
|
15
|
+
private fontObjNum;
|
|
16
|
+
private embeddedImages;
|
|
17
|
+
constructor(data: Uint8Array);
|
|
18
|
+
get pageCount(): number;
|
|
19
|
+
getPage(index: number): PdfPage;
|
|
20
|
+
embedPng(data: Uint8Array): PdfImage;
|
|
21
|
+
/**
|
|
22
|
+
* Save the modified PDF using an incremental update
|
|
23
|
+
*/
|
|
24
|
+
save(): Uint8Array;
|
|
25
|
+
/**
|
|
26
|
+
* Save with a signature placeholder for digital signing
|
|
27
|
+
*/
|
|
28
|
+
saveWithPlaceholder(options: SignaturePlaceholderOptions): {
|
|
29
|
+
pdf: Uint8Array;
|
|
30
|
+
byteRange: [number, number, number, number];
|
|
31
|
+
};
|
|
32
|
+
private buildIncrementalUpdate;
|
|
33
|
+
private hasImagesForPage;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Find the ByteRange and Contents placeholder in a signed PDF
|
|
37
|
+
*/
|
|
38
|
+
export declare function findByteRange(pdfData: Uint8Array): {
|
|
39
|
+
byteRange: [number, number, number, number];
|
|
40
|
+
contentsStart: number;
|
|
41
|
+
contentsEnd: number;
|
|
42
|
+
placeholderLength: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Extract the bytes that need to be signed according to the ByteRange
|
|
46
|
+
*/
|
|
47
|
+
export declare function extractBytesToSign(pdfData: Uint8Array, byteRange: [number, number, number, number]): Uint8Array;
|
|
48
|
+
/**
|
|
49
|
+
* Embed a signature (as raw bytes) into the Contents placeholder.
|
|
50
|
+
*
|
|
51
|
+
* **Mutates `pdfData` in-place** and returns the same buffer. Callers must not
|
|
52
|
+
* retain a reference to `pdfData` and expect it to remain unchanged after this call.
|
|
53
|
+
*/
|
|
54
|
+
export declare function embedSignature(pdfData: Uint8Array, signature: Uint8Array): Uint8Array;
|
|
55
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/plugins/editing/document.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,KAAK,EACX,WAAW,EACX,QAAQ,EACR,OAAO,EACP,2BAA2B,EAC3B,MAAM,YAAY,CAAC;AAwFpB,qBAAa,eAAgB,YAAW,WAAW;IAClD,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAuC;IACxD,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,cAAc,CAOd;gBAEI,IAAI,EAAE,UAAU;IAwB5B,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAS/B,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,QAAQ;IAqBpC;;OAEG;IACH,IAAI,IAAI,UAAU;IAIlB;;OAEG;IACH,mBAAmB,CAAC,OAAO,EAAE,2BAA2B,GAAG;QAC1D,GAAG,EAAE,UAAU,CAAC;QAChB,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;KAC5C;IAID,OAAO,CAAC,sBAAsB;IA4W9B,OAAO,CAAC,gBAAgB;CAGxB;AAsHD;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG;IACnD,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;CAC1B,CAkBA;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,UAAU,EACnB,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GACzC,UAAU,CAoBZ;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC7B,OAAO,EAAE,UAAU,EACnB,SAAS,EAAE,UAAU,GACnB,UAAU,CAwBZ"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PDF Editing Plugin
|
|
3
|
+
*
|
|
4
|
+
* Load existing PDFs, modify them (draw text, rectangles, images),
|
|
5
|
+
* and save with incremental updates. Also supports creating signature
|
|
6
|
+
* placeholders for digital signing workflows.
|
|
7
|
+
*/
|
|
8
|
+
export type { PdfDocument, PdfPage, PdfImage, TextOptions, RectOptions, ImageOptions, SignaturePlaceholderOptions, } from "./types.ts";
|
|
9
|
+
export { PdfDocumentImpl } from "./document.ts";
|
|
10
|
+
export { findByteRange, extractBytesToSign, embedSignature, } from "./document.ts";
|
|
11
|
+
import type { PdfDocument } from "./types.ts";
|
|
12
|
+
/**
|
|
13
|
+
* Load an existing PDF for editing
|
|
14
|
+
*
|
|
15
|
+
* @param data - The PDF file contents as a Uint8Array
|
|
16
|
+
* @returns A PdfDocument that can be modified and saved
|
|
17
|
+
*/
|
|
18
|
+
export declare function loadPdf(data: Uint8Array): PdfDocument;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/editing/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EACX,WAAW,EACX,OAAO,EACP,QAAQ,EACR,WAAW,EACX,WAAW,EACX,YAAY,EACZ,2BAA2B,GAC3B,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EACN,aAAa,EACb,kBAAkB,EAClB,cAAc,GACd,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,WAAW,CAErD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PdfPage implementation for the editing plugin
|
|
3
|
+
*
|
|
4
|
+
* Collects drawing operations as PDF content stream operators.
|
|
5
|
+
* The accumulated operators are later serialised as a new content stream
|
|
6
|
+
* object appended via incremental update.
|
|
7
|
+
*/
|
|
8
|
+
import type { PdfImage, PdfPage, TextOptions, RectOptions, ImageOptions } from "./types.ts";
|
|
9
|
+
export declare class PdfPageImpl implements PdfPage {
|
|
10
|
+
readonly width: number;
|
|
11
|
+
readonly height: number;
|
|
12
|
+
/** The existing page object number in the original PDF */
|
|
13
|
+
readonly pageObjNum: number;
|
|
14
|
+
/** The raw dictionary content string of the original page */
|
|
15
|
+
readonly originalDictContent: string;
|
|
16
|
+
/** Accumulated content-stream operators added by draw* methods */
|
|
17
|
+
private operators;
|
|
18
|
+
/** Images referenced by drawImage (name -> obj num) */
|
|
19
|
+
private imageRefs;
|
|
20
|
+
/** Font object number allocated by the document (set externally) */
|
|
21
|
+
fontObjNum: number;
|
|
22
|
+
/** Whether any drawing operations have been recorded */
|
|
23
|
+
get dirty(): boolean;
|
|
24
|
+
constructor(pageObjNum: number, width: number, height: number, originalDictContent: string);
|
|
25
|
+
/**
|
|
26
|
+
* Draw text on the page using Helvetica
|
|
27
|
+
*/
|
|
28
|
+
drawText(text: string, options: TextOptions): void;
|
|
29
|
+
/**
|
|
30
|
+
* Draw a rectangle on the page
|
|
31
|
+
*/
|
|
32
|
+
drawRectangle(options: RectOptions): void;
|
|
33
|
+
/**
|
|
34
|
+
* Draw an embedded image on the page
|
|
35
|
+
*/
|
|
36
|
+
drawImage(image: PdfImage, options: ImageOptions): void;
|
|
37
|
+
/**
|
|
38
|
+
* Build the content stream bytes for the accumulated operators
|
|
39
|
+
*/
|
|
40
|
+
buildContentStream(): Uint8Array;
|
|
41
|
+
/**
|
|
42
|
+
* Get image references used in drawing operations
|
|
43
|
+
*/
|
|
44
|
+
getImageRefs(): Map<string, number>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../src/plugins/editing/page.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAiB5F,qBAAa,WAAY,YAAW,OAAO;IAC1C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,0DAA0D;IAC1D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,6DAA6D;IAC7D,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IAErC,kEAAkE;IAClE,OAAO,CAAC,SAAS,CAAgB;IAEjC,uDAAuD;IACvD,OAAO,CAAC,SAAS,CAAkC;IAEnD,oEAAoE;IACpE,UAAU,SAAK;IAEf,wDAAwD;IACxD,IAAI,KAAK,IAAI,OAAO,CAEnB;gBAGA,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,MAAM;IAQ5B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI;IAqBlD;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IA6BzC;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI;IAWvD;;OAEG;IACH,kBAAkB,IAAI,UAAU;IAKhC;;OAEG;IACH,YAAY,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;CAGnC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight PDF structure parser for incremental editing
|
|
3
|
+
*
|
|
4
|
+
* Parses just enough of an existing PDF to enable incremental updates:
|
|
5
|
+
* - Finds the cross-reference table via startxref
|
|
6
|
+
* - Reads the trailer to get Root, Size, Info
|
|
7
|
+
* - Follows Root -> Pages -> Kids to locate page objects
|
|
8
|
+
* - Extracts MediaBox dimensions from pages
|
|
9
|
+
*
|
|
10
|
+
* All public functions accept a pre-decoded latin1 string (`pdfStr`) rather
|
|
11
|
+
* than the raw Uint8Array so that the caller can decode ONCE and reuse the
|
|
12
|
+
* string across many calls — avoiding O(pages) redundant allocations.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Parsed PDF structure needed for incremental updates
|
|
16
|
+
*/
|
|
17
|
+
export type PdfStructure = {
|
|
18
|
+
xrefOffset: number;
|
|
19
|
+
rootNum: number;
|
|
20
|
+
infoNum: number | null;
|
|
21
|
+
size: number;
|
|
22
|
+
pagesNum: number;
|
|
23
|
+
pageNums: number[];
|
|
24
|
+
rootDictContent: string;
|
|
25
|
+
pageDictContents: string[];
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Find the byte offset recorded after the last `startxref` keyword
|
|
29
|
+
*/
|
|
30
|
+
export declare function findStartXref(pdfStr: string): number;
|
|
31
|
+
/**
|
|
32
|
+
* Parse the trailer dictionary to extract Root, Size, Info, and Prev xref offset.
|
|
33
|
+
*
|
|
34
|
+
* Supports both traditional trailers (`trailer << ... >>`) and
|
|
35
|
+
* cross-reference streams (PDF 1.5+) where the trailer entries live
|
|
36
|
+
* inside the xref stream object dictionary.
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseTrailer(pdfStr: string): {
|
|
39
|
+
root: number;
|
|
40
|
+
size: number;
|
|
41
|
+
info: number | null;
|
|
42
|
+
prevXref: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Extract the dictionary content (between outer << and >>) for a given object number.
|
|
46
|
+
* Returns the content string without the delimiters.
|
|
47
|
+
*/
|
|
48
|
+
export declare function extractObjectDictContent(pdfStr: string, objNum: number): string;
|
|
49
|
+
/**
|
|
50
|
+
* Find all LEAF page object numbers by following Root -> Pages -> Kids recursively.
|
|
51
|
+
*
|
|
52
|
+
* The PDF page tree can be arbitrarily deep — every ~100-200 pages, PDF tools
|
|
53
|
+
* create intermediate Pages nodes (Type=Pages) that group their children.
|
|
54
|
+
* This function recurses until it reaches actual Page leaves (Type=Page).
|
|
55
|
+
*/
|
|
56
|
+
export declare function findPageObjects(pdfStr: string, rootNum: number): number[];
|
|
57
|
+
/**
|
|
58
|
+
* Get the MediaBox for a page object: [x1, y1, x2, y2].
|
|
59
|
+
*
|
|
60
|
+
* Per the PDF spec, /MediaBox is inherited: if the Page object itself does not
|
|
61
|
+
* carry the entry, we walk up the /Parent chain until we find one.
|
|
62
|
+
*/
|
|
63
|
+
export declare function getMediaBox(pdfStr: string, pageObjNum: number): [number, number, number, number];
|
|
64
|
+
/**
|
|
65
|
+
* Parse the full PDF structure needed for incremental editing.
|
|
66
|
+
*
|
|
67
|
+
* @param pdfStr - The PDF file decoded as a latin1 string (decode ONCE and pass here)
|
|
68
|
+
*/
|
|
69
|
+
export declare function parsePdfStructure(pdfStr: string): PdfStructure;
|
|
70
|
+
/**
|
|
71
|
+
* Parse a Resources dictionary from page content, handling both inline
|
|
72
|
+
* dictionaries and indirect references.
|
|
73
|
+
*
|
|
74
|
+
* Returns a map of resource type names to their dictionary/array content strings.
|
|
75
|
+
* Example: { "/Font": "<< /F1 10 0 R >>", "/ProcSet": "[/PDF /Text]" }
|
|
76
|
+
*/
|
|
77
|
+
export declare function parseResourcesDict(pageContent: string, pdfStr: string): Record<string, string>;
|
|
78
|
+
/**
|
|
79
|
+
* Merge two Resources dictionaries, combining entries from both.
|
|
80
|
+
*
|
|
81
|
+
* For dictionary-type entries like /Font, /XObject, extracts individual
|
|
82
|
+
* name-reference pairs and combines them. For array-type entries like
|
|
83
|
+
* /ProcSet, uses the existing value (no merge needed).
|
|
84
|
+
*
|
|
85
|
+
* @param existing - Parsed Resources from original page
|
|
86
|
+
* @param additions - New Resources to add (from signature appearance)
|
|
87
|
+
* @returns Merged Resources dictionary entries
|
|
88
|
+
*/
|
|
89
|
+
export declare function mergeResourcesDicts(existing: Record<string, string>, additions: Record<string, string>): Record<string, string>;
|
|
90
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/plugins/editing/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;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BAAmB,CAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA0BxB"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the PDF editing plugin
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* A loaded PDF document that can be modified and saved
|
|
6
|
+
*/
|
|
7
|
+
export type PdfDocument = {
|
|
8
|
+
/** Number of pages in the document */
|
|
9
|
+
pageCount: number;
|
|
10
|
+
/** Get a page by zero-based index */
|
|
11
|
+
getPage(index: number): PdfPage;
|
|
12
|
+
/** Embed a PNG image for use with drawImage */
|
|
13
|
+
embedPng(data: Uint8Array): PdfImage;
|
|
14
|
+
/** Save the modified PDF with incremental update */
|
|
15
|
+
save(): Uint8Array;
|
|
16
|
+
/** Save with a signature placeholder for digital signing */
|
|
17
|
+
saveWithPlaceholder(options: SignaturePlaceholderOptions): {
|
|
18
|
+
pdf: Uint8Array;
|
|
19
|
+
byteRange: [number, number, number, number];
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* A page in a loaded PDF document
|
|
24
|
+
*/
|
|
25
|
+
export type PdfPage = {
|
|
26
|
+
/** Page width in points */
|
|
27
|
+
width: number;
|
|
28
|
+
/** Page height in points */
|
|
29
|
+
height: number;
|
|
30
|
+
/** Draw text on the page */
|
|
31
|
+
drawText(text: string, options: TextOptions): void;
|
|
32
|
+
/** Draw a rectangle on the page */
|
|
33
|
+
drawRectangle(options: RectOptions): void;
|
|
34
|
+
/** Draw an embedded image on the page */
|
|
35
|
+
drawImage(image: PdfImage, options: ImageOptions): void;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* An embedded image reference
|
|
39
|
+
*/
|
|
40
|
+
export type PdfImage = {
|
|
41
|
+
/** Internal object number for the image XObject */
|
|
42
|
+
readonly objectNumber: number;
|
|
43
|
+
/** Image width in pixels */
|
|
44
|
+
readonly width: number;
|
|
45
|
+
/** Image height in pixels */
|
|
46
|
+
readonly height: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Options for drawing text
|
|
50
|
+
*/
|
|
51
|
+
export type TextOptions = {
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
/** Font size in points (default: 12) */
|
|
55
|
+
size?: number;
|
|
56
|
+
/** Hex color string like "#000000" (default: black) */
|
|
57
|
+
color?: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Options for drawing a rectangle
|
|
61
|
+
*/
|
|
62
|
+
export type RectOptions = {
|
|
63
|
+
x: number;
|
|
64
|
+
y: number;
|
|
65
|
+
width: number;
|
|
66
|
+
height: number;
|
|
67
|
+
/** Fill color as hex string */
|
|
68
|
+
color?: string;
|
|
69
|
+
/** Stroke/border color as hex string */
|
|
70
|
+
borderColor?: string;
|
|
71
|
+
/** Border line width in points */
|
|
72
|
+
borderWidth?: number;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Options for drawing an image
|
|
76
|
+
*/
|
|
77
|
+
export type ImageOptions = {
|
|
78
|
+
x: number;
|
|
79
|
+
y: number;
|
|
80
|
+
width: number;
|
|
81
|
+
height: number;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Options for creating a signature placeholder
|
|
85
|
+
*/
|
|
86
|
+
export type SignaturePlaceholderOptions = {
|
|
87
|
+
reason?: string;
|
|
88
|
+
name?: string;
|
|
89
|
+
location?: string;
|
|
90
|
+
contactInfo?: string;
|
|
91
|
+
/** Size of the signature contents in bytes (default: 16384) */
|
|
92
|
+
signatureLength?: number;
|
|
93
|
+
/** DocMDP permission level: 1 = no changes, 2 = form fill + sign, 3 = form fill + sign + annotate (default: 2) */
|
|
94
|
+
docMdpPermission?: 1 | 2 | 3;
|
|
95
|
+
/**
|
|
96
|
+
* Zero-based page index where the signature widget annotation should be placed.
|
|
97
|
+
* This should match the page where the visual signature appearance is drawn.
|
|
98
|
+
* Defaults to 0 (first page) for invisible signatures.
|
|
99
|
+
*/
|
|
100
|
+
appearancePage?: number;
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/editing/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACzB,sCAAsC;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,QAAQ,CAAC;IACrC,oDAAoD;IACpD,IAAI,IAAI,UAAU,CAAC;IACnB,4DAA4D;IAC5D,mBAAmB,CAAC,OAAO,EAAE,2BAA2B,GAAG;QAC1D,GAAG,EAAE,UAAU,CAAC;QAChB,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;KAC5C,CAAC;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG;IACrB,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IACnD,mCAAmC;IACnC,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1C,yCAAyC;IACzC,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;CACxD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;I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Ac,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@f-o-t/pdf",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -10,18 +10,26 @@
|
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
|
+
"module": "./dist/index.js",
|
|
14
|
+
"import": "./dist/index.js",
|
|
13
15
|
"default": "./dist/index.js"
|
|
14
16
|
},
|
|
15
17
|
"./plugins/generation": {
|
|
16
18
|
"types": "./dist/plugins/generation/index.d.ts",
|
|
19
|
+
"module": "./dist/plugins/generation/index.js",
|
|
20
|
+
"import": "./dist/plugins/generation/index.js",
|
|
17
21
|
"default": "./dist/plugins/generation/index.js"
|
|
18
22
|
},
|
|
19
23
|
"./plugins/parsing": {
|
|
20
24
|
"types": "./dist/plugins/parsing/index.d.ts",
|
|
25
|
+
"module": "./dist/plugins/parsing/index.js",
|
|
26
|
+
"import": "./dist/plugins/parsing/index.js",
|
|
21
27
|
"default": "./dist/plugins/parsing/index.js"
|
|
22
28
|
},
|
|
23
29
|
"./plugins/editing": {
|
|
24
30
|
"types": "./dist/plugins/editing/index.d.ts",
|
|
31
|
+
"module": "./dist/plugins/editing/index.js",
|
|
32
|
+
"import": "./dist/plugins/editing/index.js",
|
|
25
33
|
"default": "./dist/plugins/editing/index.js"
|
|
26
34
|
}
|
|
27
35
|
},
|