modern-pdf-lib 0.14.0 → 0.15.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/README.md +56 -11
- package/dist/bridge-C7U4E7St.mjs +103 -0
- package/dist/bridge-DUcJFVsk.cjs +132 -0
- package/dist/index.cjs +1737 -91
- package/dist/index.d.cts +878 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +878 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1719 -92
- package/dist/{libdeflateWasm-DlHgU5oy.mjs → libdeflateWasm-82loOtIV.mjs} +2 -2
- package/dist/{libdeflateWasm-OkNoqBnO.cjs → libdeflateWasm-Enus0G1k.cjs} +2 -2
- package/dist/{loader-CQfoGFp9.mjs → loader-1VJXLlMZ.mjs} +3 -2
- package/dist/{loader-_fqS-TmT.cjs → loader-CKlBOHma.cjs} +3 -2
- package/dist/{pngEmbed-OYyOe_W0.cjs → pngEmbed-10m4CfBU.cjs} +2 -2
- package/dist/{pngEmbed-DTOqgEUC.mjs → pngEmbed-gaJ9S2Dk.mjs} +2 -2
- package/package.json +4 -1
package/dist/index.d.mts
CHANGED
|
@@ -3162,6 +3162,15 @@ declare class PdfEncryptionHandler {
|
|
|
3162
3162
|
private readonly perms?;
|
|
3163
3163
|
/** The file ID (first element of /ID array). */
|
|
3164
3164
|
private readonly fileId;
|
|
3165
|
+
/**
|
|
3166
|
+
* Cache for per-object derived keys (V=1-4 only).
|
|
3167
|
+
* Key: `(objNum << 16) | genNum` — unique integer per object.
|
|
3168
|
+
* Value: the derived encryption key.
|
|
3169
|
+
*
|
|
3170
|
+
* Avoids recomputing MD5(fileKey + objNum + genNum [+ sAlT]) for
|
|
3171
|
+
* every string and stream in the same object.
|
|
3172
|
+
*/
|
|
3173
|
+
private readonly objectKeyCache;
|
|
3165
3174
|
private constructor();
|
|
3166
3175
|
/**
|
|
3167
3176
|
* Create a new encryption handler for encrypting a document.
|
|
@@ -3580,6 +3589,33 @@ declare class PdfViewerPreferences {
|
|
|
3580
3589
|
*
|
|
3581
3590
|
* @packageDocumentation
|
|
3582
3591
|
*/
|
|
3592
|
+
/**
|
|
3593
|
+
* Options for a visible signature appearance on the page.
|
|
3594
|
+
*/
|
|
3595
|
+
interface VisibleSignatureOptions {
|
|
3596
|
+
/** Zero-based page index where the signature should appear. Default: 0. */
|
|
3597
|
+
pageIndex?: number | undefined;
|
|
3598
|
+
/** Rectangle [x, y, width, height] in PDF points from the bottom-left corner. */
|
|
3599
|
+
rect: [number, number, number, number];
|
|
3600
|
+
/**
|
|
3601
|
+
* Text lines to display in the signature box.
|
|
3602
|
+
* Each string becomes a separate line. If omitted, auto-generates
|
|
3603
|
+
* from the signer name, reason, location, and date.
|
|
3604
|
+
*/
|
|
3605
|
+
text?: string[] | undefined;
|
|
3606
|
+
/** Font size for the text. Default: 10. */
|
|
3607
|
+
fontSize?: number | undefined;
|
|
3608
|
+
/**
|
|
3609
|
+
* Background color as [r, g, b] values (0–1). Default: transparent.
|
|
3610
|
+
*/
|
|
3611
|
+
backgroundColor?: [number, number, number] | undefined;
|
|
3612
|
+
/**
|
|
3613
|
+
* Border color as [r, g, b] values (0–1). Default: [0, 0, 0] (black).
|
|
3614
|
+
*/
|
|
3615
|
+
borderColor?: [number, number, number] | undefined;
|
|
3616
|
+
/** Border width in points. Default: 1. Set to 0 for no border. */
|
|
3617
|
+
borderWidth?: number | undefined;
|
|
3618
|
+
}
|
|
3583
3619
|
/**
|
|
3584
3620
|
* Options for signing a PDF.
|
|
3585
3621
|
*/
|
|
@@ -3598,6 +3634,12 @@ interface SignOptions {
|
|
|
3598
3634
|
contactInfo?: string | undefined;
|
|
3599
3635
|
/** RFC 3161 TSA URL for timestamping (optional). */
|
|
3600
3636
|
timestampUrl?: string | undefined;
|
|
3637
|
+
/**
|
|
3638
|
+
* Visible signature appearance options. When provided, the signature
|
|
3639
|
+
* field is rendered visibly on the specified page with text and
|
|
3640
|
+
* optional styling. When omitted, the signature is invisible.
|
|
3641
|
+
*/
|
|
3642
|
+
appearance?: VisibleSignatureOptions | undefined;
|
|
3601
3643
|
}
|
|
3602
3644
|
/**
|
|
3603
3645
|
* Information about an existing signature in a PDF.
|
|
@@ -4738,6 +4780,24 @@ declare class PdfDocument {
|
|
|
4738
4780
|
* @returns An {@link ImageRef}.
|
|
4739
4781
|
*/
|
|
4740
4782
|
embedJpeg(jpegData: Uint8Array | ArrayBuffer): Promise<ImageRef>;
|
|
4783
|
+
/**
|
|
4784
|
+
* Embed an image, auto-detecting the format from file headers.
|
|
4785
|
+
*
|
|
4786
|
+
* Inspects the first bytes to determine whether the data is PNG or JPEG,
|
|
4787
|
+
* then delegates to {@link embedPng} or {@link embedJpeg} accordingly.
|
|
4788
|
+
*
|
|
4789
|
+
* @param imageData Raw image file bytes (PNG or JPEG).
|
|
4790
|
+
* @returns An {@link ImageRef} to pass to `page.drawImage()`.
|
|
4791
|
+
* @throws If the image format cannot be detected.
|
|
4792
|
+
*
|
|
4793
|
+
* @example
|
|
4794
|
+
* ```ts
|
|
4795
|
+
* const bytes = new Uint8Array(await readFile('photo.jpg'));
|
|
4796
|
+
* const image = await pdf.embedImage(bytes);
|
|
4797
|
+
* page.drawImage(image, { x: 50, y: 400, width: 200, height: 150 });
|
|
4798
|
+
* ```
|
|
4799
|
+
*/
|
|
4800
|
+
embedImage(imageData: Uint8Array | ArrayBuffer): Promise<ImageRef>;
|
|
4741
4801
|
/**
|
|
4742
4802
|
* Embed pages from another PDF as Form XObjects.
|
|
4743
4803
|
*
|
|
@@ -6724,6 +6784,9 @@ interface EncryptDictValues {
|
|
|
6724
6784
|
* Tries the password as both user and owner password. Returns the key
|
|
6725
6785
|
* on the first successful match, or throws if neither works.
|
|
6726
6786
|
*
|
|
6787
|
+
* Results are cached so that re-opening the same PDF with the same
|
|
6788
|
+
* password skips the expensive key derivation.
|
|
6789
|
+
*
|
|
6727
6790
|
* @param password The password to try.
|
|
6728
6791
|
* @param dict Encryption dictionary values.
|
|
6729
6792
|
* @param fileId The first element of the /ID array (unused for R>=5).
|
|
@@ -7459,6 +7522,151 @@ declare class PdfRedactAnnotation extends PdfAnnotation {
|
|
|
7459
7522
|
setQuadPoints(points: number[]): void;
|
|
7460
7523
|
}
|
|
7461
7524
|
//#endregion
|
|
7525
|
+
//#region src/annotation/types/popupAnnotation.d.ts
|
|
7526
|
+
/**
|
|
7527
|
+
* A popup annotation (subtype /Popup).
|
|
7528
|
+
*
|
|
7529
|
+
* Displays a floating window containing the text of its parent
|
|
7530
|
+
* annotation. The parent annotation references this popup via its
|
|
7531
|
+
* `/Popup` entry, and this popup references its parent via `/Parent`.
|
|
7532
|
+
*/
|
|
7533
|
+
declare class PdfPopupAnnotation extends PdfAnnotation {
|
|
7534
|
+
constructor(dict: PdfDict);
|
|
7535
|
+
/**
|
|
7536
|
+
* Create a new popup annotation.
|
|
7537
|
+
*
|
|
7538
|
+
* @param options.open Whether the popup is initially open. Default: false.
|
|
7539
|
+
* @param options.parent Reference to the parent annotation (set after registration).
|
|
7540
|
+
*/
|
|
7541
|
+
static create(options: AnnotationOptions & {
|
|
7542
|
+
open?: boolean | undefined;
|
|
7543
|
+
}): PdfPopupAnnotation;
|
|
7544
|
+
/**
|
|
7545
|
+
* Create a PdfPopupAnnotation from an existing dictionary.
|
|
7546
|
+
*/
|
|
7547
|
+
static fromDict(dict: PdfDict, _resolver?: (ref: PdfRef) => PdfObject | undefined): PdfPopupAnnotation;
|
|
7548
|
+
/** Whether the popup is initially open. */
|
|
7549
|
+
isOpen(): boolean;
|
|
7550
|
+
/** Set the initial open state. */
|
|
7551
|
+
setOpen(open: boolean): void;
|
|
7552
|
+
/**
|
|
7553
|
+
* Set the parent annotation reference.
|
|
7554
|
+
* The parent is the annotation whose text this popup displays.
|
|
7555
|
+
*/
|
|
7556
|
+
setParent(parentRef: PdfRef): void;
|
|
7557
|
+
/** Get the parent annotation reference, if set. */
|
|
7558
|
+
getParent(): PdfRef | undefined;
|
|
7559
|
+
}
|
|
7560
|
+
//#endregion
|
|
7561
|
+
//#region src/annotation/types/caretAnnotation.d.ts
|
|
7562
|
+
/**
|
|
7563
|
+
* Symbol displayed by the caret annotation.
|
|
7564
|
+
*
|
|
7565
|
+
* - `'None'` — No symbol (just the caret marker).
|
|
7566
|
+
* - `'P'` — A paragraph symbol, indicating a new paragraph should
|
|
7567
|
+
* be inserted at this location.
|
|
7568
|
+
*/
|
|
7569
|
+
type CaretSymbol = 'None' | 'P';
|
|
7570
|
+
/**
|
|
7571
|
+
* A caret annotation (subtype /Caret).
|
|
7572
|
+
*
|
|
7573
|
+
* Marks an insertion point in the text. Used in review workflows
|
|
7574
|
+
* to indicate where new content should be added.
|
|
7575
|
+
*/
|
|
7576
|
+
declare class PdfCaretAnnotation extends PdfAnnotation {
|
|
7577
|
+
constructor(dict: PdfDict);
|
|
7578
|
+
/**
|
|
7579
|
+
* Create a new caret annotation.
|
|
7580
|
+
*
|
|
7581
|
+
* @param options.symbol The caret symbol. Default: 'None'.
|
|
7582
|
+
* @param options.caretRect The inner rectangle (RD) that describes
|
|
7583
|
+
* the difference between the annotation rect and the actual caret
|
|
7584
|
+
* position. Format: [left, bottom, right, top] insets.
|
|
7585
|
+
*/
|
|
7586
|
+
static create(options: AnnotationOptions & {
|
|
7587
|
+
symbol?: CaretSymbol | undefined;
|
|
7588
|
+
caretRect?: [number, number, number, number] | undefined;
|
|
7589
|
+
}): PdfCaretAnnotation;
|
|
7590
|
+
/**
|
|
7591
|
+
* Create a PdfCaretAnnotation from an existing dictionary.
|
|
7592
|
+
*/
|
|
7593
|
+
static fromDict(dict: PdfDict, _resolver?: (ref: PdfRef) => PdfObject | undefined): PdfCaretAnnotation;
|
|
7594
|
+
/** Get the caret symbol. Defaults to 'None'. */
|
|
7595
|
+
getSymbol(): CaretSymbol;
|
|
7596
|
+
/** Set the caret symbol. */
|
|
7597
|
+
setSymbol(symbol: CaretSymbol): void;
|
|
7598
|
+
/**
|
|
7599
|
+
* Get the inner rectangle differences (RD entry).
|
|
7600
|
+
* Returns [left, bottom, right, top] insets from the annotation rect.
|
|
7601
|
+
*/
|
|
7602
|
+
getCaretRect(): [number, number, number, number] | undefined;
|
|
7603
|
+
/** Set the inner rectangle differences (RD entry). */
|
|
7604
|
+
setCaretRect(rd: [number, number, number, number]): void;
|
|
7605
|
+
}
|
|
7606
|
+
//#endregion
|
|
7607
|
+
//#region src/annotation/types/fileAttachmentAnnotation.d.ts
|
|
7608
|
+
/**
|
|
7609
|
+
* Standard icon names for file attachment annotations.
|
|
7610
|
+
*
|
|
7611
|
+
* - `'GraphPushPin'` — A push pin on a graph (default).
|
|
7612
|
+
* - `'PaperclipTag'` — A paper clip with a tag.
|
|
7613
|
+
* - `'Paperclip'` — A paper clip.
|
|
7614
|
+
* - `'Tag'` — A tag label.
|
|
7615
|
+
*/
|
|
7616
|
+
type FileAttachmentIcon = 'GraphPushPin' | 'PaperclipTag' | 'Paperclip' | 'Tag';
|
|
7617
|
+
/**
|
|
7618
|
+
* A file attachment annotation (subtype /FileAttachment).
|
|
7619
|
+
*
|
|
7620
|
+
* Embeds a file directly in the annotation, rendered as a clickable
|
|
7621
|
+
* icon on the page. When the user clicks the icon, the PDF viewer
|
|
7622
|
+
* allows them to open or save the embedded file.
|
|
7623
|
+
*/
|
|
7624
|
+
declare class PdfFileAttachmentAnnotation extends PdfAnnotation {
|
|
7625
|
+
/** The raw file data to embed. */
|
|
7626
|
+
private fileData;
|
|
7627
|
+
/** The filename to display. */
|
|
7628
|
+
private fileName;
|
|
7629
|
+
/** Optional MIME type. */
|
|
7630
|
+
private mimeType;
|
|
7631
|
+
/** Optional file description. */
|
|
7632
|
+
private fileDescription;
|
|
7633
|
+
constructor(dict: PdfDict);
|
|
7634
|
+
/**
|
|
7635
|
+
* Create a new file attachment annotation.
|
|
7636
|
+
*
|
|
7637
|
+
* @param options.file The file data to embed.
|
|
7638
|
+
* @param options.fileName The filename (e.g., 'invoice.xml').
|
|
7639
|
+
* @param options.mimeType Optional MIME type (e.g., 'application/xml').
|
|
7640
|
+
* @param options.description Optional description of the file.
|
|
7641
|
+
* @param options.icon Icon to display. Default: 'GraphPushPin'.
|
|
7642
|
+
*/
|
|
7643
|
+
static create(options: AnnotationOptions & {
|
|
7644
|
+
file: Uint8Array;
|
|
7645
|
+
fileName: string;
|
|
7646
|
+
mimeType?: string | undefined;
|
|
7647
|
+
description?: string | undefined;
|
|
7648
|
+
icon?: FileAttachmentIcon | undefined;
|
|
7649
|
+
}): PdfFileAttachmentAnnotation;
|
|
7650
|
+
/**
|
|
7651
|
+
* Create a PdfFileAttachmentAnnotation from an existing dictionary.
|
|
7652
|
+
*/
|
|
7653
|
+
static fromDict(dict: PdfDict, _resolver?: (ref: PdfRef) => PdfObject | undefined): PdfFileAttachmentAnnotation;
|
|
7654
|
+
/** Get the icon name. Defaults to 'GraphPushPin'. */
|
|
7655
|
+
getIcon(): FileAttachmentIcon;
|
|
7656
|
+
/** Set the icon name. */
|
|
7657
|
+
setIcon(icon: FileAttachmentIcon): void;
|
|
7658
|
+
/** Get the filename, if set. */
|
|
7659
|
+
getFileName(): string | undefined;
|
|
7660
|
+
/**
|
|
7661
|
+
* Build the file specification dictionary and register the embedded
|
|
7662
|
+
* file stream. Call this before serializing the annotation.
|
|
7663
|
+
*
|
|
7664
|
+
* @param registry The document's object registry.
|
|
7665
|
+
* @returns The annotation dict with `/FS` referencing the file.
|
|
7666
|
+
*/
|
|
7667
|
+
buildFileSpec(registry: PdfObjectRegistry): PdfDict;
|
|
7668
|
+
}
|
|
7669
|
+
//#endregion
|
|
7462
7670
|
//#region src/annotation/appearanceGenerator.d.ts
|
|
7463
7671
|
/**
|
|
7464
7672
|
* Generate appearance stream for a Square annotation.
|
|
@@ -7680,7 +7888,25 @@ interface ByteRangeResult {
|
|
|
7680
7888
|
* @param placeholderSize Size in bytes for the signature. Default 8192.
|
|
7681
7889
|
* @returns The prepared PDF and ByteRange info.
|
|
7682
7890
|
*/
|
|
7683
|
-
|
|
7891
|
+
/**
|
|
7892
|
+
* Options for visible signature appearance within the byte-range preparation.
|
|
7893
|
+
* @internal
|
|
7894
|
+
*/
|
|
7895
|
+
interface PrepareAppearanceOptions {
|
|
7896
|
+
/** Page rectangle [x, y, width, height]. */
|
|
7897
|
+
rect: [number, number, number, number];
|
|
7898
|
+
/** Lines of text to render inside the signature box. */
|
|
7899
|
+
textLines: string[];
|
|
7900
|
+
/** Font size. Default: 10. */
|
|
7901
|
+
fontSize?: number | undefined;
|
|
7902
|
+
/** Background [r,g,b]. Default: none. */
|
|
7903
|
+
backgroundColor?: [number, number, number] | undefined;
|
|
7904
|
+
/** Border [r,g,b]. Default: [0,0,0]. */
|
|
7905
|
+
borderColor?: [number, number, number] | undefined;
|
|
7906
|
+
/** Border width. Default: 1. */
|
|
7907
|
+
borderWidth?: number | undefined;
|
|
7908
|
+
}
|
|
7909
|
+
declare function prepareForSigning(pdfBytes: Uint8Array, signatureFieldName: string, placeholderSize?: number, appearance?: PrepareAppearanceOptions | undefined): {
|
|
7684
7910
|
preparedPdf: Uint8Array;
|
|
7685
7911
|
byteRange: ByteRangeResult;
|
|
7686
7912
|
};
|
|
@@ -8080,6 +8306,650 @@ declare function validatePdfA(pdfBytes: Uint8Array, level: PdfALevel): PdfAValid
|
|
|
8080
8306
|
*/
|
|
8081
8307
|
declare function enforcePdfA(pdfBytes: Uint8Array, level: PdfALevel): Promise<Uint8Array>;
|
|
8082
8308
|
//#endregion
|
|
8309
|
+
//#region src/wasm/jpeg/bridge.d.ts
|
|
8310
|
+
/**
|
|
8311
|
+
* @module wasm/jpeg/bridge
|
|
8312
|
+
*
|
|
8313
|
+
* TypeScript bridge for the JPEG WASM encoder/decoder module.
|
|
8314
|
+
*
|
|
8315
|
+
* Provides JPEG encoding (raw pixels → JPEG bytes) and decoding (JPEG bytes →
|
|
8316
|
+
* raw pixels) via a Rust WASM module compiled with wasm-bindgen.
|
|
8317
|
+
*
|
|
8318
|
+
* If the WASM module is not available, all functions fail gracefully and
|
|
8319
|
+
* callers should fall back to JS alternatives.
|
|
8320
|
+
*
|
|
8321
|
+
* No Buffer — uses Uint8Array exclusively.
|
|
8322
|
+
*/
|
|
8323
|
+
/** Pre-built wasm-bindgen module interface (when passed directly). */
|
|
8324
|
+
interface JpegWasmModule {
|
|
8325
|
+
encode_jpeg(pixels: Uint8Array, width: number, height: number, channels: number, quality: number, progressive: boolean, chroma_subsampling: number): Uint8Array;
|
|
8326
|
+
decode_jpeg(data: Uint8Array): Uint8Array;
|
|
8327
|
+
}
|
|
8328
|
+
/**
|
|
8329
|
+
* Chroma subsampling modes for JPEG encoding.
|
|
8330
|
+
*
|
|
8331
|
+
* - `'4:4:4'`: No subsampling — best quality, largest file.
|
|
8332
|
+
* - `'4:2:2'`: Horizontal subsampling — good balance.
|
|
8333
|
+
* - `'4:2:0'`: Both directions — smallest file, default for most encoders.
|
|
8334
|
+
*/
|
|
8335
|
+
type ChromaSubsampling = '4:4:4' | '4:2:2' | '4:2:0';
|
|
8336
|
+
/** Result of decoding a JPEG image. */
|
|
8337
|
+
interface JpegDecodeResult {
|
|
8338
|
+
/** Raw pixel data (row-major, channel-interleaved). */
|
|
8339
|
+
readonly pixels: Uint8Array;
|
|
8340
|
+
/** Image width in pixels. */
|
|
8341
|
+
readonly width: number;
|
|
8342
|
+
/** Image height in pixels. */
|
|
8343
|
+
readonly height: number;
|
|
8344
|
+
/** Number of channels (1=grayscale, 3=RGB). */
|
|
8345
|
+
readonly channels: number;
|
|
8346
|
+
}
|
|
8347
|
+
/**
|
|
8348
|
+
* Initialize the JPEG WASM module.
|
|
8349
|
+
*
|
|
8350
|
+
* @param wasmSource - The WASM binary as `Uint8Array`, URL, `Response`,
|
|
8351
|
+
* or a pre-built wasm-bindgen module. When omitted,
|
|
8352
|
+
* the function uses the universal WASM loader.
|
|
8353
|
+
*/
|
|
8354
|
+
declare function initJpegWasm(wasmSource?: JpegWasmModule | Uint8Array | URL | string | Response): Promise<void>;
|
|
8355
|
+
/**
|
|
8356
|
+
* Check whether the JPEG WASM module has been initialized.
|
|
8357
|
+
*
|
|
8358
|
+
* @returns `true` if {@link initJpegWasm} completed successfully.
|
|
8359
|
+
*/
|
|
8360
|
+
declare function isJpegWasmReady(): boolean;
|
|
8361
|
+
/**
|
|
8362
|
+
* Encode raw pixel data to JPEG using the WASM encoder.
|
|
8363
|
+
*
|
|
8364
|
+
* @param pixels - Raw pixel data (row-major, channel-interleaved).
|
|
8365
|
+
* @param width - Image width in pixels.
|
|
8366
|
+
* @param height - Image height in pixels.
|
|
8367
|
+
* @param channels - Number of channels: 1 (grayscale), 3 (RGB), or 4 (RGBA).
|
|
8368
|
+
* @param quality - JPEG quality 1–100.
|
|
8369
|
+
* @param progressive - Encode as progressive JPEG (default: false).
|
|
8370
|
+
* @param chroma - Chroma subsampling mode (default: '4:2:0').
|
|
8371
|
+
* @returns JPEG-encoded bytes, or `undefined` if WASM is not available.
|
|
8372
|
+
*/
|
|
8373
|
+
declare function encodeJpegWasm(pixels: Uint8Array, width: number, height: number, channels: 1 | 3 | 4, quality: number, progressive?: boolean, chroma?: ChromaSubsampling): Uint8Array | undefined;
|
|
8374
|
+
/**
|
|
8375
|
+
* Decode JPEG bytes to raw pixel data using the WASM decoder.
|
|
8376
|
+
*
|
|
8377
|
+
* The WASM module returns a flat byte array with layout:
|
|
8378
|
+
* `[width_u32_le, height_u32_le, channels_u8, ...pixels]`.
|
|
8379
|
+
*
|
|
8380
|
+
* @param jpegBytes - JPEG-encoded image data.
|
|
8381
|
+
* @returns Decoded pixel data with metadata, or `undefined` if WASM is not
|
|
8382
|
+
* available or decoding failed.
|
|
8383
|
+
*/
|
|
8384
|
+
declare function decodeJpegWasm(jpegBytes: Uint8Array): JpegDecodeResult | undefined;
|
|
8385
|
+
//#endregion
|
|
8386
|
+
//#region src/assets/image/imageOptimize.d.ts
|
|
8387
|
+
/**
|
|
8388
|
+
* Options for image downscaling.
|
|
8389
|
+
*/
|
|
8390
|
+
interface DownscaleOptions {
|
|
8391
|
+
/** Target maximum width in pixels. The image is scaled proportionally. */
|
|
8392
|
+
readonly maxWidth?: number;
|
|
8393
|
+
/** Target maximum height in pixels. The image is scaled proportionally. */
|
|
8394
|
+
readonly maxHeight?: number;
|
|
8395
|
+
/**
|
|
8396
|
+
* Target DPI for the image at its intended print size. If specified
|
|
8397
|
+
* along with `printWidth` / `printHeight`, the image is downscaled
|
|
8398
|
+
* to match the target DPI.
|
|
8399
|
+
*
|
|
8400
|
+
* For example, a 3000×2000 image printed at 10×6.67 inches would be
|
|
8401
|
+
* 300 DPI. Setting `targetDpi: 150` would downscale to 1500×1000.
|
|
8402
|
+
*/
|
|
8403
|
+
readonly targetDpi?: number;
|
|
8404
|
+
/**
|
|
8405
|
+
* Intended print width in points (1/72 inch).
|
|
8406
|
+
* Used together with `targetDpi` to compute the target pixel dimensions.
|
|
8407
|
+
*/
|
|
8408
|
+
readonly printWidth?: number;
|
|
8409
|
+
/**
|
|
8410
|
+
* Intended print height in points (1/72 inch).
|
|
8411
|
+
* Used together with `targetDpi` to compute the target pixel dimensions.
|
|
8412
|
+
*/
|
|
8413
|
+
readonly printHeight?: number;
|
|
8414
|
+
/**
|
|
8415
|
+
* Resampling algorithm.
|
|
8416
|
+
* - `'nearest'`: Nearest-neighbor (fast, blocky)
|
|
8417
|
+
* - `'bilinear'`: Bilinear interpolation (good quality, moderate speed)
|
|
8418
|
+
* - `'lanczos'`: Lanczos-3 resampling (best quality, slowest)
|
|
8419
|
+
*
|
|
8420
|
+
* Default: `'bilinear'`.
|
|
8421
|
+
*/
|
|
8422
|
+
readonly algorithm?: 'nearest' | 'bilinear' | 'lanczos';
|
|
8423
|
+
}
|
|
8424
|
+
/**
|
|
8425
|
+
* Options for image recompression.
|
|
8426
|
+
*/
|
|
8427
|
+
interface RecompressOptions {
|
|
8428
|
+
/**
|
|
8429
|
+
* Output format.
|
|
8430
|
+
* - `'jpeg'`: JPEG compression (lossy, good for photographs)
|
|
8431
|
+
* - `'deflate'`: Deflate/zlib compression (lossless, used in PDF FlateDecode)
|
|
8432
|
+
*
|
|
8433
|
+
* Default: `'deflate'`.
|
|
8434
|
+
*/
|
|
8435
|
+
readonly format?: 'jpeg' | 'deflate';
|
|
8436
|
+
/**
|
|
8437
|
+
* JPEG quality (1–100). Only used when `format` is `'jpeg'`.
|
|
8438
|
+
* Higher values produce larger files with better quality.
|
|
8439
|
+
*
|
|
8440
|
+
* Default: `85`.
|
|
8441
|
+
*/
|
|
8442
|
+
readonly quality?: number;
|
|
8443
|
+
/**
|
|
8444
|
+
* Deflate compression level (1–9). Only used when `format` is `'deflate'`.
|
|
8445
|
+
* Higher values produce smaller files but take longer.
|
|
8446
|
+
*
|
|
8447
|
+
* Default: `6`.
|
|
8448
|
+
*/
|
|
8449
|
+
readonly compressionLevel?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
8450
|
+
/**
|
|
8451
|
+
* Encode as progressive JPEG. Only used when `format` is `'jpeg'`.
|
|
8452
|
+
*
|
|
8453
|
+
* Progressive JPEGs render in multiple passes (low-res → full-res)
|
|
8454
|
+
* which improves perceived loading speed on slow connections.
|
|
8455
|
+
* They are also often slightly smaller than baseline JPEGs.
|
|
8456
|
+
*
|
|
8457
|
+
* Requires the JPEG WASM module to be initialized.
|
|
8458
|
+
*
|
|
8459
|
+
* Default: `false`.
|
|
8460
|
+
*/
|
|
8461
|
+
readonly progressive?: boolean;
|
|
8462
|
+
/**
|
|
8463
|
+
* Chroma subsampling mode. Only used when `format` is `'jpeg'`.
|
|
8464
|
+
*
|
|
8465
|
+
* - `'4:4:4'`: No subsampling — best color fidelity, largest file.
|
|
8466
|
+
* - `'4:2:2'`: Horizontal subsampling — good balance.
|
|
8467
|
+
* - `'4:2:0'`: Both horizontal and vertical — smallest file.
|
|
8468
|
+
*
|
|
8469
|
+
* Requires the JPEG WASM module to be initialized.
|
|
8470
|
+
*
|
|
8471
|
+
* Default: `'4:2:0'`.
|
|
8472
|
+
*/
|
|
8473
|
+
readonly chromaSubsampling?: ChromaSubsampling;
|
|
8474
|
+
}
|
|
8475
|
+
/**
|
|
8476
|
+
* Combined options for the full optimization pipeline.
|
|
8477
|
+
*/
|
|
8478
|
+
interface ImageOptimizeOptions extends DownscaleOptions, RecompressOptions {
|
|
8479
|
+
/**
|
|
8480
|
+
* Skip optimization if the input data is already smaller than this
|
|
8481
|
+
* threshold (in bytes).
|
|
8482
|
+
*
|
|
8483
|
+
* Default: `0` (always optimize).
|
|
8484
|
+
*/
|
|
8485
|
+
readonly skipBelowBytes?: number;
|
|
8486
|
+
}
|
|
8487
|
+
/**
|
|
8488
|
+
* Raw image pixel data with metadata.
|
|
8489
|
+
*/
|
|
8490
|
+
interface RawImageData {
|
|
8491
|
+
/** Pixel data in row-major order, channel-interleaved. */
|
|
8492
|
+
readonly pixels: Uint8Array;
|
|
8493
|
+
/** Image width in pixels. */
|
|
8494
|
+
readonly width: number;
|
|
8495
|
+
/** Image height in pixels. */
|
|
8496
|
+
readonly height: number;
|
|
8497
|
+
/**
|
|
8498
|
+
* Number of channels:
|
|
8499
|
+
* - 1: Grayscale
|
|
8500
|
+
* - 2: Grayscale + Alpha
|
|
8501
|
+
* - 3: RGB
|
|
8502
|
+
* - 4: RGBA or CMYK (see `colorSpace`)
|
|
8503
|
+
*/
|
|
8504
|
+
readonly channels: 1 | 2 | 3 | 4;
|
|
8505
|
+
/** Bits per channel (typically 8). */
|
|
8506
|
+
readonly bitsPerChannel: number;
|
|
8507
|
+
/**
|
|
8508
|
+
* Color space of the pixel data.
|
|
8509
|
+
*
|
|
8510
|
+
* - `'rgb'` — Channels are R, G, B (and optionally A).
|
|
8511
|
+
* - `'cmyk'` — Channels are C, M, Y, K (only when `channels` is 4).
|
|
8512
|
+
* CMYK pixels are converted to RGB before JPEG encoding.
|
|
8513
|
+
* - `'gray'` — Grayscale (only when `channels` is 1 or 2).
|
|
8514
|
+
*
|
|
8515
|
+
* Default: inferred from channel count (`1|2 → 'gray'`, `3|4 → 'rgb'`).
|
|
8516
|
+
*/
|
|
8517
|
+
readonly colorSpace?: 'rgb' | 'cmyk' | 'gray';
|
|
8518
|
+
}
|
|
8519
|
+
/**
|
|
8520
|
+
* The result of an optimization operation.
|
|
8521
|
+
*/
|
|
8522
|
+
interface OptimizeResult {
|
|
8523
|
+
/** The optimized pixel data (or compressed data if recompressed). */
|
|
8524
|
+
readonly data: Uint8Array;
|
|
8525
|
+
/** Output width in pixels. */
|
|
8526
|
+
readonly width: number;
|
|
8527
|
+
/** Output height in pixels. */
|
|
8528
|
+
readonly height: number;
|
|
8529
|
+
/** Number of channels in the output. */
|
|
8530
|
+
readonly channels: number;
|
|
8531
|
+
/** The compression format applied, if any. */
|
|
8532
|
+
readonly format: 'raw' | 'jpeg' | 'deflate';
|
|
8533
|
+
/** Whether any actual optimization was performed. */
|
|
8534
|
+
readonly wasOptimized: boolean;
|
|
8535
|
+
}
|
|
8536
|
+
/**
|
|
8537
|
+
* Downscale an image to fit within the specified dimensions.
|
|
8538
|
+
*
|
|
8539
|
+
* If the image is already smaller than the target dimensions, it is
|
|
8540
|
+
* returned unchanged.
|
|
8541
|
+
*
|
|
8542
|
+
* @param image - The raw image pixel data.
|
|
8543
|
+
* @param options - Downscaling options (target dimensions, algorithm).
|
|
8544
|
+
* @returns The downscaled image, or the original if no scaling needed.
|
|
8545
|
+
*
|
|
8546
|
+
* @example
|
|
8547
|
+
* ```ts
|
|
8548
|
+
* const result = downscaleImage(rawImage, {
|
|
8549
|
+
* maxWidth: 1024,
|
|
8550
|
+
* maxHeight: 768,
|
|
8551
|
+
* algorithm: 'bilinear',
|
|
8552
|
+
* });
|
|
8553
|
+
* ```
|
|
8554
|
+
*/
|
|
8555
|
+
declare function downscaleImage(image: RawImageData, options?: DownscaleOptions): RawImageData;
|
|
8556
|
+
/**
|
|
8557
|
+
* Recompress raw image pixel data using the specified format.
|
|
8558
|
+
*
|
|
8559
|
+
* @param image - The raw image pixel data.
|
|
8560
|
+
* @param options - Recompression options (format, quality).
|
|
8561
|
+
* @returns The compressed image data.
|
|
8562
|
+
*
|
|
8563
|
+
* @example
|
|
8564
|
+
* ```ts
|
|
8565
|
+
* const result = await recompressImage(rawImage, {
|
|
8566
|
+
* format: 'deflate',
|
|
8567
|
+
* compressionLevel: 9,
|
|
8568
|
+
* });
|
|
8569
|
+
* ```
|
|
8570
|
+
*/
|
|
8571
|
+
declare function recompressImage(image: RawImageData, options?: RecompressOptions): Promise<OptimizeResult>;
|
|
8572
|
+
/**
|
|
8573
|
+
* Run the full image optimization pipeline: downscale then recompress.
|
|
8574
|
+
*
|
|
8575
|
+
* @param image - The raw image pixel data.
|
|
8576
|
+
* @param options - Combined optimization options.
|
|
8577
|
+
* @returns The optimized result.
|
|
8578
|
+
*/
|
|
8579
|
+
declare function optimizeImage(image: RawImageData, options?: ImageOptimizeOptions): Promise<OptimizeResult>;
|
|
8580
|
+
/**
|
|
8581
|
+
* Estimate the JPEG quality level (1–100) from the quantization tables
|
|
8582
|
+
* embedded in a JPEG file.
|
|
8583
|
+
*
|
|
8584
|
+
* Parses the DQT (Define Quantization Table, marker 0xFFDB) segments
|
|
8585
|
+
* from the raw JPEG bytes and compares the table values against the
|
|
8586
|
+
* standard JPEG luminance quantization table to estimate the quality
|
|
8587
|
+
* factor that was used during encoding.
|
|
8588
|
+
*
|
|
8589
|
+
* If no DQT marker is found, returns `undefined`.
|
|
8590
|
+
*
|
|
8591
|
+
* @param jpegBytes - Raw JPEG file bytes.
|
|
8592
|
+
* @returns Estimated quality 1–100, or `undefined` if no DQT is found.
|
|
8593
|
+
*
|
|
8594
|
+
* @example
|
|
8595
|
+
* ```ts
|
|
8596
|
+
* import { estimateJpegQuality } from 'modern-pdf-lib';
|
|
8597
|
+
*
|
|
8598
|
+
* const quality = estimateJpegQuality(jpegBytes);
|
|
8599
|
+
* if (quality !== undefined) {
|
|
8600
|
+
* console.log(`Estimated JPEG quality: ${quality}`);
|
|
8601
|
+
* }
|
|
8602
|
+
* ```
|
|
8603
|
+
*/
|
|
8604
|
+
declare function estimateJpegQuality(jpegBytes: Uint8Array): number | undefined;
|
|
8605
|
+
//#endregion
|
|
8606
|
+
//#region src/assets/image/imageExtract.d.ts
|
|
8607
|
+
/**
|
|
8608
|
+
* Information about a single image XObject in a PDF document.
|
|
8609
|
+
*/
|
|
8610
|
+
interface ImageInfo {
|
|
8611
|
+
/** The PdfStream object for this image (can be mutated for in-place optimization). */
|
|
8612
|
+
readonly stream: PdfStream;
|
|
8613
|
+
/** The indirect reference to this stream in the registry. */
|
|
8614
|
+
readonly ref: PdfRef;
|
|
8615
|
+
/** Resource name on the page (e.g. '/Im1'). */
|
|
8616
|
+
readonly name: string;
|
|
8617
|
+
/** Zero-based page index where this image appears. */
|
|
8618
|
+
readonly pageIndex: number;
|
|
8619
|
+
/** Image width in pixels. */
|
|
8620
|
+
readonly width: number;
|
|
8621
|
+
/** Image height in pixels. */
|
|
8622
|
+
readonly height: number;
|
|
8623
|
+
/** Bits per component (typically 8). */
|
|
8624
|
+
readonly bitsPerComponent: number;
|
|
8625
|
+
/** PDF color space name (e.g. 'DeviceRGB', 'DeviceGray', 'DeviceCMYK'). */
|
|
8626
|
+
readonly colorSpace: string;
|
|
8627
|
+
/** Number of color channels (1, 3, or 4). */
|
|
8628
|
+
readonly channels: number;
|
|
8629
|
+
/** PDF filter name(s) applied to this stream. */
|
|
8630
|
+
readonly filters: readonly string[];
|
|
8631
|
+
/** Size of the compressed stream data in bytes. */
|
|
8632
|
+
readonly compressedSize: number;
|
|
8633
|
+
}
|
|
8634
|
+
/**
|
|
8635
|
+
* Extract all image XObjects from a PDF document.
|
|
8636
|
+
*
|
|
8637
|
+
* Walks every page's `/Resources /XObject` dictionary and collects
|
|
8638
|
+
* metadata for each image XObject found.
|
|
8639
|
+
*
|
|
8640
|
+
* @param doc - A parsed `PdfDocument`.
|
|
8641
|
+
* @returns An array of `ImageInfo` objects, one per image XObject.
|
|
8642
|
+
*
|
|
8643
|
+
* @example
|
|
8644
|
+
* ```ts
|
|
8645
|
+
* import { loadPdf, extractImages } from 'modern-pdf-lib';
|
|
8646
|
+
*
|
|
8647
|
+
* const doc = await loadPdf(pdfBytes);
|
|
8648
|
+
* const images = extractImages(doc);
|
|
8649
|
+
*
|
|
8650
|
+
* for (const img of images) {
|
|
8651
|
+
* console.log(`${img.name}: ${img.width}x${img.height} ${img.colorSpace} (${img.compressedSize} bytes)`);
|
|
8652
|
+
* }
|
|
8653
|
+
* ```
|
|
8654
|
+
*/
|
|
8655
|
+
declare function extractImages(doc: PdfDocument): ImageInfo[];
|
|
8656
|
+
/**
|
|
8657
|
+
* Decode image stream data into raw pixels.
|
|
8658
|
+
*
|
|
8659
|
+
* For DCTDecode (JPEG) streams, returns the raw JPEG bytes (not decoded
|
|
8660
|
+
* to pixels) since JPEG decoding requires the WASM module.
|
|
8661
|
+
*
|
|
8662
|
+
* For FlateDecode and other filters, fully decodes the stream.
|
|
8663
|
+
*
|
|
8664
|
+
* @param imageInfo - An `ImageInfo` from `extractImages()`.
|
|
8665
|
+
* @returns The decoded stream data.
|
|
8666
|
+
*/
|
|
8667
|
+
declare function decodeImageStream(imageInfo: ImageInfo): Uint8Array;
|
|
8668
|
+
//#endregion
|
|
8669
|
+
//#region src/assets/image/batchOptimize.d.ts
|
|
8670
|
+
/**
|
|
8671
|
+
* Options for batch image optimization.
|
|
8672
|
+
*/
|
|
8673
|
+
interface BatchOptimizeOptions {
|
|
8674
|
+
/**
|
|
8675
|
+
* JPEG quality (1–100) for recompressed images.
|
|
8676
|
+
*
|
|
8677
|
+
* Default: `80`.
|
|
8678
|
+
*/
|
|
8679
|
+
readonly quality?: number;
|
|
8680
|
+
/**
|
|
8681
|
+
* Maximum DPI for images. Images exceeding this DPI at their
|
|
8682
|
+
* display size will be downscaled before recompression.
|
|
8683
|
+
*
|
|
8684
|
+
* Default: `150`.
|
|
8685
|
+
*/
|
|
8686
|
+
readonly maxDpi?: number;
|
|
8687
|
+
/**
|
|
8688
|
+
* Encode as progressive JPEG.
|
|
8689
|
+
*
|
|
8690
|
+
* Default: `false`.
|
|
8691
|
+
*/
|
|
8692
|
+
readonly progressive?: boolean;
|
|
8693
|
+
/**
|
|
8694
|
+
* Chroma subsampling mode for JPEG encoding.
|
|
8695
|
+
*
|
|
8696
|
+
* Default: `'4:2:0'`.
|
|
8697
|
+
*/
|
|
8698
|
+
readonly chromaSubsampling?: ChromaSubsampling;
|
|
8699
|
+
/**
|
|
8700
|
+
* Skip images smaller than this threshold (in bytes).
|
|
8701
|
+
*
|
|
8702
|
+
* Default: `false` (process all images).
|
|
8703
|
+
*/
|
|
8704
|
+
readonly skipSmallImages?: boolean;
|
|
8705
|
+
/**
|
|
8706
|
+
* Minimum savings percentage required to replace an image.
|
|
8707
|
+
* If the recompressed image is not at least this much smaller,
|
|
8708
|
+
* the original is kept.
|
|
8709
|
+
*
|
|
8710
|
+
* Default: `10`.
|
|
8711
|
+
*/
|
|
8712
|
+
readonly minSavingsPercent?: number;
|
|
8713
|
+
/**
|
|
8714
|
+
* Auto-detect and convert pseudo-grayscale RGB images to true
|
|
8715
|
+
* grayscale before encoding.
|
|
8716
|
+
*
|
|
8717
|
+
* Default: `false`.
|
|
8718
|
+
*/
|
|
8719
|
+
readonly autoGrayscale?: boolean;
|
|
8720
|
+
}
|
|
8721
|
+
/**
|
|
8722
|
+
* Per-image optimization report entry.
|
|
8723
|
+
*/
|
|
8724
|
+
interface ImageOptimizeEntry {
|
|
8725
|
+
/** Resource name (e.g. '/Im1'). */
|
|
8726
|
+
readonly name: string;
|
|
8727
|
+
/** Page index where this image appears. */
|
|
8728
|
+
readonly pageIndex: number;
|
|
8729
|
+
/** Original compressed size in bytes. */
|
|
8730
|
+
readonly originalSize: number;
|
|
8731
|
+
/** New compressed size in bytes (same as original if skipped). */
|
|
8732
|
+
readonly newSize: number;
|
|
8733
|
+
/** Whether this image was skipped. */
|
|
8734
|
+
readonly skipped: boolean;
|
|
8735
|
+
/** Reason for skipping, if applicable. */
|
|
8736
|
+
readonly reason?: string;
|
|
8737
|
+
}
|
|
8738
|
+
/**
|
|
8739
|
+
* Summary report from batch image optimization.
|
|
8740
|
+
*/
|
|
8741
|
+
interface OptimizationReport {
|
|
8742
|
+
/** Total number of image XObjects found. */
|
|
8743
|
+
readonly totalImages: number;
|
|
8744
|
+
/** Number of images that were recompressed. */
|
|
8745
|
+
readonly optimizedImages: number;
|
|
8746
|
+
/** Total original compressed size (all images). */
|
|
8747
|
+
readonly originalTotalBytes: number;
|
|
8748
|
+
/** Total new compressed size (all images). */
|
|
8749
|
+
readonly optimizedTotalBytes: number;
|
|
8750
|
+
/** Overall savings percentage. */
|
|
8751
|
+
readonly savings: number;
|
|
8752
|
+
/** Per-image details. */
|
|
8753
|
+
readonly perImage: readonly ImageOptimizeEntry[];
|
|
8754
|
+
}
|
|
8755
|
+
/**
|
|
8756
|
+
* Optimize all images in a PDF document by recompressing them as JPEG.
|
|
8757
|
+
*
|
|
8758
|
+
* Walks every image XObject in the document, decodes its pixel data,
|
|
8759
|
+
* recompresses it as JPEG using the WASM encoder (if available), and
|
|
8760
|
+
* replaces the stream data in-place when the result is smaller.
|
|
8761
|
+
*
|
|
8762
|
+
* **Requires the JPEG WASM module to be initialized** via
|
|
8763
|
+
* `initJpegWasm()` or `initWasm({ jpeg: true })`. Without it,
|
|
8764
|
+
* no images will be optimized (all will be skipped).
|
|
8765
|
+
*
|
|
8766
|
+
* @param doc - A parsed `PdfDocument` (from `loadPdf()`).
|
|
8767
|
+
* @param options - Optimization settings.
|
|
8768
|
+
* @returns A report summarizing the optimization results.
|
|
8769
|
+
*
|
|
8770
|
+
* @example
|
|
8771
|
+
* ```ts
|
|
8772
|
+
* import { loadPdf, initWasm, optimizeAllImages } from 'modern-pdf-lib';
|
|
8773
|
+
*
|
|
8774
|
+
* await initWasm({ jpeg: true });
|
|
8775
|
+
*
|
|
8776
|
+
* const doc = await loadPdf(pdfBytes);
|
|
8777
|
+
* const report = await optimizeAllImages(doc);
|
|
8778
|
+
*
|
|
8779
|
+
* console.log(`Optimized ${report.optimizedImages} of ${report.totalImages} images`);
|
|
8780
|
+
* console.log(`Savings: ${report.savings.toFixed(1)}%`);
|
|
8781
|
+
*
|
|
8782
|
+
* const optimizedBytes = await doc.save();
|
|
8783
|
+
* ```
|
|
8784
|
+
*/
|
|
8785
|
+
declare function optimizeAllImages(doc: PdfDocument, options?: BatchOptimizeOptions): Promise<OptimizationReport>;
|
|
8786
|
+
//#endregion
|
|
8787
|
+
//#region src/assets/image/deduplicateImages.d.ts
|
|
8788
|
+
/**
|
|
8789
|
+
* Report from image deduplication.
|
|
8790
|
+
*/
|
|
8791
|
+
interface DeduplicationReport {
|
|
8792
|
+
/** Total number of image XObjects found. */
|
|
8793
|
+
readonly totalImages: number;
|
|
8794
|
+
/** Number of unique images (after deduplication). */
|
|
8795
|
+
readonly uniqueImages: number;
|
|
8796
|
+
/** Number of duplicate references replaced. */
|
|
8797
|
+
readonly duplicatesRemoved: number;
|
|
8798
|
+
/** Estimated bytes saved by deduplication. */
|
|
8799
|
+
readonly bytesSaved: number;
|
|
8800
|
+
}
|
|
8801
|
+
/**
|
|
8802
|
+
* Deduplicate identical images in a PDF document.
|
|
8803
|
+
*
|
|
8804
|
+
* Scans all image XObjects, hashes their compressed stream data (plus
|
|
8805
|
+
* dimensions and filter), and replaces duplicate references in page
|
|
8806
|
+
* resource dictionaries with the canonical (first-seen) copy.
|
|
8807
|
+
*
|
|
8808
|
+
* This operation modifies the document in-place. Duplicate streams
|
|
8809
|
+
* are not removed from the object registry (they become unreferenced
|
|
8810
|
+
* and will be omitted on save if the writer supports garbage collection).
|
|
8811
|
+
*
|
|
8812
|
+
* @param doc - A parsed `PdfDocument` (from `loadPdf()`).
|
|
8813
|
+
* @returns A report summarizing deduplication results.
|
|
8814
|
+
*
|
|
8815
|
+
* @example
|
|
8816
|
+
* ```ts
|
|
8817
|
+
* import { loadPdf, deduplicateImages } from 'modern-pdf-lib';
|
|
8818
|
+
*
|
|
8819
|
+
* const doc = await loadPdf(pdfBytes);
|
|
8820
|
+
* const report = await deduplicateImages(doc);
|
|
8821
|
+
*
|
|
8822
|
+
* console.log(`Removed ${report.duplicatesRemoved} duplicate images`);
|
|
8823
|
+
* console.log(`Saved ~${(report.bytesSaved / 1024).toFixed(0)} KB`);
|
|
8824
|
+
*
|
|
8825
|
+
* const optimizedBytes = await doc.save();
|
|
8826
|
+
* ```
|
|
8827
|
+
*/
|
|
8828
|
+
declare function deduplicateImages(doc: PdfDocument): DeduplicationReport;
|
|
8829
|
+
//#endregion
|
|
8830
|
+
//#region src/assets/image/grayscaleDetect.d.ts
|
|
8831
|
+
/**
|
|
8832
|
+
* @module assets/image/grayscaleDetect
|
|
8833
|
+
*
|
|
8834
|
+
* Grayscale detection and conversion for image optimization.
|
|
8835
|
+
*
|
|
8836
|
+
* Detects RGB images where all pixels are effectively grayscale
|
|
8837
|
+
* (R ≈ G ≈ B) and converts them to single-channel grayscale,
|
|
8838
|
+
* reducing data size by ~66%.
|
|
8839
|
+
*
|
|
8840
|
+
* No Buffer — uses Uint8Array exclusively.
|
|
8841
|
+
*/
|
|
8842
|
+
/**
|
|
8843
|
+
* Check whether an RGB/RGBA image is effectively grayscale.
|
|
8844
|
+
*
|
|
8845
|
+
* Scans all pixels and checks if R, G, and B channels are within
|
|
8846
|
+
* `tolerance` of each other. If ≥99% of pixels pass, the image
|
|
8847
|
+
* is considered grayscale.
|
|
8848
|
+
*
|
|
8849
|
+
* @param pixels - Raw pixel data (row-major, channel-interleaved).
|
|
8850
|
+
* @param width - Image width in pixels.
|
|
8851
|
+
* @param height - Image height in pixels.
|
|
8852
|
+
* @param channels - Number of channels: 3 (RGB) or 4 (RGBA).
|
|
8853
|
+
* @param tolerance - Maximum allowed difference between R, G, and B
|
|
8854
|
+
* values for a pixel to be considered gray.
|
|
8855
|
+
* Default: `2`.
|
|
8856
|
+
* @returns `true` if the image is effectively grayscale.
|
|
8857
|
+
*
|
|
8858
|
+
* @example
|
|
8859
|
+
* ```ts
|
|
8860
|
+
* import { isGrayscaleImage, convertToGrayscale } from 'modern-pdf-lib';
|
|
8861
|
+
*
|
|
8862
|
+
* if (isGrayscaleImage(pixels, width, height, 3)) {
|
|
8863
|
+
* const grayPixels = convertToGrayscale(pixels, width, height, 3);
|
|
8864
|
+
* // grayPixels has 1 byte per pixel instead of 3
|
|
8865
|
+
* }
|
|
8866
|
+
* ```
|
|
8867
|
+
*/
|
|
8868
|
+
declare function isGrayscaleImage(pixels: Uint8Array, width: number, height: number, channels: 3 | 4, tolerance?: number): boolean;
|
|
8869
|
+
/**
|
|
8870
|
+
* Convert an RGB/RGBA image to single-channel grayscale.
|
|
8871
|
+
*
|
|
8872
|
+
* Uses the ITU-R BT.601 luma formula:
|
|
8873
|
+
* ```
|
|
8874
|
+
* gray = 0.299 × R + 0.587 × G + 0.114 × B
|
|
8875
|
+
* ```
|
|
8876
|
+
*
|
|
8877
|
+
* The alpha channel (if present) is discarded.
|
|
8878
|
+
*
|
|
8879
|
+
* @param pixels - Raw pixel data (row-major, channel-interleaved).
|
|
8880
|
+
* @param width - Image width in pixels.
|
|
8881
|
+
* @param height - Image height in pixels.
|
|
8882
|
+
* @param channels - Number of channels: 3 (RGB) or 4 (RGBA).
|
|
8883
|
+
* @returns Grayscale pixel data (1 byte per pixel).
|
|
8884
|
+
*/
|
|
8885
|
+
declare function convertToGrayscale(pixels: Uint8Array, width: number, height: number, channels: 3 | 4): Uint8Array;
|
|
8886
|
+
//#endregion
|
|
8887
|
+
//#region src/assets/image/dpiAnalyze.d.ts
|
|
8888
|
+
/**
|
|
8889
|
+
* @module assets/image/dpiAnalyze
|
|
8890
|
+
*
|
|
8891
|
+
* DPI analysis for PDF image XObjects.
|
|
8892
|
+
*
|
|
8893
|
+
* Computes the effective DPI of an image based on its pixel dimensions
|
|
8894
|
+
* and its display size in the PDF (determined by the content stream's
|
|
8895
|
+
* current transformation matrix).
|
|
8896
|
+
*
|
|
8897
|
+
* No Buffer — uses Uint8Array exclusively.
|
|
8898
|
+
*/
|
|
8899
|
+
/**
|
|
8900
|
+
* DPI information for an image.
|
|
8901
|
+
*/
|
|
8902
|
+
interface ImageDpi {
|
|
8903
|
+
/** Horizontal DPI. */
|
|
8904
|
+
readonly xDpi: number;
|
|
8905
|
+
/** Vertical DPI. */
|
|
8906
|
+
readonly yDpi: number;
|
|
8907
|
+
/** Effective DPI (minimum of xDpi and yDpi). */
|
|
8908
|
+
readonly effectiveDpi: number;
|
|
8909
|
+
}
|
|
8910
|
+
/**
|
|
8911
|
+
* Compute the effective DPI of an image given its pixel dimensions
|
|
8912
|
+
* and display dimensions in points.
|
|
8913
|
+
*
|
|
8914
|
+
* PDF uses 72 points per inch, so:
|
|
8915
|
+
* ```
|
|
8916
|
+
* DPI = imagePixels / (displayPoints / 72)
|
|
8917
|
+
* ```
|
|
8918
|
+
*
|
|
8919
|
+
* @param imageWidth - Image width in pixels.
|
|
8920
|
+
* @param imageHeight - Image height in pixels.
|
|
8921
|
+
* @param displayWidth - Display width in PDF points (1/72 inch).
|
|
8922
|
+
* @param displayHeight - Display height in PDF points (1/72 inch).
|
|
8923
|
+
* @returns DPI information.
|
|
8924
|
+
*
|
|
8925
|
+
* @example
|
|
8926
|
+
* ```ts
|
|
8927
|
+
* import { computeImageDpi } from 'modern-pdf-lib';
|
|
8928
|
+
*
|
|
8929
|
+
* // A 3000×2000 image displayed at 4.17×2.78 inches (300×200 points)
|
|
8930
|
+
* const dpi = computeImageDpi(3000, 2000, 300, 200);
|
|
8931
|
+
* console.log(dpi.effectiveDpi); // 720
|
|
8932
|
+
* ```
|
|
8933
|
+
*/
|
|
8934
|
+
declare function computeImageDpi(imageWidth: number, imageHeight: number, displayWidth: number, displayHeight: number): ImageDpi;
|
|
8935
|
+
/**
|
|
8936
|
+
* Compute the target pixel dimensions for downscaling an image
|
|
8937
|
+
* to a maximum DPI at a given display size.
|
|
8938
|
+
*
|
|
8939
|
+
* @param imageWidth - Current image width in pixels.
|
|
8940
|
+
* @param imageHeight - Current image height in pixels.
|
|
8941
|
+
* @param displayWidth - Display width in PDF points.
|
|
8942
|
+
* @param displayHeight - Display height in PDF points.
|
|
8943
|
+
* @param maxDpi - Maximum allowed DPI.
|
|
8944
|
+
* @returns Target dimensions, or the original dimensions if no
|
|
8945
|
+
* downscaling is needed.
|
|
8946
|
+
*/
|
|
8947
|
+
declare function computeTargetDimensions(imageWidth: number, imageHeight: number, displayWidth: number, displayHeight: number, maxDpi: number): {
|
|
8948
|
+
width: number;
|
|
8949
|
+
height: number;
|
|
8950
|
+
downscaled: boolean;
|
|
8951
|
+
};
|
|
8952
|
+
//#endregion
|
|
8083
8953
|
//#region src/utils/base64.d.ts
|
|
8084
8954
|
/**
|
|
8085
8955
|
* @module utils/base64
|
|
@@ -8250,6 +9120,12 @@ interface InitWasmOptions {
|
|
|
8250
9120
|
* Pre-loaded WASM bytes for the font subsetting module.
|
|
8251
9121
|
*/
|
|
8252
9122
|
fontWasm?: Uint8Array | undefined;
|
|
9123
|
+
/** Initialize the JPEG encoding/decoding WASM module. Default: `false`. */
|
|
9124
|
+
jpeg?: boolean | undefined;
|
|
9125
|
+
/**
|
|
9126
|
+
* Pre-loaded WASM bytes for the JPEG encoding/decoding module.
|
|
9127
|
+
*/
|
|
9128
|
+
jpegWasm?: Uint8Array | undefined;
|
|
8253
9129
|
}
|
|
8254
9130
|
/**
|
|
8255
9131
|
* Initialize the optional WASM acceleration modules.
|
|
@@ -8271,5 +9147,5 @@ interface InitWasmOptions {
|
|
|
8271
9147
|
*/
|
|
8272
9148
|
declare function initWasm(options?: string | URL | InitWasmOptions): Promise<void>;
|
|
8273
9149
|
//#endregion
|
|
8274
|
-
export { type AccessibilityIssue, type Angle, AnnotationFlags, type AnnotationOptions, type AnnotationType, type AppearanceProviderFor, BlendMode, type ButtonAppearanceOptions, type ByteRangeResult, type ByteWriter, type CIDFontData, type CIDSystemInfoData, type CatalogOptions, ChangeTracker, type CheckboxAppearanceOptions, type CmykColor, type Color, type ColorStop, CombedTextLayoutError, type ComputeFontSizeOptions, type ContentStreamOperator, type CropBox, type Degrees, type DocumentMetadata, type DocumentStructure, type DrawCircleOptions, type DrawEllipseOptions, type DrawImageOptions, type DrawLineOptions, type DrawPageOptions, type DrawRectangleOptions, type DrawSquareOptions, type DrawSvgPathOptions, type DrawTextOptions, type DropdownAppearanceOptions, type EmbedFontOptions, type EmbedPageOptions, type EmbeddedFile, EmbeddedFont, type EmbeddedPdfPage, type EncryptAlgorithm, type EncryptDictValues, type EncryptOptions, EncryptedPdfError, ExceededMaxLengthError, FieldAlreadyExistsError, FieldExistsAsNonTerminalError, FieldFlags, type FieldType, type FontDescriptorData, type FontEmbeddingResult, type FontMetrics, FontNotEmbeddedError, type FontRef, ForeignPageError, type FreeTextAlignment, type GradientFill, type GrayscaleColor, ImageAlignment, type ImageRef, type IncrementalSaveResult, InitWasmOptions, InvalidFieldNamePartError, type LayoutCombedOptions, type LayoutMultilineOptions, type LayoutMultilineResult, type LayoutSinglelineOptions, type LayoutSinglelineResult, LineCapStyle, type LineEndingStyle, LineJoinStyle, type LinearGradientOptions, type LinearizationOptions, type LinkHighlightMode, type ListboxAppearanceOptions, type LoadPdfOptions, type MarkedContentScope, MissingOnValueCheckError, NoSuchFieldError, type NormalizedStop, type Operand, type OutlineDestination, type OutlineItemOptions, PDFOperator, type PageEntry, type PageRange, type PageSize, PageSizes, ParseSpeeds, type PatternFill, type PdfAIssue, type PdfALevel, type PdfAValidationResult, PdfAnnotation, PdfArray, PdfBool, PdfButtonField, PdfCheckboxField, PdfCircleAnnotation, PdfDict, PdfDocument, PdfDropdownField, PdfEncryptionHandler, PdfField, PdfForm, PdfFreeTextAnnotation, PdfHighlightAnnotation, PdfInkAnnotation, PdfLayer, PdfLayerManager, PdfLineAnnotation, PdfLinkAnnotation, PdfListboxField, PdfName, PdfNull, PdfNumber, type PdfObject, PdfObjectRegistry, PdfOutlineItem, PdfOutlineTree, PdfPage, PdfParseError, type PdfPermissionFlags, PdfPolyLineAnnotation, PdfPolygonAnnotation, PdfRadioGroup, PdfRedactAnnotation, PdfRef, type PdfSaveOptions, PdfSignatureField, type PdfSignatureInfo, PdfSquareAnnotation, PdfSquigglyAnnotation, PdfStampAnnotation, PdfStream, PdfStreamWriter, PdfStrikeOutAnnotation, PdfString, PdfStructureElement, PdfStructureTree, PdfTextAnnotation, PdfTextField, PdfUnderlineAnnotation, PdfViewerPreferences, PdfWriter, type RadialGradientFill, type RadialGradientOptions, type Radians, type RadioAppearanceOptions, type RedactionMark, type RedactionOptions, type RefResolver, type RegistryEntry, RemovePageFromEmptyDocumentError, type RgbColor, RichTextFieldReadError, type SetTitleOptions, type SignOptions, type SignatureAppearanceOptions, type SignatureOptions, type SignatureVerificationResult, type SignerInfo, type SoftMaskBuilder, type SoftMaskRef, type StandardFontName, StandardFonts, type StandardStampName, type StructureElementOptions, type StructureType, type SubsetCmap, type SubsetResult, type SvgDrawCommand, type SvgElement, type SvgRenderOptions, TextAlignment, type TextAnnotationIcon, type TextAppearanceOptions, type TextExtractionOptions, type TextItem, TextRenderingMode, type TilingPatternOptions, type TimestampResult, type TransparencyGroupOptions, type Type0FontData, UnexpectedFieldTypeError, type ViewerPreferences, type WatermarkOptions, type WidgetAnnotationHost, type WidthEntry, addWatermark, addWatermarkToPage, aesDecryptCBC, aesEncryptCBC, annotationFromDict, applyFillColor, applyRedactions, applyStrokeColor, asNumber, asPDFName, asPDFNumber, attachFile, base64Decode, base64Encode, beginArtifact, beginArtifactWithType, beginLayerContent, beginMarkedContent, beginMarkedContentSequence, beginMarkedContentWithProperties, beginText, buildAnnotationDict, buildCatalog, buildDocumentStructure, buildEmbeddedFilesNameTree, buildGradientObjects, buildInfoDict, buildPageTree, buildPatternObjects, buildPkcs7Signature, buildTimestampRequest, buildViewerPreferencesDict, buildXmpMetadata, checkAccessibility, circlePath, clipEvenOdd, clip as clipOp, closeAndStroke, closeFillAndStroke, closeFillEvenOddAndStroke, closePath as closePathOp, cmyk, colorToComponents, componentsToColor, computeFileEncryptionKey, computeFontSize, computeSignatureHash, concatMatrix, concatMatrix as concatTransformationMatrix, copyPages, createAnnotation, createMarkedContentScope, createPdf, createXmpStream, cropPage, curveToFinal, curveToInitial, curveTo as curveToOp, decodePermissions, decodeStream, degrees, degreesToRadians, drawImageWithMatrix, drawImageXObject, drawXObject as drawObject, drawXObject, drawSvgOnPage, ellipsePath, embedPageAsFormXObject, embedSignature, encodeContextTag, encodeInteger, encodeLength, encodeOID, encodeOctetString, encodePermissions, encodePrintableString, encodeSequence, encodeSet, encodeUTCTime, encodeUtf8String, endArtifact, endLayerContent, endMarkedContent, endPath as endPathOp, endText, enforcePdfA, extractMetrics, extractText, extractTextWithPositions, fillAndStroke as fillAndStrokeOp, fillEvenOdd, fillEvenOddAndStroke, fill as fillOp, findSignatures, formatHexContext, formatPdfDate, generateButtonAppearance, generateCheckboxAppearance, generateCircleAppearance, generateDropdownAppearance, generateFreeTextAppearance, generateHighlightAppearance, generateInkAppearance, generateLineAppearance, generateListboxAppearance, generateRadioAppearance, generateSignatureAppearance, generateSquareAppearance, generateSquigglyAppearance, generateStrikeOutAppearance, generateTextAppearance, generateUnderlineAppearance, getAttachments, getPageSize, getRedactionMarks, getSignatures, grayscale, initWasm, insertPage, isAccessible, isLinearized, isOpenTypeCFF, isTrueType, layoutCombedText, layoutMultilineText, layoutSinglelineText, lineTo as lineToOp, linearGradient, linearizePdf, loadPdf, markForRedaction, md5, mergePdfs, movePage, moveText as moveTextOp, moveTextSetLeading, moveTo as moveToOp, nextLine as nextLineOp, parseContentStream, parseSvg, parseSvgColor, parseSvgPath, parseSvgTransform, parseTimestampResponse, parseViewerPreferences, parseXmpMetadata, restoreState as popGraphicsState, restoreState, prepareForSigning, saveState as pushGraphicsState, saveState, radialGradient, radians, radiansToDegrees, rc4, rectangle as rectangleOp, removePage, removePages, requestTimestamp, resizePage, reversePages, rgb, rotateAllPages, rotate as rotateOp, rotatePage, rotationMatrix, saveDocumentIncremental, saveIncremental, scale as scaleOp, serializePdf, setCharacterSpacing as setCharacterSpacingOp, setCharacterSpacing as setCharacterSqueeze, setColorSpace, setDashPattern as setDashPatternOp, setFillColor, setFillColorCmyk, setFillColorGray, setFillColorRgb, setFillingColor, setFlatness, setFont as setFontAndSize, setFont as setFontOp, setFontSize as setFontSizeOp, setGraphicsState as setGraphicsStateOp, setLeading as setLeadingOp, setLeading as setLineHeight, setLineCap as setLineCapOp, setLineJoin as setLineJoinOp, setLineWidth as setLineWidthOp, setMiterLimit, setStrokeColor, setStrokeColorCmyk, setStrokeColorGray, setStrokeColorRgb, setStrokeColorSpace, setStrokingColor, setTextMatrix as setTextMatrixOp, setTextRenderingMode as setTextRenderingModeOp, setTextRise as setTextRiseOp, setWordSpacing as setWordSpacingOp, sha256, sha384, sha512, showTextArray, showTextHex, showTextNextLine, showText as showTextOp, showTextWithSpacing, signPdf, skew as skewOp, splitPdf, stroke as strokeOp, summarizeIssues, svgToPdfOperators, tilingPattern, translate as translateOp, validatePdfA, verifyOwnerPassword, verifySignature, verifySignatures, verifyUserPassword, wrapInMarkedContent };
|
|
9150
|
+
export { type AccessibilityIssue, type Angle, AnnotationFlags, type AnnotationOptions, type AnnotationType, type AppearanceProviderFor, type BatchOptimizeOptions, BlendMode, type ButtonAppearanceOptions, type ByteRangeResult, type ByteWriter, type CIDFontData, type CIDSystemInfoData, type CaretSymbol, type CatalogOptions, ChangeTracker, type CheckboxAppearanceOptions, type ChromaSubsampling, type CmykColor, type Color, type ColorStop, CombedTextLayoutError, type ComputeFontSizeOptions, type ContentStreamOperator, type CropBox, type DeduplicationReport, type Degrees, type DocumentMetadata, type DocumentStructure, type DownscaleOptions, type DrawCircleOptions, type DrawEllipseOptions, type DrawImageOptions, type DrawLineOptions, type DrawPageOptions, type DrawRectangleOptions, type DrawSquareOptions, type DrawSvgPathOptions, type DrawTextOptions, type DropdownAppearanceOptions, type EmbedFontOptions, type EmbedPageOptions, type EmbeddedFile, EmbeddedFont, type EmbeddedPdfPage, type EncryptAlgorithm, type EncryptDictValues, type EncryptOptions, EncryptedPdfError, ExceededMaxLengthError, FieldAlreadyExistsError, FieldExistsAsNonTerminalError, FieldFlags, type FieldType, type FileAttachmentIcon, type FontDescriptorData, type FontEmbeddingResult, type FontMetrics, FontNotEmbeddedError, type FontRef, ForeignPageError, type FreeTextAlignment, type GradientFill, type GrayscaleColor, ImageAlignment, type ImageDpi, type ImageInfo, type ImageOptimizeEntry, type ImageOptimizeOptions, type ImageRef, type IncrementalSaveResult, InitWasmOptions, InvalidFieldNamePartError, type JpegDecodeResult, type LayoutCombedOptions, type LayoutMultilineOptions, type LayoutMultilineResult, type LayoutSinglelineOptions, type LayoutSinglelineResult, LineCapStyle, type LineEndingStyle, LineJoinStyle, type LinearGradientOptions, type LinearizationOptions, type LinkHighlightMode, type ListboxAppearanceOptions, type LoadPdfOptions, type MarkedContentScope, MissingOnValueCheckError, NoSuchFieldError, type NormalizedStop, type Operand, type OptimizationReport, type OptimizeResult, type OutlineDestination, type OutlineItemOptions, PDFOperator, type PageEntry, type PageRange, type PageSize, PageSizes, ParseSpeeds, type PatternFill, type PdfAIssue, type PdfALevel, type PdfAValidationResult, PdfAnnotation, PdfArray, PdfBool, PdfButtonField, PdfCaretAnnotation, PdfCheckboxField, PdfCircleAnnotation, PdfDict, PdfDocument, PdfDropdownField, PdfEncryptionHandler, PdfField, PdfFileAttachmentAnnotation, PdfForm, PdfFreeTextAnnotation, PdfHighlightAnnotation, PdfInkAnnotation, PdfLayer, PdfLayerManager, PdfLineAnnotation, PdfLinkAnnotation, PdfListboxField, PdfName, PdfNull, PdfNumber, type PdfObject, PdfObjectRegistry, PdfOutlineItem, PdfOutlineTree, PdfPage, PdfParseError, type PdfPermissionFlags, PdfPolyLineAnnotation, PdfPolygonAnnotation, PdfPopupAnnotation, PdfRadioGroup, PdfRedactAnnotation, PdfRef, type PdfSaveOptions, PdfSignatureField, type PdfSignatureInfo, PdfSquareAnnotation, PdfSquigglyAnnotation, PdfStampAnnotation, PdfStream, PdfStreamWriter, PdfStrikeOutAnnotation, PdfString, PdfStructureElement, PdfStructureTree, PdfTextAnnotation, PdfTextField, PdfUnderlineAnnotation, PdfViewerPreferences, PdfWriter, type RadialGradientFill, type RadialGradientOptions, type Radians, type RadioAppearanceOptions, type RawImageData, type RecompressOptions, type RedactionMark, type RedactionOptions, type RefResolver, type RegistryEntry, RemovePageFromEmptyDocumentError, type RgbColor, RichTextFieldReadError, type SetTitleOptions, type SignOptions, type SignatureAppearanceOptions, type SignatureOptions, type SignatureVerificationResult, type SignerInfo, type SoftMaskBuilder, type SoftMaskRef, type StandardFontName, StandardFonts, type StandardStampName, type StructureElementOptions, type StructureType, type SubsetCmap, type SubsetResult, type SvgDrawCommand, type SvgElement, type SvgRenderOptions, TextAlignment, type TextAnnotationIcon, type TextAppearanceOptions, type TextExtractionOptions, type TextItem, TextRenderingMode, type TilingPatternOptions, type TimestampResult, type TransparencyGroupOptions, type Type0FontData, UnexpectedFieldTypeError, type ViewerPreferences, type VisibleSignatureOptions, type WatermarkOptions, type WidgetAnnotationHost, type WidthEntry, addWatermark, addWatermarkToPage, aesDecryptCBC, aesEncryptCBC, annotationFromDict, applyFillColor, applyRedactions, applyStrokeColor, asNumber, asPDFName, asPDFNumber, attachFile, base64Decode, base64Encode, beginArtifact, beginArtifactWithType, beginLayerContent, beginMarkedContent, beginMarkedContentSequence, beginMarkedContentWithProperties, beginText, buildAnnotationDict, buildCatalog, buildDocumentStructure, buildEmbeddedFilesNameTree, buildGradientObjects, buildInfoDict, buildPageTree, buildPatternObjects, buildPkcs7Signature, buildTimestampRequest, buildViewerPreferencesDict, buildXmpMetadata, checkAccessibility, circlePath, clipEvenOdd, clip as clipOp, closeAndStroke, closeFillAndStroke, closeFillEvenOddAndStroke, closePath as closePathOp, cmyk, colorToComponents, componentsToColor, computeFileEncryptionKey, computeFontSize, computeImageDpi, computeSignatureHash, computeTargetDimensions, concatMatrix, concatMatrix as concatTransformationMatrix, convertToGrayscale, copyPages, createAnnotation, createMarkedContentScope, createPdf, createXmpStream, cropPage, curveToFinal, curveToInitial, curveTo as curveToOp, decodeImageStream, decodeJpegWasm, decodePermissions, decodeStream, deduplicateImages, degrees, degreesToRadians, downscaleImage, drawImageWithMatrix, drawImageXObject, drawXObject as drawObject, drawXObject, drawSvgOnPage, ellipsePath, embedPageAsFormXObject, embedSignature, encodeContextTag, encodeInteger, encodeJpegWasm, encodeLength, encodeOID, encodeOctetString, encodePermissions, encodePrintableString, encodeSequence, encodeSet, encodeUTCTime, encodeUtf8String, endArtifact, endLayerContent, endMarkedContent, endPath as endPathOp, endText, enforcePdfA, estimateJpegQuality, extractImages, extractMetrics, extractText, extractTextWithPositions, fillAndStroke as fillAndStrokeOp, fillEvenOdd, fillEvenOddAndStroke, fill as fillOp, findSignatures, formatHexContext, formatPdfDate, generateButtonAppearance, generateCheckboxAppearance, generateCircleAppearance, generateDropdownAppearance, generateFreeTextAppearance, generateHighlightAppearance, generateInkAppearance, generateLineAppearance, generateListboxAppearance, generateRadioAppearance, generateSignatureAppearance, generateSquareAppearance, generateSquigglyAppearance, generateStrikeOutAppearance, generateTextAppearance, generateUnderlineAppearance, getAttachments, getPageSize, getRedactionMarks, getSignatures, grayscale, initJpegWasm, initWasm, insertPage, isAccessible, isGrayscaleImage, isJpegWasmReady, isLinearized, isOpenTypeCFF, isTrueType, layoutCombedText, layoutMultilineText, layoutSinglelineText, lineTo as lineToOp, linearGradient, linearizePdf, loadPdf, markForRedaction, md5, mergePdfs, movePage, moveText as moveTextOp, moveTextSetLeading, moveTo as moveToOp, nextLine as nextLineOp, optimizeAllImages, optimizeImage, parseContentStream, parseSvg, parseSvgColor, parseSvgPath, parseSvgTransform, parseTimestampResponse, parseViewerPreferences, parseXmpMetadata, restoreState as popGraphicsState, restoreState, prepareForSigning, saveState as pushGraphicsState, saveState, radialGradient, radians, radiansToDegrees, rc4, recompressImage, rectangle as rectangleOp, removePage, removePages, requestTimestamp, resizePage, reversePages, rgb, rotateAllPages, rotate as rotateOp, rotatePage, rotationMatrix, saveDocumentIncremental, saveIncremental, scale as scaleOp, serializePdf, setCharacterSpacing as setCharacterSpacingOp, setCharacterSpacing as setCharacterSqueeze, setColorSpace, setDashPattern as setDashPatternOp, setFillColor, setFillColorCmyk, setFillColorGray, setFillColorRgb, setFillingColor, setFlatness, setFont as setFontAndSize, setFont as setFontOp, setFontSize as setFontSizeOp, setGraphicsState as setGraphicsStateOp, setLeading as setLeadingOp, setLeading as setLineHeight, setLineCap as setLineCapOp, setLineJoin as setLineJoinOp, setLineWidth as setLineWidthOp, setMiterLimit, setStrokeColor, setStrokeColorCmyk, setStrokeColorGray, setStrokeColorRgb, setStrokeColorSpace, setStrokingColor, setTextMatrix as setTextMatrixOp, setTextRenderingMode as setTextRenderingModeOp, setTextRise as setTextRiseOp, setWordSpacing as setWordSpacingOp, sha256, sha384, sha512, showTextArray, showTextHex, showTextNextLine, showText as showTextOp, showTextWithSpacing, signPdf, skew as skewOp, splitPdf, stroke as strokeOp, summarizeIssues, svgToPdfOperators, tilingPattern, translate as translateOp, validatePdfA, verifyOwnerPassword, verifySignature, verifySignatures, verifyUserPassword, wrapInMarkedContent };
|
|
8275
9151
|
//# sourceMappingURL=index.d.mts.map
|