@kitsy/pdf 0.0.0-stage → 0.1.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 +22 -0
- package/LICENSE +201 -0
- package/NOTICE +16 -0
- package/README.md +229 -2
- package/THIRD_PARTY_NOTICES.md +48 -0
- package/dist/chunk-2K5X7L5J.js +43 -0
- package/dist/chunk-2K5X7L5J.js.map +1 -0
- package/dist/chunk-4EAYBJ6G.js +362 -0
- package/dist/chunk-4EAYBJ6G.js.map +1 -0
- package/dist/chunk-4LBJTDV5.js +165 -0
- package/dist/chunk-4LBJTDV5.js.map +1 -0
- package/dist/chunk-4USCGC24.js +304 -0
- package/dist/chunk-4USCGC24.js.map +1 -0
- package/dist/chunk-5OIMR74G.js +273 -0
- package/dist/chunk-5OIMR74G.js.map +1 -0
- package/dist/chunk-6NFNAKWA.js +257 -0
- package/dist/chunk-6NFNAKWA.js.map +1 -0
- package/dist/chunk-7MTEMQLL.js +47 -0
- package/dist/chunk-7MTEMQLL.js.map +1 -0
- package/dist/chunk-7V4SWTUK.js +83 -0
- package/dist/chunk-7V4SWTUK.js.map +1 -0
- package/dist/chunk-7XH7MFZ4.js +295 -0
- package/dist/chunk-7XH7MFZ4.js.map +1 -0
- package/dist/chunk-BK3MYSUS.js +61 -0
- package/dist/chunk-BK3MYSUS.js.map +1 -0
- package/dist/chunk-BLHNKR3S.js +35 -0
- package/dist/chunk-BLHNKR3S.js.map +1 -0
- package/dist/chunk-CCJ43SIX.js +342 -0
- package/dist/chunk-CCJ43SIX.js.map +1 -0
- package/dist/chunk-CNEDWATL.js +210 -0
- package/dist/chunk-CNEDWATL.js.map +1 -0
- package/dist/chunk-CYTWDJE2.js +152 -0
- package/dist/chunk-CYTWDJE2.js.map +1 -0
- package/dist/chunk-DKVOICYZ.js +45 -0
- package/dist/chunk-DKVOICYZ.js.map +1 -0
- package/dist/chunk-DPEJU4P6.js +79 -0
- package/dist/chunk-DPEJU4P6.js.map +1 -0
- package/dist/chunk-DQPABZTU.js +22 -0
- package/dist/chunk-DQPABZTU.js.map +1 -0
- package/dist/chunk-EKHEY3LI.js +46 -0
- package/dist/chunk-EKHEY3LI.js.map +1 -0
- package/dist/chunk-G467LFKC.js +191 -0
- package/dist/chunk-G467LFKC.js.map +1 -0
- package/dist/chunk-GLYWSVSB.js +250 -0
- package/dist/chunk-GLYWSVSB.js.map +1 -0
- package/dist/chunk-GXBIMUO7.js +135 -0
- package/dist/chunk-GXBIMUO7.js.map +1 -0
- package/dist/chunk-H6EERRCR.js +180 -0
- package/dist/chunk-H6EERRCR.js.map +1 -0
- package/dist/chunk-HDTM3LXD.js +35 -0
- package/dist/chunk-HDTM3LXD.js.map +1 -0
- package/dist/chunk-IGMX56C3.js +180 -0
- package/dist/chunk-IGMX56C3.js.map +1 -0
- package/dist/chunk-J4IRICCJ.js +74 -0
- package/dist/chunk-J4IRICCJ.js.map +1 -0
- package/dist/chunk-JXKQ7S6W.js +331 -0
- package/dist/chunk-JXKQ7S6W.js.map +1 -0
- package/dist/chunk-KY6DXS6S.js +34 -0
- package/dist/chunk-KY6DXS6S.js.map +1 -0
- package/dist/chunk-NOFGCYGS.js +22 -0
- package/dist/chunk-NOFGCYGS.js.map +1 -0
- package/dist/chunk-OSHUJRKD.js +131 -0
- package/dist/chunk-OSHUJRKD.js.map +1 -0
- package/dist/chunk-PMH7OWPF.js +40 -0
- package/dist/chunk-PMH7OWPF.js.map +1 -0
- package/dist/chunk-PRBKSX3A.js +299 -0
- package/dist/chunk-PRBKSX3A.js.map +1 -0
- package/dist/chunk-SVPUX7AM.js +48 -0
- package/dist/chunk-SVPUX7AM.js.map +1 -0
- package/dist/chunk-TR6HJ4NO.js +659 -0
- package/dist/chunk-TR6HJ4NO.js.map +1 -0
- package/dist/chunk-TV3E4YUF.js +69 -0
- package/dist/chunk-TV3E4YUF.js.map +1 -0
- package/dist/chunk-U2ROTOPF.js +256 -0
- package/dist/chunk-U2ROTOPF.js.map +1 -0
- package/dist/chunk-VCTN77K2.js +112 -0
- package/dist/chunk-VCTN77K2.js.map +1 -0
- package/dist/chunk-WEOPDD3P.js +120 -0
- package/dist/chunk-WEOPDD3P.js.map +1 -0
- package/dist/chunk-ZBZ7OC6I.js +228 -0
- package/dist/chunk-ZBZ7OC6I.js.map +1 -0
- package/dist/config-CJYo46X9.d.ts +19 -0
- package/dist/index.d.ts +487 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/react/certificate-sign.d.ts +5 -0
- package/dist/react/certificate-sign.js +14 -0
- package/dist/react/certificate-sign.js.map +1 -0
- package/dist/react/compress.d.ts +5 -0
- package/dist/react/compress.js +8 -0
- package/dist/react/compress.js.map +1 -0
- package/dist/react/fill-form.d.ts +5 -0
- package/dist/react/fill-form.js +8 -0
- package/dist/react/fill-form.js.map +1 -0
- package/dist/react/images-to-pdf.d.ts +5 -0
- package/dist/react/images-to-pdf.js +7 -0
- package/dist/react/images-to-pdf.js.map +1 -0
- package/dist/react/merge.d.ts +5 -0
- package/dist/react/merge.js +8 -0
- package/dist/react/merge.js.map +1 -0
- package/dist/react/metadata.d.ts +5 -0
- package/dist/react/metadata.js +8 -0
- package/dist/react/metadata.js.map +1 -0
- package/dist/react/organize.d.ts +5 -0
- package/dist/react/organize.js +12 -0
- package/dist/react/organize.js.map +1 -0
- package/dist/react/pdf-to-images.d.ts +5 -0
- package/dist/react/pdf-to-images.js +13 -0
- package/dist/react/pdf-to-images.js.map +1 -0
- package/dist/react/protect.d.ts +5 -0
- package/dist/react/protect.js +8 -0
- package/dist/react/protect.js.map +1 -0
- package/dist/react/sign.d.ts +5 -0
- package/dist/react/sign.js +13 -0
- package/dist/react/sign.js.map +1 -0
- package/dist/react/split.d.ts +5 -0
- package/dist/react/split.js +11 -0
- package/dist/react/split.js.map +1 -0
- package/dist/react/verify-signatures.d.ts +5 -0
- package/dist/react/verify-signatures.js +8 -0
- package/dist/react/verify-signatures.js.map +1 -0
- package/dist/react/watermark.d.ts +5 -0
- package/dist/react/watermark.js +10 -0
- package/dist/react/watermark.js.map +1 -0
- package/dist/react.d.ts +40 -0
- package/dist/react.js +40 -0
- package/dist/react.js.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/vite.d.ts +5 -0
- package/dist/vite.js +9 -0
- package/dist/vite.js.map +1 -0
- package/package.json +163 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
export { P as PdfConfig, c as configurePdf, g as getPdfConfig } from './config-CJYo46X9.js';
|
|
2
|
+
import { PDFDocument, PDFDict, PDFPage } from 'pdf-lib';
|
|
3
|
+
|
|
4
|
+
declare function isPdfFile(file: {
|
|
5
|
+
name?: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
}): boolean;
|
|
8
|
+
declare function formatBytes(bytes?: number): string;
|
|
9
|
+
/** Strip a known extension and characters that are invalid in file names. */
|
|
10
|
+
declare function toBaseName(value: string, fallback: string): string;
|
|
11
|
+
declare function downloadBlob(blob: Blob, fileName: string): void;
|
|
12
|
+
declare function loadPdf(bytes: ArrayBuffer | Uint8Array, options?: {
|
|
13
|
+
updateMetadata?: boolean;
|
|
14
|
+
}): Promise<PDFDocument>;
|
|
15
|
+
declare function getPdfPageCount(bytes: ArrayBuffer | Uint8Array): Promise<number>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Parse a 1-based page selection ("1-3, 5, 8-") into groups of 0-based page
|
|
19
|
+
* indices, one group per comma-separated part, in the order typed.
|
|
20
|
+
*/
|
|
21
|
+
declare function parsePageGroups(selection: string | undefined, pageCount: number): number[][];
|
|
22
|
+
/**
|
|
23
|
+
* Parse a 1-based page selection ("1-3, 5, 8-") into 0-based page indices,
|
|
24
|
+
* preserving the order the user typed. Empty means every page. Throws on
|
|
25
|
+
* out-of-range or malformed input.
|
|
26
|
+
*/
|
|
27
|
+
declare function parsePageSelection(selection: string | undefined, pageCount: number): number[];
|
|
28
|
+
|
|
29
|
+
type SignatureField = {
|
|
30
|
+
/** Fully qualified field name, e.g. "Signature1". */
|
|
31
|
+
name: string;
|
|
32
|
+
field: PDFDict;
|
|
33
|
+
/** The signature dictionary (/V), when the field has been signed. */
|
|
34
|
+
value: PDFDict | null;
|
|
35
|
+
};
|
|
36
|
+
/** Every signature field in the AcroForm tree (FT is inheritable). */
|
|
37
|
+
declare function signatureFields(doc: PDFDocument): SignatureField[];
|
|
38
|
+
/** True when the PDF carries at least one applied digital signature. */
|
|
39
|
+
declare function hasDigitalSignatures(doc: PDFDocument): boolean;
|
|
40
|
+
|
|
41
|
+
declare function crc32(bytes: Uint8Array): number;
|
|
42
|
+
type ZipEntry = {
|
|
43
|
+
name: string;
|
|
44
|
+
bytes: Uint8Array;
|
|
45
|
+
};
|
|
46
|
+
declare function createZip(entries: ZipEntry[], date?: Date): Uint8Array<ArrayBuffer>;
|
|
47
|
+
|
|
48
|
+
declare function loadPdfJs(): any;
|
|
49
|
+
/**
|
|
50
|
+
* Open a PDF for rendering. pdf.js transfers the buffer it is given to its
|
|
51
|
+
* worker (leaving it empty), so it always gets a copy.
|
|
52
|
+
*/
|
|
53
|
+
declare function openRenderDocument(bytes: ArrayBuffer | Uint8Array): Promise<any>;
|
|
54
|
+
/**
|
|
55
|
+
* Render one page (1-based) as it appears in a viewer: CropBox and /Rotate
|
|
56
|
+
* applied. Returns the canvas and its CSS-pixel size at scale 1.
|
|
57
|
+
*/
|
|
58
|
+
declare function renderPageToCanvas(doc: any, pageNumber: number, { scale, background, maxPixels }?: {
|
|
59
|
+
scale?: number;
|
|
60
|
+
background?: string;
|
|
61
|
+
maxPixels?: number;
|
|
62
|
+
}): Promise<{
|
|
63
|
+
canvas: HTMLCanvasElement;
|
|
64
|
+
width: any;
|
|
65
|
+
height: any;
|
|
66
|
+
scale: number;
|
|
67
|
+
reduced: boolean;
|
|
68
|
+
}>;
|
|
69
|
+
declare function canvasToBlob(canvas: HTMLCanvasElement, type?: string, quality?: number): Promise<Blob>;
|
|
70
|
+
/** Render a small thumbnail as an object URL. Caller revokes it. */
|
|
71
|
+
declare function renderThumbnail(doc: any, pageNumber: number, targetWidth?: number): Promise<{
|
|
72
|
+
url: string;
|
|
73
|
+
width: any;
|
|
74
|
+
height: any;
|
|
75
|
+
}>;
|
|
76
|
+
|
|
77
|
+
type MergePdfSource = {
|
|
78
|
+
name: string;
|
|
79
|
+
bytes: ArrayBuffer | Uint8Array;
|
|
80
|
+
/** Optional 1-based page selection, e.g. "1-3, 5, 8-". Empty means all pages. */
|
|
81
|
+
pages?: string;
|
|
82
|
+
};
|
|
83
|
+
type MergePdfOptions = {
|
|
84
|
+
title?: string;
|
|
85
|
+
};
|
|
86
|
+
declare function mergePdfs(sources: MergePdfSource[], options?: MergePdfOptions): Promise<Uint8Array<ArrayBufferLike>>;
|
|
87
|
+
|
|
88
|
+
type SplitMode = "ranges" | "every" | "extract";
|
|
89
|
+
type SplitPdfOptions = {
|
|
90
|
+
mode: SplitMode;
|
|
91
|
+
/** 1-based selection. "ranges": one file per comma part. "extract": one file. */
|
|
92
|
+
ranges?: string;
|
|
93
|
+
/** "every": pages per output file. */
|
|
94
|
+
every?: number;
|
|
95
|
+
baseName?: string;
|
|
96
|
+
};
|
|
97
|
+
type SplitPdfOutput = {
|
|
98
|
+
name: string;
|
|
99
|
+
pageIndices: number[];
|
|
100
|
+
bytes: Uint8Array;
|
|
101
|
+
};
|
|
102
|
+
/** Work out which pages go into which output file, without touching PDF bytes. */
|
|
103
|
+
declare function planSplit(pageCount: number, options: SplitPdfOptions): number[][];
|
|
104
|
+
declare function splitPdf(bytes: ArrayBuffer | Uint8Array, options: SplitPdfOptions): Promise<SplitPdfOutput[]>;
|
|
105
|
+
|
|
106
|
+
type ImageKind = "png" | "jpg";
|
|
107
|
+
type PageSizeOption = "fit" | "a4" | "letter";
|
|
108
|
+
type OrientationOption = "auto" | "portrait" | "landscape";
|
|
109
|
+
type ImageSource = {
|
|
110
|
+
name: string;
|
|
111
|
+
bytes: ArrayBuffer | Uint8Array;
|
|
112
|
+
};
|
|
113
|
+
type ImagesToPdfOptions = {
|
|
114
|
+
pageSize?: PageSizeOption;
|
|
115
|
+
orientation?: OrientationOption;
|
|
116
|
+
/** Margin in PDF points (1/72 inch). */
|
|
117
|
+
margin?: number;
|
|
118
|
+
title?: string;
|
|
119
|
+
};
|
|
120
|
+
declare function detectImageKind(bytes: ArrayBuffer | Uint8Array): ImageKind | null;
|
|
121
|
+
/**
|
|
122
|
+
* Read the EXIF orientation (1-8) from a JPEG, or 1 when absent. Values other
|
|
123
|
+
* than 1 mean viewers rotate/flip the photo, which pdf-lib does not do.
|
|
124
|
+
*/
|
|
125
|
+
declare function getJpegOrientation(bytes: ArrayBuffer | Uint8Array): number;
|
|
126
|
+
/**
|
|
127
|
+
* Page size and image placement for one image. For "fit" the page wraps the
|
|
128
|
+
* image (plus margin); otherwise the image is scaled down to fit and centred.
|
|
129
|
+
*/
|
|
130
|
+
declare function layoutImage(imageWidth: number, imageHeight: number, { pageSize, orientation, margin, }?: ImagesToPdfOptions): {
|
|
131
|
+
pageWidth: number;
|
|
132
|
+
pageHeight: number;
|
|
133
|
+
x: number;
|
|
134
|
+
y: number;
|
|
135
|
+
width: number;
|
|
136
|
+
height: number;
|
|
137
|
+
};
|
|
138
|
+
declare function imagesToPdf(images: ImageSource[], options?: ImagesToPdfOptions): Promise<Uint8Array<ArrayBufferLike>>;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Map a point in the page's on-screen ("visual") space to PDF user space,
|
|
142
|
+
* accounting for the page's /Rotate. Returns the user-space point and the
|
|
143
|
+
* extra text rotation needed for text to read upright on screen.
|
|
144
|
+
*/
|
|
145
|
+
declare function visualToUser(page: {
|
|
146
|
+
width: number;
|
|
147
|
+
height: number;
|
|
148
|
+
rotation: number;
|
|
149
|
+
}, vx: number, vy: number): {
|
|
150
|
+
x: number;
|
|
151
|
+
y: number;
|
|
152
|
+
angle: number;
|
|
153
|
+
};
|
|
154
|
+
/** Where on-screen point (vx, vy) of the visible page lands in PDF user space. */
|
|
155
|
+
declare function textOrigin(page: PDFPage, vx: number, vy: number): {
|
|
156
|
+
x: number;
|
|
157
|
+
y: number;
|
|
158
|
+
angle: number;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
type NumberPosition = "bottom-left" | "bottom-center" | "bottom-right" | "top-left" | "top-center" | "top-right";
|
|
162
|
+
type WatermarkOptions = {
|
|
163
|
+
text: string;
|
|
164
|
+
fontSize?: number;
|
|
165
|
+
/** 0-1 */
|
|
166
|
+
opacity?: number;
|
|
167
|
+
/** Degrees, counter-clockwise, as seen on screen. */
|
|
168
|
+
rotation?: number;
|
|
169
|
+
/** "#rrggbb" */
|
|
170
|
+
color?: string;
|
|
171
|
+
};
|
|
172
|
+
type PageNumberOptions = {
|
|
173
|
+
/** Tokens: {n} page number, {total} numbered page count. */
|
|
174
|
+
format?: string;
|
|
175
|
+
position?: NumberPosition;
|
|
176
|
+
fontSize?: number;
|
|
177
|
+
startAt?: number;
|
|
178
|
+
margin?: number;
|
|
179
|
+
color?: string;
|
|
180
|
+
};
|
|
181
|
+
type StampPdfOptions = {
|
|
182
|
+
/** 1-based selection of pages to stamp. Empty means all pages. */
|
|
183
|
+
pages?: string;
|
|
184
|
+
watermark?: WatermarkOptions | null;
|
|
185
|
+
pageNumbers?: PageNumberOptions | null;
|
|
186
|
+
};
|
|
187
|
+
declare function formatPageNumber(format: string | undefined, n: number, total: number): string;
|
|
188
|
+
/**
|
|
189
|
+
* Which pages get stamped and the number each one shows. Pages listed twice
|
|
190
|
+
* are stamped once; numbering counts only stamped pages.
|
|
191
|
+
*/
|
|
192
|
+
declare function planStampedPages(targets: number[], startAt?: number): {
|
|
193
|
+
pageIndex: number;
|
|
194
|
+
n: number;
|
|
195
|
+
total: number;
|
|
196
|
+
}[];
|
|
197
|
+
declare function stampPdf(bytes: ArrayBuffer | Uint8Array, options: StampPdfOptions): Promise<Uint8Array<ArrayBufferLike>>;
|
|
198
|
+
|
|
199
|
+
type PdfMetadataFields = {
|
|
200
|
+
title: string;
|
|
201
|
+
author: string;
|
|
202
|
+
subject: string;
|
|
203
|
+
keywords: string;
|
|
204
|
+
creator: string;
|
|
205
|
+
producer: string;
|
|
206
|
+
};
|
|
207
|
+
type PdfMetadata = PdfMetadataFields & {
|
|
208
|
+
pageCount: number;
|
|
209
|
+
creationDate: Date | null;
|
|
210
|
+
modificationDate: Date | null;
|
|
211
|
+
hasXmp: boolean;
|
|
212
|
+
};
|
|
213
|
+
declare function readPdfMetadata(bytes: ArrayBuffer | Uint8Array): Promise<PdfMetadata>;
|
|
214
|
+
declare function splitKeywords(value: string): string[];
|
|
215
|
+
declare function writePdfMetadata(bytes: ArrayBuffer | Uint8Array, fields: Partial<PdfMetadataFields>, { stripXmp, now }?: {
|
|
216
|
+
stripXmp?: boolean;
|
|
217
|
+
now?: Date;
|
|
218
|
+
}): Promise<Uint8Array<ArrayBufferLike>>;
|
|
219
|
+
|
|
220
|
+
/** One page of the output: which source page (0-based) and extra rotation. */
|
|
221
|
+
type PageEdit = {
|
|
222
|
+
source: number;
|
|
223
|
+
rotation?: number;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Reorder, rotate, and delete pages. Pages not listed are deleted. Edits the
|
|
227
|
+
* document in place so metadata and document-level settings are kept.
|
|
228
|
+
*/
|
|
229
|
+
declare function organizePdf(bytes: ArrayBuffer | Uint8Array, edits: PageEdit[]): Promise<Uint8Array<ArrayBufferLike>>;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* A signature image placed on a page. x/y/width/height are fractions (0-1)
|
|
233
|
+
* of the visible page, measured from its top-left corner, as on screen.
|
|
234
|
+
*/
|
|
235
|
+
type SignaturePlacement = {
|
|
236
|
+
pageIndex: number;
|
|
237
|
+
image: Uint8Array;
|
|
238
|
+
x: number;
|
|
239
|
+
y: number;
|
|
240
|
+
width: number;
|
|
241
|
+
height: number;
|
|
242
|
+
};
|
|
243
|
+
/** Convert a top-left fractional box into a bottom-left box in visual points. */
|
|
244
|
+
declare function placementToVisual(placement: Pick<SignaturePlacement, "x" | "y" | "width" | "height">, visualWidth: number, visualHeight: number): {
|
|
245
|
+
vx: number;
|
|
246
|
+
vy: number;
|
|
247
|
+
width: number;
|
|
248
|
+
height: number;
|
|
249
|
+
};
|
|
250
|
+
declare function applySignatures(bytes: ArrayBuffer | Uint8Array, placements: SignaturePlacement[]): Promise<Uint8Array<ArrayBufferLike>>;
|
|
251
|
+
|
|
252
|
+
/** Make near-white pixels transparent, e.g. for a photographed signature. */
|
|
253
|
+
declare function whiteToTransparent(data: Uint8ClampedArray, threshold?: number): Uint8ClampedArray<ArrayBufferLike>;
|
|
254
|
+
/** Bounding box of pixels with alpha above the threshold, or null if empty. */
|
|
255
|
+
declare function opaqueBounds(data: Uint8ClampedArray, width: number, height: number, alphaThreshold?: number): {
|
|
256
|
+
x: number;
|
|
257
|
+
y: number;
|
|
258
|
+
width: number;
|
|
259
|
+
height: number;
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
type ImageFormat = "png" | "jpeg";
|
|
263
|
+
/** PDF user space is 72 points per inch. */
|
|
264
|
+
declare function dpiToScale(dpi: number): number;
|
|
265
|
+
/** "report-page-07.png": zero-padded so files sort in page order. */
|
|
266
|
+
declare function imageFileName(baseName: string, pageNumber: number, pageCount: number, format: ImageFormat): string;
|
|
267
|
+
/** Pixel size of a page rendered at the given DPI, before any browser limits. */
|
|
268
|
+
declare function renderedSize(widthPoints: number, heightPoints: number, dpi: number): {
|
|
269
|
+
width: number;
|
|
270
|
+
height: number;
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
type ImageInput = {
|
|
274
|
+
kind: "jpeg";
|
|
275
|
+
bytes: Uint8Array;
|
|
276
|
+
width: number;
|
|
277
|
+
height: number;
|
|
278
|
+
} | {
|
|
279
|
+
kind: "raw";
|
|
280
|
+
pixels: Uint8Array;
|
|
281
|
+
width: number;
|
|
282
|
+
height: number;
|
|
283
|
+
components: 1 | 3;
|
|
284
|
+
};
|
|
285
|
+
type CompressTarget = {
|
|
286
|
+
maxDimension: number;
|
|
287
|
+
quality: number;
|
|
288
|
+
};
|
|
289
|
+
/** Browser (canvas) or test implementation of the pixel work. */
|
|
290
|
+
type ImageCodec = {
|
|
291
|
+
inflate(bytes: Uint8Array): Promise<Uint8Array>;
|
|
292
|
+
encodeJpeg(input: ImageInput, target: CompressTarget): Promise<{
|
|
293
|
+
bytes: Uint8Array;
|
|
294
|
+
width: number;
|
|
295
|
+
height: number;
|
|
296
|
+
}>;
|
|
297
|
+
};
|
|
298
|
+
declare const COMPRESSION_LEVELS: Record<string, CompressTarget & {
|
|
299
|
+
label: string;
|
|
300
|
+
}>;
|
|
301
|
+
/** Number of colour components for colour spaces we can safely re-encode. */
|
|
302
|
+
declare function colorComponents(dict: PDFDict): 1 | 3 | null;
|
|
303
|
+
/** Reverse PNG row predictors (PDF /Predictor 10-15). */
|
|
304
|
+
declare function unpredictPng(data: Uint8Array, columns: number, colors: number, bitsPerComponent?: number): Uint8Array<ArrayBuffer>;
|
|
305
|
+
type CompressStats = {
|
|
306
|
+
images: number;
|
|
307
|
+
compressed: number;
|
|
308
|
+
originalSize: number;
|
|
309
|
+
newSize: number;
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* Re-encode large embedded images as smaller JPEGs. Images that are masks,
|
|
313
|
+
* use unusual colour spaces, or would not shrink are left untouched.
|
|
314
|
+
*/
|
|
315
|
+
declare function compressPdf(bytes: ArrayBuffer | Uint8Array, target: CompressTarget, codec: ImageCodec, onProgress?: (done: number, total: number) => void): Promise<{
|
|
316
|
+
bytes: Uint8Array<ArrayBufferLike>;
|
|
317
|
+
stats: CompressStats;
|
|
318
|
+
}>;
|
|
319
|
+
|
|
320
|
+
declare const browserCodec: ImageCodec;
|
|
321
|
+
|
|
322
|
+
type FieldKind = "text" | "checkbox" | "radio" | "dropdown" | "list" | "button" | "signature";
|
|
323
|
+
type FormFieldInfo = {
|
|
324
|
+
name: string;
|
|
325
|
+
kind: FieldKind;
|
|
326
|
+
/** text: string; checkbox: boolean; radio/dropdown: string; list: string[] */
|
|
327
|
+
value: string | boolean | string[];
|
|
328
|
+
options?: string[];
|
|
329
|
+
multiline?: boolean;
|
|
330
|
+
maxLength?: number;
|
|
331
|
+
multiSelect?: boolean;
|
|
332
|
+
/** Dropdowns that accept a typed value as well as the listed options. */
|
|
333
|
+
editable?: boolean;
|
|
334
|
+
readOnly: boolean;
|
|
335
|
+
required: boolean;
|
|
336
|
+
/** 1-based page of the field's first widget, or null if not on a page. */
|
|
337
|
+
page: number | null;
|
|
338
|
+
};
|
|
339
|
+
type FormValues = Record<string, string | boolean | string[]>;
|
|
340
|
+
declare function readFormFields(bytes: ArrayBuffer | Uint8Array): Promise<{
|
|
341
|
+
fields: FormFieldInfo[];
|
|
342
|
+
hasXfa: boolean;
|
|
343
|
+
}>;
|
|
344
|
+
/**
|
|
345
|
+
* Fill form fields by name. Read-only, button, and signature fields are left
|
|
346
|
+
* alone. With flatten, answers are drawn into the pages and the form removed.
|
|
347
|
+
*/
|
|
348
|
+
declare function fillForm(bytes: ArrayBuffer | Uint8Array, values: FormValues, { flatten }?: {
|
|
349
|
+
flatten?: boolean;
|
|
350
|
+
}): Promise<Uint8Array<ArrayBufferLike>>;
|
|
351
|
+
|
|
352
|
+
/** The parts of an Emscripten qpdf instance we use. */
|
|
353
|
+
type QpdfInstance = {
|
|
354
|
+
callMain(args: string[]): number;
|
|
355
|
+
FS: {
|
|
356
|
+
writeFile(path: string, data: Uint8Array): void;
|
|
357
|
+
readFile(path: string): Uint8Array;
|
|
358
|
+
unlink(path: string): void;
|
|
359
|
+
};
|
|
360
|
+
};
|
|
361
|
+
/** Create a fresh qpdf module (browser: fetches the .wasm; tests: from disk). */
|
|
362
|
+
type QpdfFactory = (options: Record<string, unknown>) => Promise<QpdfInstance>;
|
|
363
|
+
declare class PasswordError extends Error {
|
|
364
|
+
constructor(message?: string);
|
|
365
|
+
}
|
|
366
|
+
type PrintPermission = "full" | "low" | "none";
|
|
367
|
+
type ProtectOptions = {
|
|
368
|
+
/** Needed to open the file. Empty means anyone can open it (restrictions only). */
|
|
369
|
+
userPassword?: string;
|
|
370
|
+
/** Needed to change permissions. Generated when left empty. */
|
|
371
|
+
ownerPassword?: string;
|
|
372
|
+
print?: PrintPermission;
|
|
373
|
+
/** Copying text and images. */
|
|
374
|
+
extract?: boolean;
|
|
375
|
+
/** Any editing: content, pages, annotations, forms. */
|
|
376
|
+
modify?: boolean;
|
|
377
|
+
};
|
|
378
|
+
declare function randomPassword(length?: number): string;
|
|
379
|
+
declare function isEncrypted(bytes: ArrayBuffer | Uint8Array): Promise<boolean>;
|
|
380
|
+
/** Encrypt with AES-256. Returns the bytes and the owner password used. */
|
|
381
|
+
declare function protectPdf(bytes: ArrayBuffer | Uint8Array, options: ProtectOptions, factory: QpdfFactory): Promise<{
|
|
382
|
+
bytes: Uint8Array<ArrayBufferLike>;
|
|
383
|
+
ownerPassword: string;
|
|
384
|
+
}>;
|
|
385
|
+
/**
|
|
386
|
+
* Remove encryption. Tries without a password first, which works for files
|
|
387
|
+
* that only restrict printing or editing. Throws PasswordError when a
|
|
388
|
+
* password is needed or the one given is wrong.
|
|
389
|
+
*/
|
|
390
|
+
declare function unlockPdf(bytes: ArrayBuffer | Uint8Array, password: string, factory: QpdfFactory): Promise<Uint8Array<ArrayBufferLike>>;
|
|
391
|
+
|
|
392
|
+
declare const browserQpdf: QpdfFactory;
|
|
393
|
+
|
|
394
|
+
declare class CertificatePasswordError extends Error {
|
|
395
|
+
constructor();
|
|
396
|
+
}
|
|
397
|
+
type CertificateIdentity = {
|
|
398
|
+
/** DER of the signer certificate, byte-for-byte as stored in the file. */
|
|
399
|
+
certificate: Uint8Array;
|
|
400
|
+
/** DER of the other certificates in the file (issuers), if any. */
|
|
401
|
+
chain: Uint8Array[];
|
|
402
|
+
/** PKCS#8 DER of the RSA private key, for WebCrypto importKey. */
|
|
403
|
+
privateKeyPkcs8: Uint8Array;
|
|
404
|
+
};
|
|
405
|
+
declare function readPkcs12(bytes: ArrayBuffer | Uint8Array, password: string): CertificateIdentity;
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Whatever holds the private key: a .pfx in the browser today, a USB token
|
|
409
|
+
* behind a local signer later. It signs the DER-encoded signed attributes
|
|
410
|
+
* with RSASSA-PKCS1-v1_5 / SHA-256 and never exposes the key.
|
|
411
|
+
*/
|
|
412
|
+
type RawSigner = {
|
|
413
|
+
certificate: Uint8Array;
|
|
414
|
+
chain?: Uint8Array[];
|
|
415
|
+
sign(toBeSigned: Uint8Array): Promise<Uint8Array>;
|
|
416
|
+
};
|
|
417
|
+
/**
|
|
418
|
+
* Build a detached CMS SignedData over a document digest. The signed
|
|
419
|
+
* attributes are DER-sorted and the exact bytes signed are the ones embedded.
|
|
420
|
+
*/
|
|
421
|
+
declare function buildCmsSignature(documentDigest: Uint8Array, signer: RawSigner): Promise<Uint8Array<ArrayBuffer>>;
|
|
422
|
+
/** A RawSigner backed by a PKCS#8 RSA key held in WebCrypto (non-extractable). */
|
|
423
|
+
declare function webCryptoSigner(identity: {
|
|
424
|
+
certificate: Uint8Array;
|
|
425
|
+
chain?: Uint8Array[];
|
|
426
|
+
privateKeyPkcs8: Uint8Array;
|
|
427
|
+
}): Promise<RawSigner>;
|
|
428
|
+
type CertificateSummary = {
|
|
429
|
+
commonName: string;
|
|
430
|
+
organization: string;
|
|
431
|
+
organizationalUnit: string;
|
|
432
|
+
email: string;
|
|
433
|
+
issuerCommonName: string;
|
|
434
|
+
issuerOrganization: string;
|
|
435
|
+
serialNumber: string;
|
|
436
|
+
notBefore: Date;
|
|
437
|
+
notAfter: Date;
|
|
438
|
+
selfSigned: boolean;
|
|
439
|
+
keyBits: number;
|
|
440
|
+
};
|
|
441
|
+
declare function describeCertificate(der: Uint8Array): CertificateSummary;
|
|
442
|
+
|
|
443
|
+
type VisibleSignature = {
|
|
444
|
+
pageIndex: number;
|
|
445
|
+
/** Fractions (0-1) of the visible page, from its top-left corner. */
|
|
446
|
+
x: number;
|
|
447
|
+
y: number;
|
|
448
|
+
width: number;
|
|
449
|
+
height: number;
|
|
450
|
+
};
|
|
451
|
+
type CertificateSignOptions = {
|
|
452
|
+
reason?: string;
|
|
453
|
+
location?: string;
|
|
454
|
+
contactInfo?: string;
|
|
455
|
+
/** Omit for an invisible signature. */
|
|
456
|
+
visible?: VisibleSignature | null;
|
|
457
|
+
signingTime?: Date;
|
|
458
|
+
};
|
|
459
|
+
/** "2026.11.01 14:05:09 +05'30'" in the signer's local time. */
|
|
460
|
+
declare function displayDate(date: Date): string;
|
|
461
|
+
/**
|
|
462
|
+
* Add a digital signature. Rejects PDFs that are already signed: rewriting
|
|
463
|
+
* the file (as pdf-lib does) would invalidate the existing signature.
|
|
464
|
+
*/
|
|
465
|
+
declare function signPdfWithCertificate(bytes: ArrayBuffer | Uint8Array, signer: RawSigner, options?: CertificateSignOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
466
|
+
|
|
467
|
+
type SignatureCheck = {
|
|
468
|
+
fieldName: string;
|
|
469
|
+
subFilter: string;
|
|
470
|
+
/** The signature bytes match the signed content. */
|
|
471
|
+
intact: boolean | null;
|
|
472
|
+
/** The signature covers the whole file (nothing appended after signing). */
|
|
473
|
+
coversWholeFile: boolean;
|
|
474
|
+
signer: CertificateSummary | null;
|
|
475
|
+
/** Certificate validity period includes the claimed signing time. */
|
|
476
|
+
certificateValidAtSigning: boolean | null;
|
|
477
|
+
signingTime: Date | null;
|
|
478
|
+
reason: string;
|
|
479
|
+
location: string;
|
|
480
|
+
/** Why the signature could not be fully checked, if it couldn't. */
|
|
481
|
+
problem: string;
|
|
482
|
+
};
|
|
483
|
+
/** "D:20261101120509+05'30'" -> Date. */
|
|
484
|
+
declare function parsePdfDate(value: string): Date;
|
|
485
|
+
declare function verifyPdfSignatures(bytes: ArrayBuffer | Uint8Array): Promise<SignatureCheck[]>;
|
|
486
|
+
|
|
487
|
+
export { COMPRESSION_LEVELS, CertificatePasswordError, type CertificateSignOptions, type CertificateSummary, type CompressStats, type CompressTarget, type FieldKind, type FormFieldInfo, type FormValues, type ImageCodec, type ImageFormat, type ImageKind, type ImageSource, type ImagesToPdfOptions, type MergePdfOptions, type MergePdfSource, type NumberPosition, type OrientationOption, type PageEdit, type PageNumberOptions, type PageSizeOption, PasswordError, type PdfMetadata, type PdfMetadataFields, type PrintPermission, type ProtectOptions, type QpdfFactory, type RawSigner, type SignatureCheck, type SignatureField, type SignaturePlacement, type SplitMode, type SplitPdfOptions, type SplitPdfOutput, type StampPdfOptions, type VisibleSignature, type WatermarkOptions, type ZipEntry, applySignatures, browserCodec, browserQpdf, buildCmsSignature, canvasToBlob, colorComponents, compressPdf, crc32, createZip, describeCertificate, detectImageKind, displayDate, downloadBlob, dpiToScale, fillForm, formatBytes, formatPageNumber, getJpegOrientation, getPdfPageCount, hasDigitalSignatures, imageFileName, imagesToPdf, isEncrypted, isPdfFile, layoutImage, loadPdf, loadPdfJs, mergePdfs, opaqueBounds, openRenderDocument, organizePdf, parsePageGroups, parsePageSelection, parsePdfDate, placementToVisual, planSplit, planStampedPages, protectPdf, randomPassword, readFormFields, readPdfMetadata, readPkcs12, renderPageToCanvas, renderThumbnail, renderedSize, signPdfWithCertificate, signatureFields, splitKeywords, splitPdf, stampPdf, textOrigin, toBaseName, unlockPdf, unpredictPng, verifyPdfSignatures, visualToUser, webCryptoSigner, whiteToTransparent, writePdfMetadata };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { organizePdf } from './chunk-GXBIMUO7.js';
|
|
2
|
+
export { opaqueBounds, whiteToTransparent } from './chunk-KY6DXS6S.js';
|
|
3
|
+
export { dpiToScale, imageFileName, renderedSize } from './chunk-NOFGCYGS.js';
|
|
4
|
+
export { COMPRESSION_LEVELS, browserCodec, colorComponents, compressPdf, unpredictPng } from './chunk-ZBZ7OC6I.js';
|
|
5
|
+
export { fillForm, readFormFields } from './chunk-CYTWDJE2.js';
|
|
6
|
+
export { PasswordError, browserQpdf, isEncrypted, protectPdf, randomPassword, unlockPdf } from './chunk-OSHUJRKD.js';
|
|
7
|
+
export { CertificatePasswordError, displayDate, readPkcs12, signPdfWithCertificate } from './chunk-U2ROTOPF.js';
|
|
8
|
+
export { applySignatures, placementToVisual } from './chunk-SVPUX7AM.js';
|
|
9
|
+
export { canvasToBlob, loadPdfJs, openRenderDocument, renderPageToCanvas, renderThumbnail } from './chunk-DPEJU4P6.js';
|
|
10
|
+
export { buildCmsSignature, describeCertificate, parsePdfDate, verifyPdfSignatures, webCryptoSigner } from './chunk-5OIMR74G.js';
|
|
11
|
+
export { mergePdfs } from './chunk-HDTM3LXD.js';
|
|
12
|
+
export { planSplit, splitPdf } from './chunk-TV3E4YUF.js';
|
|
13
|
+
export { crc32, createZip } from './chunk-7V4SWTUK.js';
|
|
14
|
+
export { detectImageKind, getJpegOrientation, imagesToPdf, layoutImage } from './chunk-WEOPDD3P.js';
|
|
15
|
+
export { configurePdf, getPdfConfig } from './chunk-DQPABZTU.js';
|
|
16
|
+
export { formatPageNumber, planStampedPages, stampPdf } from './chunk-VCTN77K2.js';
|
|
17
|
+
export { textOrigin, visualToUser } from './chunk-PMH7OWPF.js';
|
|
18
|
+
export { parsePageGroups, parsePageSelection } from './chunk-BLHNKR3S.js';
|
|
19
|
+
export { readPdfMetadata, splitKeywords, writePdfMetadata } from './chunk-DKVOICYZ.js';
|
|
20
|
+
export { hasDigitalSignatures, signatureFields } from './chunk-7MTEMQLL.js';
|
|
21
|
+
export { downloadBlob, formatBytes, getPdfPageCount, isPdfFile, loadPdf, toBaseName } from './chunk-EKHEY3LI.js';
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { CertSignPdf as default } from '../chunk-4USCGC24.js';
|
|
2
|
+
import '../chunk-2K5X7L5J.js';
|
|
3
|
+
import '../chunk-U2ROTOPF.js';
|
|
4
|
+
import '../chunk-SVPUX7AM.js';
|
|
5
|
+
import '../chunk-DPEJU4P6.js';
|
|
6
|
+
import '../chunk-5OIMR74G.js';
|
|
7
|
+
import '../chunk-DQPABZTU.js';
|
|
8
|
+
import '../chunk-PMH7OWPF.js';
|
|
9
|
+
import '../chunk-BK3MYSUS.js';
|
|
10
|
+
import '../chunk-7MTEMQLL.js';
|
|
11
|
+
import '../chunk-H6EERRCR.js';
|
|
12
|
+
import '../chunk-EKHEY3LI.js';
|
|
13
|
+
//# sourceMappingURL=certificate-sign.js.map
|
|
14
|
+
//# sourceMappingURL=certificate-sign.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"certificate-sign.js"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { CompressPdf as default } from '../chunk-4LBJTDV5.js';
|
|
2
|
+
import '../chunk-ZBZ7OC6I.js';
|
|
3
|
+
import '../chunk-BK3MYSUS.js';
|
|
4
|
+
import '../chunk-7MTEMQLL.js';
|
|
5
|
+
import '../chunk-H6EERRCR.js';
|
|
6
|
+
import '../chunk-EKHEY3LI.js';
|
|
7
|
+
//# sourceMappingURL=compress.js.map
|
|
8
|
+
//# sourceMappingURL=compress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"compress.js"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { FillPdfForm as default } from '../chunk-7XH7MFZ4.js';
|
|
2
|
+
import '../chunk-CYTWDJE2.js';
|
|
3
|
+
import '../chunk-BK3MYSUS.js';
|
|
4
|
+
import '../chunk-7MTEMQLL.js';
|
|
5
|
+
import '../chunk-H6EERRCR.js';
|
|
6
|
+
import '../chunk-EKHEY3LI.js';
|
|
7
|
+
//# sourceMappingURL=fill-form.js.map
|
|
8
|
+
//# sourceMappingURL=fill-form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"fill-form.js"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ImagesToPdf as default } from '../chunk-CCJ43SIX.js';
|
|
2
|
+
import '../chunk-WEOPDD3P.js';
|
|
3
|
+
import '../chunk-DQPABZTU.js';
|
|
4
|
+
import '../chunk-H6EERRCR.js';
|
|
5
|
+
import '../chunk-EKHEY3LI.js';
|
|
6
|
+
//# sourceMappingURL=images-to-pdf.js.map
|
|
7
|
+
//# sourceMappingURL=images-to-pdf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"images-to-pdf.js"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { MergePdf as default } from '../chunk-JXKQ7S6W.js';
|
|
2
|
+
import '../chunk-HDTM3LXD.js';
|
|
3
|
+
import '../chunk-DQPABZTU.js';
|
|
4
|
+
import '../chunk-BLHNKR3S.js';
|
|
5
|
+
import '../chunk-H6EERRCR.js';
|
|
6
|
+
import '../chunk-EKHEY3LI.js';
|
|
7
|
+
//# sourceMappingURL=merge.js.map
|
|
8
|
+
//# sourceMappingURL=merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"merge.js"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { PdfMetadata as default } from '../chunk-G467LFKC.js';
|
|
2
|
+
import '../chunk-DKVOICYZ.js';
|
|
3
|
+
import '../chunk-BK3MYSUS.js';
|
|
4
|
+
import '../chunk-7MTEMQLL.js';
|
|
5
|
+
import '../chunk-H6EERRCR.js';
|
|
6
|
+
import '../chunk-EKHEY3LI.js';
|
|
7
|
+
//# sourceMappingURL=metadata.js.map
|
|
8
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"metadata.js"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { OrganizePdf as default } from '../chunk-6NFNAKWA.js';
|
|
2
|
+
import '../chunk-J4IRICCJ.js';
|
|
3
|
+
import '../chunk-GXBIMUO7.js';
|
|
4
|
+
import '../chunk-DPEJU4P6.js';
|
|
5
|
+
import '../chunk-DQPABZTU.js';
|
|
6
|
+
import '../chunk-PMH7OWPF.js';
|
|
7
|
+
import '../chunk-BK3MYSUS.js';
|
|
8
|
+
import '../chunk-7MTEMQLL.js';
|
|
9
|
+
import '../chunk-H6EERRCR.js';
|
|
10
|
+
import '../chunk-EKHEY3LI.js';
|
|
11
|
+
//# sourceMappingURL=organize.js.map
|
|
12
|
+
//# sourceMappingURL=organize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"organize.js"}
|