Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@embedpdf/models

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@embedpdf/models - npm Package Compare versions

Comparing version
1.0.11
to
1.0.12
+21
dist/color.d.ts
import { PdfAlphaColor } from './pdf';
export interface WebAlphaColor {
color: string;
opacity: number;
}
/**
* Convert a {@link PdfAlphaColor} to a CSS-style colour definition.
*
* @param c - the colour coming from PDFium (0-255 per channel)
* @returns
* hex – #RRGGBB (no alpha channel)
* opacity – 0-1 float suitable for CSS `opacity`/`rgba()`
*/
export declare function pdfAlphaColorToWebAlphaColor(c: PdfAlphaColor): WebAlphaColor;
/**
* Convert a CSS hex colour + opacity back into {@link PdfAlphaColor}
*
* @param hex - #RGB, #RRGGBB, or #rrggbb
* @param opacity - 0-1 float (values outside clamp automatically)
*/
export declare function webAlphaColorToPdfAlphaColor({ color, opacity }: WebAlphaColor): PdfAlphaColor;
/**
* Parse a PDF date string **D:YYYYMMDDHHmmSSOHH'mm'** to ISO-8601.
*
* Returns `undefined` if the input is malformed.
*
* @public
*/
export declare function pdfDateToDate(pdf?: string): Date | undefined;
/**
* Convert a date to a PDF date string
* @param date - date to convert
* @returns PDF date string
*
* @public
*/
export declare function dateToPdfDate(date?: Date): string;
/**
* Clockwise direction
* @public
*/
export declare enum Rotation {
Degree0 = 0,
Degree90 = 1,
Degree180 = 2,
Degree270 = 3
}
/** Clamp a Position to device-pixel integers (floor) */
export declare function toIntPos(p: Position): Position;
/** Clamp a Size so it never truncates right / bottom (ceil) */
export declare function toIntSize(s: Size): Size;
/** Apply both rules to a Rect */
export declare function toIntRect(r: Rect): Rect;
/**
* Calculate degree that match the rotation type
* @param rotation - type of rotation
* @returns rotated degree
*
* @public
*/
export declare function calculateDegree(rotation: Rotation): 0 | 90 | 180 | 270;
/**
* Calculate angle that match the rotation type
* @param rotation - type of rotation
* @returns rotated angle
*
* @public
*/
export declare function calculateAngle(rotation: Rotation): number;
/**
* Represent the size of object
*
* @public
*/
export interface Size {
/**
* width of the object
*/
width: number;
/**
* height of the object
*/
height: number;
}
/**
* Represents a rectangle defined by its left, top, right, and bottom edges
*
* @public
*/
export interface Box {
/**
* The x-coordinate of the left edge
*/
left: number;
/**
* The y-coordinate of the top edge
*/
top: number;
/**
* The x-coordinate of the right edge
*/
right: number;
/**
* The y-coordinate of the bottom edge
*/
bottom: number;
}
/**
* Swap the width and height of the size object
* @param size - the original size
* @returns swapped size
*
* @public
*/
export declare function swap(size: Size): Size;
/**
* Transform size with specified rotation angle and scale factor
* @param size - orignal size of rect
* @param rotation - rotation angle
* @param scaleFactor - - scale factor
* @returns size that has been transformed
*
* @public
*/
export declare function transformSize(size: Size, rotation: Rotation, scaleFactor: number): Size;
/**
* position of point
*
* @public
*/
export interface Position {
/**
* x coordinate
*/
x: number;
/**
* y coordinate
*/
y: number;
}
/**
* Quadrilateral
*
* @public
*/
export interface Quad {
p1: Position;
p2: Position;
p3: Position;
p4: Position;
}
/**
* Convert quadrilateral to rectangle
* @param q - quadrilateral
* @returns rectangle
*
* @public
*/
export declare function quadToRect(q: Quad): Rect;
/**
* Convert rectangle to quadrilateral
* @param r - rectangle
* @returns quadrilateral
*
* @public
*/
export declare function rectToQuad(r: Rect): Quad;
/**
* Rotate the container and calculate the new position for a point
* in specified position
* @param containerSize - size of the container
* @param position - position of the point
* @param rotation - rotated angle
* @returns new position of the point
*
* @public
*/
export declare function rotatePosition(containerSize: Size, position: Position, rotation: Rotation): Position;
/**
* Calculate the position of point by scaling the container
* @param position - position of the point
* @param scaleFactor - factor of scaling
* @returns new position of point
*
* @public
*/
export declare function scalePosition(position: Position, scaleFactor: number): Position;
/**
* Calculate the position of the point by applying the specified transformation
* @param containerSize - size of container
* @param position - position of the point
* @param rotation - rotated angle
* @param scaleFactor - factor of scaling
* @returns new position of point
*
* @public
*/
export declare function transformPosition(containerSize: Size, position: Position, rotation: Rotation, scaleFactor: number): Position;
/**
* Restore the position in a transformed cotainer
* @param containerSize - size of the container
* @param position - position of the point
* @param rotation - rotated angle
* @param scaleFactor - factor of scaling
* @returns the original position of the point
*
* @public
*/
export declare function restorePosition(containerSize: Size, position: Position, rotation: Rotation, scaleFactor: number): Position;
/**
* representation of rectangle
*
* @public
*/
export interface Rect {
/**
* origin of the rectangle
*/
origin: Position;
/**
* size of the rectangle
*/
size: Size;
}
/**
* Calculate the rect after rotated the container
* @param containerSize - size of container
* @param rect - target rect
* @param rotation - rotation angle
* @returns rotated rect
*
* @public
*/
export declare function rotateRect(containerSize: Size, rect: Rect, rotation: Rotation): Rect;
/**
* Scale the rectangle
* @param rect - rectangle
* @param scaleFactor - factor of scaling
* @returns new rectangle
*
* @public
*/
export declare function scaleRect(rect: Rect, scaleFactor: number): Rect;
/**
* Calculate new rectangle after transforming the container
* @param containerSize - size of the container
* @param rect - the target rectangle
* @param rotation - rotated angle
* @param scaleFactor - factor of scaling
* @returns new rectangle after transformation
*
* @public
*/
export declare function transformRect(containerSize: Size, rect: Rect, rotation: Rotation, scaleFactor: number): Rect;
/**
* Calculate new rectangle before transforming the container
* @param containerSize - size of the container
* @param rect - the target rectangle
* @param rotation - rotated angle
* @param scaleFactor - factor of scaling
* @returns original rectangle before transformation
*
* @public
*/
export declare function restoreRect(containerSize: Size, rect: Rect, rotation: Rotation, scaleFactor: number): Rect;
/**
* Calculate the original offset in a transformed container
* @param offset - position of the point
* @param rotation - rotated angle
* @param scaleFactor - factor of scaling
* @returns original position of the point
*
* @public
*/
export declare function restoreOffset(offset: Position, rotation: Rotation, scaleFactor: number): Position;
/**
* Return the smallest rectangle that encloses *all* `rects`.
* If the array is empty, returns `null`.
*
* @param rects - array of rectangles
* @returns smallest rectangle that encloses all the rectangles
*
* @public
*/
export declare function boundingRect(rects: Rect[]): Rect | null;
export interface Matrix {
a: number;
b: number;
c: number;
d: number;
e: number;
f: number;
}
/**
* Build a CTM that maps *PDF-space* inside the annotation
* → *device-space* inside the bitmap, honouring
* zoom (scaleFactor × dpr) **and** page-rotation.
*/
/** build the CTM for any page-rotation */
export declare const makeMatrix: (rectangle: Rect, rotation: Rotation, scaleFactor: number) => Matrix;
/**
* logger for logging
*
* @public
*/
export interface Logger {
/**
* Log debug message
* @param source - source of log
* @param category - category of log
* @param args - parameters of log
* @returns
*
* @public
*/
debug: (source: string, category: string, ...args: any) => void;
/**
* Log infor message
* @param source - source of log
* @param category - category of log
* @param args - parameters of log
* @returns
*
* @public
*/
info: (source: string, category: string, ...args: any) => void;
/**
* Log warning message
* @param source - source of log
* @param category - category of log
* @param args - parameters of log
* @returns
*
* @public
*/
warn: (source: string, category: string, ...args: any) => void;
/**
* Log error message
* @param source - source of log
* @param category - category of log
* @param args - parameters of log
* @returns
*
* @public
*/
error: (source: string, category: string, ...args: any) => void;
/**
* Log performance log
* @param source - source of log
* @param category - category of log
* @param event - event of log
* @param phase - event phase of log
* @param args - parameters of log
* @returns
*
* @public
*/
perf: (source: string, category: string, event: string, phase: 'Begin' | 'End', ...args: any) => void;
}
/**
* Logger that log nothing, it will ignore all the logs
*
* @public
*/
export declare class NoopLogger implements Logger {
/** {@inheritDoc Logger.debug} */
debug(): void;
/** {@inheritDoc Logger.info} */
info(): void;
/** {@inheritDoc Logger.warn} */
warn(): void;
/** {@inheritDoc Logger.error} */
error(): void;
/** {@inheritDoc Logger.perf} */
perf(): void;
}
/**
* Logger that use console as the output
*
* @public
*/
export declare class ConsoleLogger implements Logger {
/** {@inheritDoc Logger.debug} */
debug(source: string, category: string, ...args: any): void;
/** {@inheritDoc Logger.info} */
info(source: string, category: string, ...args: any): void;
/** {@inheritDoc Logger.warn} */
warn(source: string, category: string, ...args: any): void;
/** {@inheritDoc Logger.error} */
error(source: string, category: string, ...args: any): void;
/** {@inheritDoc Logger.perf} */
perf(source: string, category: string, event: string, phase: 'Begin' | 'End', ...args: any): void;
}
/**
* Level of log
*
* @public
*/
export declare enum LogLevel {
Debug = 0,
Info = 1,
Warn = 2,
Error = 3
}
/**
* Logger that support filtering by log level
*
* @public
*/
export declare class LevelLogger implements Logger {
private logger;
private level;
/**
* create new LevelLogger
* @param logger - the original logger
* @param level - log level that used for filtering, all logs lower than this level will be filtered out
*/
constructor(logger: Logger, level: LogLevel);
/** {@inheritDoc Logger.debug} */
debug(source: string, category: string, ...args: any): void;
/** {@inheritDoc Logger.info} */
info(source: string, category: string, ...args: any): void;
/** {@inheritDoc Logger.warn} */
warn(source: string, category: string, ...args: any): void;
/** {@inheritDoc Logger.error} */
error(source: string, category: string, ...args: any): void;
/** {@inheritDoc Logger.perf} */
perf(source: string, category: string, event: string, phase: 'Begin' | 'End', ...args: any): void;
}
/**
* Logger for performance tracking
*
* @public
*/
export declare class PerfLogger implements Logger {
/**
* create new PerfLogger
*/
constructor();
/** {@inheritDoc Logger.debug} */
debug(source: string, category: string, ...args: any): void;
/** {@inheritDoc Logger.info} */
info(source: string, category: string, ...args: any): void;
/** {@inheritDoc Logger.warn} */
warn(source: string, category: string, ...args: any): void;
/** {@inheritDoc Logger.error} */
error(source: string, category: string, ...args: any): void;
/** {@inheritDoc Logger.perf} */
perf(source: string, category: string, event: string, phase: 'Begin' | 'End', identifier: string, ...args: any): void;
}
/**
* Logger that will track and call child loggers
*
* @public
*/
export declare class AllLogger implements Logger {
private loggers;
/**
* create new PerfLogger
*/
constructor(loggers: Logger[]);
/** {@inheritDoc Logger.debug} */
debug(source: string, category: string, ...args: any): void;
/** {@inheritDoc Logger.info} */
info(source: string, category: string, ...args: any): void;
/** {@inheritDoc Logger.warn} */
warn(source: string, category: string, ...args: any): void;
/** {@inheritDoc Logger.error} */
error(source: string, category: string, ...args: any): void;
/** {@inheritDoc Logger.perf} */
perf(source: string, category: string, event: string, phase: 'Begin' | 'End', ...args: any): void;
}
import { WebAlphaColor } from './color';
import { Size, Rect, Position, Rotation } from './geometry';
import { Task, TaskError } from './task';
/**
* Representation of pdf page
*
* @public
*/
export interface PdfPageObject {
/**
* Index of this page, starts from 0
*/
index: number;
/**
* Orignal size of this page
*/
size: Size;
}
/**
* Representation of pdf page with rotated size
*
* @public
*/
export interface PdfPageObjectWithRotatedSize extends PdfPageObject {
/**
* Rotated size of this page
*/
rotatedSize: Size;
}
/**
* Representation of pdf document
*
* @public
*/
export interface PdfDocumentObject {
/**
* Identity of document
*/
id: string;
/**
* Count of pages in this document
*/
pageCount: number;
/**
* Pages in this document
*/
pages: PdfPageObject[];
}
/**
* metadata of pdf document
*
* @public
*/
export interface PdfMetadataObject {
/**
* title of the document
*/
title: string;
/**
* author of the document
*/
author: string;
/**
* subject of the document
*/
subject: string;
/**
* keywords of the document
*/
keywords: string;
/**
* producer of the document
*/
producer: string;
/**
* creator of the document
*/
creator: string;
/**
* creation date of the document
*/
creationDate: string;
/**
* modification date of the document
*/
modificationDate: string;
}
/**
* Unicode **soft-hyphen** marker (`U+00AD`).
* Often embedded by PDF generators as discretionary hyphens.
*
* @public
*/
export declare const PdfSoftHyphenMarker = "\u00AD";
/**
* Unicode **zero-width space** (`U+200B`).
*
* @public
*/
export declare const PdfZeroWidthSpace = "\u200B";
/**
* Unicode **word-joiner** (`U+2060`) – zero-width no-break.
*
* @public
*/
export declare const PdfWordJoiner = "\u2060";
/**
* Unicode **byte-order mark / zero-width no-break space** (`U+FEFF`).
*
* @public
*/
export declare const PdfBomOrZwnbsp = "\uFEFF";
/**
* Unicode non-character `U+FFFE`.
*
* @public
*/
export declare const PdfNonCharacterFFFE = "\uFFFE";
/**
* Unicode non-character `U+FFFF`.
*
* @public
*/
export declare const PdfNonCharacterFFFF = "\uFFFF";
/**
* **Frozen list** of all unwanted markers in canonical order.
*
* @public
*/
export declare const PdfUnwantedTextMarkers: readonly ["­", "​", "⁠", "", "￾", "￿"];
/**
* Compiled regular expression that matches any unwanted marker.
*
* @public
*/
export declare const PdfUnwantedTextRegex: RegExp;
/**
* Remove all {@link PdfUnwantedTextMarkers | unwanted markers} from *text*.
*
* @param text - raw text extracted from PDF
* @returns cleaned text
*
* @public
*/
export declare function stripPdfUnwantedMarkers(text: string): string;
/**
* zoom mode
*
* @public
*/
export declare enum PdfZoomMode {
Unknown = 0,
/**
* Zoom level with specified offset.
*/
XYZ = 1,
/**
* Fit both the width and height of the page (whichever smaller).
*/
FitPage = 2,
/**
* Fit the page width.
*/
FitHorizontal = 3,
/**
* Fit the page height.
*/
FitVertical = 4,
/**
* Fit a specific rectangle area within the window.
*/
FitRectangle = 5
}
/**
* Blend mode
*
* @public
*/
export declare enum PdfBlendMode {
Normal = 0,
Multiply = 1,
Screen = 2,
Overlay = 3,
Darken = 4,
Lighten = 5,
ColorDodge = 6,
ColorBurn = 7,
HardLight = 8,
SoftLight = 9,
Difference = 10,
Exclusion = 11,
Hue = 12,
Saturation = 13,
Color = 14,
Luminosity = 15
}
/** Extra UI sentinel for “multiple different values selected”. */
export declare const MixedBlendMode: unique symbol;
export type UiBlendModeValue = PdfBlendMode | typeof MixedBlendMode;
export type CssBlendMode = 'normal' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity';
interface BlendModeInfo {
/** Pdf enum value */
id: PdfBlendMode;
/** Human label for UI */
label: string;
/** CSS mix-blend-mode token */
css: CssBlendMode;
}
/** Get descriptor (falls back to Normal if unknown number sneaks in).
*
* @public
*/
export declare function getBlendModeInfo(mode: PdfBlendMode): BlendModeInfo;
/** Convert enum → CSS value for `mix-blend-mode`.
*
* @public
*/
export declare function blendModeToCss(mode: PdfBlendMode): CssBlendMode;
/** Convert CSS token → enum (returns undefined if not recognized).
*
* @public
*/
export declare function cssToBlendMode(value: CssBlendMode): PdfBlendMode | undefined;
/** Enum → UI label.
*
* @public
*/
export declare function blendModeLabel(mode: PdfBlendMode): string;
/**
* For a selection of annotations: returns the common enum value, or Mixed sentinel.
*
* @public
*/
export declare function reduceBlendModes(modes: readonly PdfBlendMode[]): UiBlendModeValue;
/** Options for a <select>.
*
* @public
*/
export declare const blendModeSelectOptions: {
value: PdfBlendMode;
label: string;
}[];
/** Provide a label when Mixed sentinel used (UI convenience).
*
* @public
*/
export declare function uiBlendModeDisplay(value: UiBlendModeValue): string;
/**
* Representation of the linked destination
*
* @public
*/
export interface PdfDestinationObject {
/**
* Index of target page
*/
pageIndex: number;
/**
* zoom config for target destination
*/
zoom: {
mode: PdfZoomMode.Unknown;
} | {
mode: PdfZoomMode.XYZ;
params: {
x: number;
y: number;
zoom: number;
};
} | {
mode: PdfZoomMode.FitPage;
} | {
mode: PdfZoomMode.FitHorizontal;
} | {
mode: PdfZoomMode.FitVertical;
} | {
mode: PdfZoomMode.FitRectangle;
};
view: number[];
}
/**
* Type of pdf action
*
* @public
*/
export declare enum PdfActionType {
Unsupported = 0,
/**
* Goto specified position in this document
*/
Goto = 1,
/**
* Goto specified position in another document
*/
RemoteGoto = 2,
/**
* Goto specified URI
*/
URI = 3,
/**
* Launch specifed application
*/
LaunchAppOrOpenFile = 4
}
export type PdfImage = {
data: Uint8ClampedArray;
width: number;
height: number;
};
/**
* Representation of pdf action
*
* @public
*/
export type PdfActionObject = {
type: PdfActionType.Unsupported;
} | {
type: PdfActionType.Goto;
destination: PdfDestinationObject;
} | {
type: PdfActionType.RemoteGoto;
destination: PdfDestinationObject;
} | {
type: PdfActionType.URI;
uri: string;
} | {
type: PdfActionType.LaunchAppOrOpenFile;
path: string;
};
/**
* target of pdf link
*
* @public
*/
export type PdfLinkTarget = {
type: 'action';
action: PdfActionObject;
} | {
type: 'destination';
destination: PdfDestinationObject;
};
/**
* PDF bookmark
*
* @public
*/
export interface PdfBookmarkObject {
/**
* title of bookmark
*/
title: string;
/**
* target of bookmark
*/
target?: PdfLinkTarget | undefined;
/**
* bookmarks in the next level
*/
children?: PdfBookmarkObject[];
}
/**
* Pdf Signature
*
* @public
*/
export interface PdfSignatureObject {
/**
* contents of signature
*/
contents: ArrayBuffer;
/**
* byte range of signature
*/
byteRange: ArrayBuffer;
/**
* sub filters of signature
*/
subFilter: ArrayBuffer;
/**
* reason of signature
*/
reason: string;
/**
* creation time of signature
*/
time: string;
/**
* MDP
*/
docMDP: number;
}
/**
* Bookmark tree of pdf
*
* @public
*/
export interface PdfBookmarksObject {
bookmarks: PdfBookmarkObject[];
}
/**
* Text rectangle in pdf page
*
* @public
*/
export interface PdfTextRectObject {
/**
* Font of the text
*/
font: {
/**
* font family
*/
family: string;
/**
* font size
*/
size: number;
};
/**
* content in this rectangle area
*/
content: string;
/**
* rectangle of the text
*/
rect: Rect;
}
/**
* Color
*
* @public
*/
export interface PdfAlphaColor {
/**
* red
*/
red: number;
/**
* green
*/
green: number;
/**
* blue
*/
blue: number;
/**
* alpha
*/
alpha: number;
}
/**
* Annotation type
*
* @public
*/
export declare enum PdfAnnotationSubtype {
UNKNOWN = 0,
TEXT = 1,
LINK = 2,
FREETEXT = 3,
LINE = 4,
SQUARE = 5,
CIRCLE = 6,
POLYGON = 7,
POLYLINE = 8,
HIGHLIGHT = 9,
UNDERLINE = 10,
SQUIGGLY = 11,
STRIKEOUT = 12,
STAMP = 13,
CARET = 14,
INK = 15,
POPUP = 16,
FILEATTACHMENT = 17,
SOUND = 18,
MOVIE = 19,
WIDGET = 20,
SCREEN = 21,
PRINTERMARK = 22,
TRAPNET = 23,
WATERMARK = 24,
THREED = 25,
RICHMEDIA = 26,
XFAWIDGET = 27,
REDACT = 28
}
/**
* Name of annotation type
*
* @public
*/
export declare const PdfAnnotationSubtypeName: Record<PdfAnnotationSubtype, string>;
/**
* Status of pdf annotation
*
* @public
*/
export declare enum PdfAnnotationObjectStatus {
/**
* Annotation is created
*/
Created = 0,
/**
* Annotation is committed to PDF file
*/
Committed = 1
}
/**
* Appearance mode
*
* @public
*/
export declare enum AppearanceMode {
Normal = 0,
Rollover = 1,
Down = 2
}
/**
* State of pdf annotation
*
* @public
*/
export declare enum PdfAnnotationState {
/**
* Annotation is active
*/
Marked = "Marked",
/**
* Annotation is unmarked
*/
Unmarked = "Unmarked",
/**
* Annotation is ink
*/
Accepted = "Accepted",
/**
* Annotation is rejected
*/
Rejected = "Rejected",
/**
* Annotation is complete
*/
Complete = "Complete",
/**
* Annotation is cancelled
*/
Cancelled = "Cancelled",
/**
* Annotation is none
*/
None = "None"
}
/**
* State model of pdf annotation
*
* @public
*/
export declare enum PdfAnnotationStateModel {
/**
* Annotation is marked
*/
Marked = "Marked",
/**
* Annotation is reviewed
*/
Reviewed = "Reviewed"
}
/**
* Basic information of pdf annotation
*
* @public
*/
export interface PdfAnnotationObjectBase {
/**
* Author of the annotation
*/
author?: string;
/**
* Modified date of the annotation
*/
modified?: Date;
/**
* blend mode of annotation
*/
blendMode?: PdfBlendMode;
/**
* intent of annotation
*/
intent?: string;
/**
* Sub type of annotation
*/
type: PdfAnnotationSubtype;
/**
* The index of page that this annotation belong to
*/
pageIndex: number;
/**
* id of the annotation
*/
id: number;
/**
* Rectangle of the annotation
*/
rect: Rect;
}
/**
* Popup annotation
*
* @public
*/
export interface PdfPopupAnnoObject extends PdfAnnotationObjectBase {
/** {@inheritDoc PdfAnnotationObjectBase.type} */
type: PdfAnnotationSubtype.POPUP;
/**
* Contents of the popup
*/
contents: string;
/**
* Whether the popup is opened or not
*/
open: boolean;
/**
* In reply to id
*/
inReplyToId?: number;
}
/**
* Pdf Link annotation
*
* @public
*/
export interface PdfLinkAnnoObject extends PdfAnnotationObjectBase {
/** {@inheritDoc PdfAnnotationObjectBase.type} */
type: PdfAnnotationSubtype.LINK;
/**
* Text of the link
*/
text: string;
/**
* target of the link
*/
target: PdfLinkTarget | undefined;
}
/**
* Pdf Text annotation
*
* @public
*/
export interface PdfTextAnnoObject extends PdfAnnotationObjectBase {
/** {@inheritDoc PdfAnnotationObjectBase.type} */
type: PdfAnnotationSubtype.TEXT;
/**
* Text contents of the annotation
*/
contents: string;
/**
* color of text annotation
*/
color?: string;
/**
* opacity of text annotation
*/
opacity?: number;
/**
* In reply to id
*/
inReplyToId?: number;
/**
* State of the text annotation
*/
state?: PdfAnnotationState;
/**
* State model of the text annotation
*/
stateModel?: PdfAnnotationStateModel;
}
/**
* Type of form field
*
* @public
*/
export declare enum PDF_FORM_FIELD_TYPE {
/**
* Unknow
*/
UNKNOWN = 0,
/**
* push button type
*/
PUSHBUTTON = 1,
/**
* check box type.
*/
CHECKBOX = 2,
/**
* radio button type.
*/
RADIOBUTTON = 3,
/**
* combo box type.
*/
COMBOBOX = 4,
/**
* list box type.
*/
LISTBOX = 5,
/**
* text field type
*/
TEXTFIELD = 6,
/**
* signature field type.
*/
SIGNATURE = 7,
/**
* Generic XFA type.
*/
XFA = 8,
/**
* XFA check box type.
*/
XFA_CHECKBOX = 9,
/**
* XFA combo box type.
*/
XFA_COMBOBOX = 10,
/**
* XFA image field type.
*/
XFA_IMAGEFIELD = 11,
/**
* XFA list box type.
*/
XFA_LISTBOX = 12,
/**
* XFA push button type.
*/
XFA_PUSHBUTTON = 13,
/**
* XFA signture field type.
*/
XFA_SIGNATURE = 14,
/**
* XFA text field type.
*/
XFA_TEXTFIELD = 15
}
export declare enum PdfAnnotationColorType {
Color = 0,
InteriorColor = 1
}
/**
* Border style of pdf annotation
*
* @public
*/
export declare enum PdfAnnotationBorderStyle {
UNKNOWN = 0,
SOLID = 1,
DASHED = 2,
BEVELED = 3,
INSET = 4,
UNDERLINE = 5,
CLOUDY = 6
}
/**
* Flag of pdf annotation
*
* @public
*/
export declare enum PdfAnnotationFlags {
NONE = 0,
INVISIBLE = 1,
HIDDEN = 2,
PRINT = 4,
NO_ZOOM = 8,
NO_ROTATE = 16,
NO_VIEW = 32,
READ_ONLY = 64,
LOCKED = 128,
TOGGLE_NOVIEW = 256
}
/**
* Flag of form field
*
* @public
*/
export declare enum PDF_FORM_FIELD_FLAG {
NONE = 0,
READONLY = 1,
REQUIRED = 2,
NOEXPORT = 4,
TEXT_MULTIPLINE = 4096,
TEXT_PASSWORD = 8192,
CHOICE_COMBO = 131072,
CHOICE_EDIT = 262144,
CHOICE_MULTL_SELECT = 2097152
}
/**
* Type of pdf object
*
* @public
*/
export declare enum PdfPageObjectType {
UNKNOWN = 0,
TEXT = 1,
PATH = 2,
IMAGE = 3,
SHADING = 4,
FORM = 5
}
/**
* Options of pdf widget annotation
*
* @public
*/
export interface PdfWidgetAnnoOption {
label: string;
isSelected: boolean;
}
export type PdfAnnotationFlagName = 'invisible' | 'hidden' | 'print' | 'noZoom' | 'noRotate' | 'noView' | 'readOnly' | 'locked' | 'toggleNoView';
type FlagMap = Partial<Record<Exclude<PdfAnnotationFlags, PdfAnnotationFlags.NONE>, PdfAnnotationFlagName>>;
export declare const PdfAnnotationFlagName: Readonly<FlagMap>;
/**
* Convert the raw bit-mask coming from `FPDFAnnot_GetFlags()` into
* an array of human-readable flag names (“invisible”, “print”…).
*/
export declare function flagsToNames(raw: number): PdfAnnotationFlagName[];
/**
* Convert an array of flag-names back into the numeric mask that
* PDFium expects for `FPDFAnnot_SetFlags()`.
*/
export declare function namesToFlags(names: readonly PdfAnnotationFlagName[]): PdfAnnotationFlags;
/**
* Field of PDF widget annotation
*
* @public
*/
export interface PdfWidgetAnnoField {
/**
* flag of field
*/
flag: PDF_FORM_FIELD_FLAG;
/**
* name of field
*/
name: string;
/**
* alternate name of field
*/
alternateName: string;
/**
* type of field
*/
type: PDF_FORM_FIELD_TYPE;
/**
* value of field
*/
value: string;
/**
* whether field is checked
*/
isChecked: boolean;
/**
* options of field
*/
options: PdfWidgetAnnoOption[];
}
/**
* PDF widget object
*
* @public
*/
export interface PdfWidgetAnnoObject extends PdfAnnotationObjectBase {
/** {@inheritDoc PdfAnnotationObjectBase.type} */
type: PdfAnnotationSubtype.WIDGET;
/**
* Field of pdf widget object
*/
field: PdfWidgetAnnoField;
}
/**
* Pdf file attachments annotation
*
* @public
*/
export interface PdfFileAttachmentAnnoObject extends PdfAnnotationObjectBase {
/** {@inheritDoc PdfAnnotationObjectBase.type} */
type: PdfAnnotationSubtype.FILEATTACHMENT;
}
/**
* ink list in pdf ink annotation
*
* @public
*/
export interface PdfInkListObject {
points: Position[];
}
/**
* Pdf ink annotation
*
* @public
*/
export interface PdfInkAnnoObject extends PdfAnnotationObjectBase {
/** {@inheritDoc PdfAnnotationObjectBase.type} */
type: PdfAnnotationSubtype.INK;
/**
* ink list of annotation
*/
inkList: PdfInkListObject[];
/**
* color of ink annotation
*/
color: string;
/**
* opacity of ink annotation
*/
opacity: number;
/**
* stroke-width of ink annotation
*/
strokeWidth: number;
}
/**
* Pdf polygon annotation
*
* @public
*/
export interface PdfPolygonAnnoObject extends PdfAnnotationObjectBase {
/** {@inheritDoc PdfAnnotationObjectBase.type} */
type: PdfAnnotationSubtype.POLYGON;
/**
* vertices of annotation
*/
vertices: Position[];
}
/**
* PDF polyline annotation
*
* @public
*/
export interface PdfPolylineAnnoObject extends PdfAnnotationObjectBase {
/** {@inheritDoc PdfAnnotationObjectBase.type} */
type: PdfAnnotationSubtype.POLYLINE;
/**
* vertices of annotation
*/
vertices: Position[];
}
/**
* PDF line annotation
*
* @public
*/
export interface PdfLineAnnoObject extends PdfAnnotationObjectBase {
/** {@inheritDoc PdfAnnotationObjectBase.type} */
type: PdfAnnotationSubtype.LINE;
/**
* start point of line
*/
startPoint: Position;
/**
* end point of line
*/
endPoint: Position;
}
/**
* PDF highlight annotation
*
* @public
*/
export interface PdfHighlightAnnoObject extends PdfAnnotationObjectBase {
/** {@inheritDoc PdfAnnotationObjectBase.type} */
type: PdfAnnotationSubtype.HIGHLIGHT;
/**
* Text contents of the highlight annotation
*/
contents?: string;
/**
* color of highlight annotation
*/
color: string;
/**
* opacity of highlight annotation
*/
opacity: number;
/**
* quads of highlight area
*/
segmentRects: Rect[];
}
/**
* Matrix for transformation, in the form [a b c d e f], equivalent to:
* | a b 0 |
* | c d 0 |
* | e f 1 |
*
* Translation is performed with [1 0 0 1 tx ty].
* Scaling is performed with [sx 0 0 sy 0 0].
* See PDF Reference 1.7, 4.2.2 Common Transformations for more.
*/
export interface PdfTransformMatrix {
a: number;
b: number;
c: number;
d: number;
e: number;
f: number;
}
/**
* type of segment type in pdf path object
*
* @public
*/
export declare enum PdfSegmentObjectType {
UNKNOWN = -1,
LINETO = 0,
BEZIERTO = 1,
MOVETO = 2
}
/**
* segment of path object
*
* @public
*/
export interface PdfSegmentObject {
type: PdfSegmentObjectType;
/**
* point of the segment
*/
point: Position;
/**
* whether this segment close the path
*/
isClosed: boolean;
}
/**
* Pdf path object
*
* @public
*/
export interface PdfPathObject {
type: PdfPageObjectType.PATH;
/**
* bound that contains the path
*/
bounds: {
left: number;
bottom: number;
right: number;
top: number;
};
/**
* segments of the path
*/
segments: PdfSegmentObject[];
/**
* transform matrix
*/
matrix: PdfTransformMatrix;
}
/**
* Pdf image object
*
* @public
*/
export interface PdfImageObject {
type: PdfPageObjectType.IMAGE;
/**
* data of the image
*/
imageData: ImageData;
/**
* transform matrix
*/
matrix: PdfTransformMatrix;
}
/**
* Pdf form object
*
* @public
*/
export interface PdfFormObject {
type: PdfPageObjectType.FORM;
/**
* objects that in this form object
*/
objects: (PdfImageObject | PdfPathObject | PdfFormObject)[];
/**
* transform matrix
*/
matrix: PdfTransformMatrix;
}
/**
* Contents type of pdf stamp annotation
*
* @public
*/
export type PdfStampAnnoObjectContents = Array<PdfPathObject | PdfImageObject | PdfFormObject>;
/**
* Pdf stamp annotation
*
* @public
*/
export interface PdfStampAnnoObject extends PdfAnnotationObjectBase {
/** {@inheritDoc PdfAnnotationObjectBase.type} */
type: PdfAnnotationSubtype.STAMP;
/**
* contents in this stamp annotation
*/
contents: PdfStampAnnoObjectContents;
}
/**
* Pdf circle annotation
*
* @public
*/
export interface PdfCircleAnnoObject extends PdfAnnotationObjectBase {
/** {@inheritDoc PdfAnnotationObjectBase.type} */
type: PdfAnnotationSubtype.CIRCLE;
/**
* flags of circle annotation
*/
flags: PdfAnnotationFlagName[];
/**
* color of circle annotation
*/
color: string;
/**
* opacity of circle annotation
*/
opacity: number;
/**
* stroke-width of circle annotation
*/
strokeWidth: number;
/**
* stroke color of circle annotation
*/
strokeColor: string;
/**
* stroke style of circle annotation
*/
strokeStyle: PdfAnnotationBorderStyle;
/**
* stroke dash array of circle annotation
*/
strokeDashArray?: number[];
/**
* cloudy border intensity of circle annotation
*/
cloudyBorderIntensity?: number;
/**
* cloudy border inset of circle annotation
*/
cloudyBorderInset?: number[];
}
/**
* Pdf square annotation
*
* @public
*/
export interface PdfSquareAnnoObject extends PdfAnnotationObjectBase {
/** {@inheritDoc PdfAnnotationObjectBase.type} */
type: PdfAnnotationSubtype.SQUARE;
/**
* flags of square annotation
*/
flags: PdfAnnotationFlagName[];
/**
* color of square annotation
*/
color: string;
/**
* opacity of square annotation
*/
opacity: number;
/**
* stroke-width of square annotation
*/
strokeWidth: number;
/**
* stroke color of square annotation
*/
strokeColor: string;
/**
* stroke style of square annotation
*/
strokeStyle: PdfAnnotationBorderStyle;
/**
* stroke dash array of square annotation
*/
strokeDashArray?: number[];
/**
* cloudy border intensity of circle annotation
*/
cloudyBorderIntensity?: number;
/**
* cloudy border inset of circle annotation
*/
cloudyBorderInset?: number[];
}
/**
* Pdf squiggly annotation
*
* @public
*/
export interface PdfSquigglyAnnoObject extends PdfAnnotationObjectBase {
/** {@inheritDoc PdfAnnotationObjectBase.type} */
type: PdfAnnotationSubtype.SQUIGGLY;
/**
* Text contents of the highlight annotation
*/
contents?: string;
/**
* color of strike out annotation
*/
color: string;
/**
* opacity of strike out annotation
*/
opacity: number;
/**
* quads of highlight area
*/
segmentRects: Rect[];
}
/**
* Pdf underline annotation
*
* @public
*/
export interface PdfUnderlineAnnoObject extends PdfAnnotationObjectBase {
/** {@inheritDoc PdfAnnotationObjectBase.type} */
type: PdfAnnotationSubtype.UNDERLINE;
/**
* Text contents of the highlight annotation
*/
contents?: string;
/**
* color of strike out annotation
*/
color: string;
/**
* opacity of strike out annotation
*/
opacity: number;
/**
* quads of highlight area
*/
segmentRects: Rect[];
}
/**
* Pdf strike out annotation
*
* @public
*/
export interface PdfStrikeOutAnnoObject extends PdfAnnotationObjectBase {
/** {@inheritDoc PdfAnnotationObjectBase.type} */
type: PdfAnnotationSubtype.STRIKEOUT;
/**
* Text contents of the strike out annotation
*/
contents?: string;
/**
* color of strike out annotation
*/
color: string;
/**
* opacity of strike out annotation
*/
opacity: number;
/**
* quads of highlight area
*/
segmentRects: Rect[];
}
/**
* Pdf caret annotation
*
* @public
*/
export interface PdfCaretAnnoObject extends PdfAnnotationObjectBase {
/** {@inheritDoc PdfAnnotationObjectBase.type} */
type: PdfAnnotationSubtype.CARET;
}
/**
* Pdf free text annotation
*
* @public
*/
export interface PdfFreeTextAnnoObject extends PdfAnnotationObjectBase {
/** {@inheritDoc PdfAnnotationObjectBase.type} */
type: PdfAnnotationSubtype.FREETEXT;
contents: string;
richContent?: string;
}
/**
* All annotation that support
*
* @public
*/
export type PdfSupportedAnnoObject = PdfInkAnnoObject | PdfTextAnnoObject | PdfLinkAnnoObject | PdfPolygonAnnoObject | PdfPolylineAnnoObject | PdfHighlightAnnoObject | PdfLineAnnoObject | PdfWidgetAnnoObject | PdfFileAttachmentAnnoObject | PdfStampAnnoObject | PdfSquareAnnoObject | PdfCircleAnnoObject | PdfSquigglyAnnoObject | PdfUnderlineAnnoObject | PdfStrikeOutAnnoObject | PdfCaretAnnoObject | PdfFreeTextAnnoObject;
/**
* Pdf annotation that does not support
*
* @public
*/
export interface PdfUnsupportedAnnoObject extends PdfAnnotationObjectBase {
type: Exclude<PdfAnnotationSubtype, PdfSupportedAnnoObject['type']>;
}
/**
* all annotations
*
* @public
*/
export type PdfAnnotationObject = PdfSupportedAnnoObject | PdfUnsupportedAnnoObject;
/**
* Pdf attachment
*
* @public
*/
export interface PdfAttachmentObject {
index: number;
name: string;
creationDate: string;
checksum: string;
}
/**
* Pdf engine features
*
* @public
*/
export declare enum PdfEngineFeature {
RenderPage = 0,
RenderPageRect = 1,
Thumbnails = 2,
Bookmarks = 3,
Annotations = 4
}
/**
* All operations for this engine
*
* @public
*/
export declare enum PdfEngineOperation {
Create = 0,
Read = 1,
Update = 2,
Delete = 3
}
/**
* flags to match the text during searching
*
* @public
*/
export declare enum MatchFlag {
None = 0,
MatchCase = 1,
MatchWholeWord = 2,
MatchConsecutive = 4
}
/**
* Union all the flags
* @param flags - all the flags
* @returns union of flags
*
* @public
*/
export declare function unionFlags(flags: MatchFlag[]): MatchFlag;
/**
* Image conversion types
*
* @public
*/
export type ImageConversionTypes = 'image/webp' | 'image/png' | 'image/jpeg';
/**
* Targe for searching
*
* @public
*/
export interface SearchTarget {
keyword: string;
flags: MatchFlag[];
}
/**
* compare 2 search target
* @param targetA - first target for search
* @param targetB - second target for search
* @returns whether 2 search target are the same
*
* @public
*/
export declare function compareSearchTarget(targetA: SearchTarget, targetB: SearchTarget): boolean;
/** Context of one hit */
export interface TextContext {
/** Complete words that come *before* the hit (no ellipsis) */
before: string;
/** Exactly the text that matched (case-preserved) */
match: string;
/** Complete words that come *after* the hit (no ellipsis) */
after: string;
/** `true` ⇢ there were more words on the left that we cut off */
truncatedLeft: boolean;
/** `true` ⇢ there were more words on the right that we cut off */
truncatedRight: boolean;
}
/**
* Text slice
*
* @public
*/
export interface PageTextSlice {
/**
* Index of the pdf page
*/
pageIndex: number;
/**
* Index of the first character
*/
charIndex: number;
/**
* Count of the characters
*/
charCount: number;
}
/**
* search result
*
* @public
*/
export interface SearchResult {
/**
* Index of the pdf page
*/
pageIndex: number;
/**
* index of the first character
*/
charIndex: number;
/**
* count of the characters
*/
charCount: number;
/**
* highlight rects
*/
rects: Rect[];
/**
* context of the hit
*/
context: TextContext;
}
/**
* Results of searching through the entire document
*/
export interface SearchAllPagesResult {
/**
* Array of all search results across all pages
*/
results: SearchResult[];
/**
* Total number of results found
*/
total: number;
}
/**
* Glyph object
*
* @public
*/
export interface PdfGlyphObject {
/**
* Origin of the glyph
*/
origin: {
x: number;
y: number;
};
/**
* Size of the glyph
*/
size: {
width: number;
height: number;
};
/**
* Whether the glyph is a space
*/
isSpace?: boolean;
/**
* Whether the glyph is a empty
*/
isEmpty?: boolean;
}
/**
* Glyph object
*
* @public
*/
export interface PdfGlyphSlim {
/**
* X coordinate of the glyph
*/
x: number;
/**
* Y coordinate of the glyph
*/
y: number;
/**
* Width of the glyph
*/
width: number;
/**
* Height of the glyph
*/
height: number;
/**
* Flags of the glyph
*/
flags: number;
}
/**
* Run object
*
* @public
*/
export interface PdfRun {
/**
* Rectangle of the run
*/
rect: {
x: number;
y: number;
width: number;
height: number;
};
/**
* Start index of the run
*/
charStart: number;
/**
* Glyphs of the run
*/
glyphs: PdfGlyphSlim[];
}
/**
* Page geometry
*
* @public
*/
export interface PdfPageGeometry {
/**
* Runs of the page
*/
runs: PdfRun[];
}
/**
* form field value
* @public
*/
export type FormFieldValue = {
kind: 'text';
text: string;
} | {
kind: 'selection';
index: number;
isSelected: boolean;
} | {
kind: 'checked';
isChecked: boolean;
};
/**
* Transformation that will be applied to annotation
*
* @public
*/
export interface PdfAnnotationTransformation {
/**
* Translated offset
*/
offset: Position;
/**
* Scaled factors
*/
scale: Size;
}
/**
* Render options
*
* @public
*/
export interface PdfRenderOptions {
/**
* Whether needs to render the page with annotations
*/
withAnnotations: boolean;
}
/**
* source can be byte array contains pdf content
*
* @public
*/
export type PdfFileContent = ArrayBuffer;
export declare enum PdfPermission {
PrintDocument = 8,
ModifyContent = 16,
CopyOrExtract = 32,
AddOrModifyTextAnnot = 64,
FillInExistingForm = 512,
ExtractTextOrGraphics = 1024,
AssembleDocument = 2048,
PrintHighQuality = 4096
}
export declare enum PdfPageFlattenFlag {
Display = 0,
Print = 1
}
export declare enum PdfPageFlattenResult {
Fail = 0,
Success = 1,
NothingToDo = 2
}
/**
* Pdf File without content
*
* @public
*/
export interface PdfFileWithoutContent {
/**
* id of file
*/
id: string;
}
export interface PdfFileLoader extends PdfFileWithoutContent {
/**
* length of file
*/
fileLength: number;
/**
* read block of file
* @param offset - offset of file
* @param length - length of file
* @returns block of file
*/
callback: (offset: number, length: number) => Uint8Array;
}
/**
* Pdf File
*
* @public
*/
export interface PdfFile extends PdfFileWithoutContent {
/**
* content of file
*/
content: PdfFileContent;
}
export interface PdfFileUrl extends PdfFileWithoutContent {
url: string;
}
export interface PdfUrlOptions {
mode?: 'auto' | 'range-request' | 'full-fetch';
password?: string;
}
export declare enum PdfErrorCode {
Ok = 0,// #define FPDF_ERR_SUCCESS 0 // No error.
Unknown = 1,// #define FPDF_ERR_UNKNOWN 1 // Unknown error.
NotFound = 2,// #define FPDF_ERR_FILE 2 // File not found or could not be opened.
WrongFormat = 3,// #define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted.
Password = 4,// #define FPDF_ERR_PASSWORD 4 // Password required or incorrect password.
Security = 5,// #define FPDF_ERR_SECURITY 5 // Unsupported security scheme.
PageError = 6,// #define FPDF_ERR_PAGE 6 // Page not found or content error.
XFALoad = 7,// #ifdef PDF_ENABLE_XFA
XFALayout = 8,//
Cancelled = 9,
Initialization = 10,
NotReady = 11,
NotSupport = 12,
LoadDoc = 13,
DocNotOpen = 14,
CantCloseDoc = 15,
CantCreateNewDoc = 16,
CantImportPages = 17,
CantCreateAnnot = 18,
CantSetAnnotRect = 19,
CantSetAnnotContent = 20,
CantRemoveInkList = 21,
CantAddInkStoke = 22,
CantReadAttachmentSize = 23,
CantReadAttachmentContent = 24,
CantFocusAnnot = 25,
CantSelectText = 26,
CantSelectOption = 27,
CantCheckField = 28
}
export interface PdfErrorReason {
code: PdfErrorCode;
message: string;
}
export type PdfEngineError = TaskError<PdfErrorReason>;
export type PdfTask<R> = Task<R, PdfErrorReason>;
export declare class PdfTaskHelper {
/**
* Create a task
* @returns new task
*/
static create<R>(): Task<R, PdfErrorReason>;
/**
* Create a task that has been resolved with value
* @param result - resolved value
* @returns resolved task
*/
static resolve<R>(result: R): Task<R, PdfErrorReason>;
/**
* Create a task that has been rejected with error
* @param reason - rejected error
* @returns rejected task
*/
static reject<T = any>(reason: PdfErrorReason): Task<T, PdfErrorReason>;
/**
* Create a task that has been aborted with error
* @param reason - aborted error
* @returns aborted task
*/
static abort<T = any>(reason: PdfErrorReason): Task<T, PdfErrorReason>;
}
/**
* Pdf engine
*
* @public
*/
export interface PdfEngine<T = Blob> {
/**
* Check whether pdf engine supports this feature
* @param feature - which feature want to check
* @returns support or not
*/
isSupport?: (feature: PdfEngineFeature) => PdfTask<PdfEngineOperation[]>;
/**
* Initialize the engine
* @returns task that indicate whether initialization is successful
*/
initialize?: () => PdfTask<boolean>;
/**
* Destroy the engine
* @returns task that indicate whether destroy is successful
*/
destroy?: () => PdfTask<boolean>;
/**
* Open a PDF from a URL with specified mode
* @param url - The PDF file URL
* @param options - Additional options including mode (auto, range-request, full-fetch) and password
* @returns Task that resolves with the PdfDocumentObject or an error
*/
openDocumentUrl: (file: PdfFileUrl, options?: PdfUrlOptions) => PdfTask<PdfDocumentObject>;
/**
* Open pdf document from buffer
* @param file - pdf file
* @param password - protected password for this file
* @returns task that contains the file or error
*/
openDocumentFromBuffer: (file: PdfFile, password: string) => PdfTask<PdfDocumentObject>;
/**
* Open pdf document from loader
* @param file - pdf file
* @param password - protected password for this file
* @returns task that contains the file or error
*/
openDocumentFromLoader: (file: PdfFileLoader, password: string) => PdfTask<PdfDocumentObject>;
/**
* Get the metadata of the file
* @param doc - pdf document
* @returns task that contains the metadata or error
*/
getMetadata: (doc: PdfDocumentObject) => PdfTask<PdfMetadataObject>;
/**
* Get permissions of the file
* @param doc - pdf document
* @returns task that contains a 32-bit integer indicating permission flags
*/
getDocPermissions: (doc: PdfDocumentObject) => PdfTask<number>;
/**
* Get the user permissions of the file
* @param doc - pdf document
* @returns task that contains a 32-bit integer indicating permission flags
*/
getDocUserPermissions: (doc: PdfDocumentObject) => PdfTask<number>;
/**
* Get the signatures of the file
* @param doc - pdf document
* @returns task that contains the signatures or error
*/
getSignatures: (doc: PdfDocumentObject) => PdfTask<PdfSignatureObject[]>;
/**
* Get the bookmarks of the file
* @param doc - pdf document
* @returns task that contains the bookmarks or error
*/
getBookmarks: (doc: PdfDocumentObject) => PdfTask<PdfBookmarksObject>;
/**
* Render the specified pdf page
* @param doc - pdf document
* @param page - pdf page
* @param scaleFactor - factor of scaling
* @param rotation - rotated angle
* @param dpr - devicePixelRatio
* @param options - render options
* @returns task contains the rendered image or error
*/
renderPage: (doc: PdfDocumentObject, page: PdfPageObject, scaleFactor: number, rotation: Rotation, dpr: number, options: PdfRenderOptions, imageType?: ImageConversionTypes) => PdfTask<T>;
/**
* Render the specified rect of pdf page
* @param doc - pdf document
* @param page - pdf page
* @param scaleFactor - factor of scaling
* @param rotation - rotated angle
* @param dpr - devicePixelRatio
* @param rect - target rect
* @param options - render options
* @returns task contains the rendered image or error
*/
renderPageRect: (doc: PdfDocumentObject, page: PdfPageObject, scaleFactor: number, rotation: Rotation, dpr: number, rect: Rect, options: PdfRenderOptions, imageType?: ImageConversionTypes) => PdfTask<T>;
/**
* Render a single annotation into an ImageData blob.
*
* Note: • honours Display-Matrix, page rotation & DPR
* • you decide whether to include the page background
* @param doc - pdf document
* @param page - pdf page
* @param annotation - the annotation to render
* @param scaleFactor - factor of scaling
* @param rotation - rotated angle
* @param dpr - devicePixelRatio
* @param mode - appearance mode
*/
renderAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject, scaleFactor: number, rotation: Rotation, dpr: number, mode: AppearanceMode, imageType: ImageConversionTypes): PdfTask<T>;
/**
* Get annotations of pdf page
* @param doc - pdf document
* @param page - pdf page
* @param scaleFactor - factor of scaling
* @param rotation - rotated angle
* @returns task contains the annotations or error
*/
getPageAnnotations: (doc: PdfDocumentObject, page: PdfPageObject) => PdfTask<PdfAnnotationObject[]>;
/**
* Change the visible colour (and opacity) of an existing annotation.
* @param doc - pdf document
* @param page - pdf page
* @param annotation - the annotation to recolour
* @param colour - RGBA color values (0-255 per channel)
* @param which - 0 = stroke/fill colour (PDFium's "colourType" param)
* @returns task that indicates whether the operation succeeded
*/
updateAnnotationColor: (doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObjectBase, color: WebAlphaColor, which?: number) => PdfTask<boolean>;
/**
* Create a annotation on specified page
* @param doc - pdf document
* @param page - pdf page
* @param annotation - new annotations
* @returns task whether the annotations is created successfully
*/
createPageAnnotation: (doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject) => PdfTask<number>;
/**
* Update a annotation on specified page
* @param doc - pdf document
* @param page - pdf page
* @param annotation - new annotations
* @returns task that indicates whether the operation succeeded
*/
updatePageAnnotation: (doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject) => PdfTask<boolean>;
/**
* Remove a annotation on specified page
* @param doc - pdf document
* @param page - pdf page
* @param annotation - new annotations
* @returns task whether the annotations is removed successfully
*/
removePageAnnotation: (doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject) => PdfTask<boolean>;
/**
* get all text rects in pdf page
* @param doc - pdf document
* @param page - pdf page
* @param scaleFactor - factor of scaling
* @param rotation - rotated angle
* @returns task contains the text rects or error
*/
getPageTextRects: (doc: PdfDocumentObject, page: PdfPageObject, scaleFactor: number, rotation: Rotation) => PdfTask<PdfTextRectObject[]>;
/**
* Render the thumbnail of specified pdf page
* @param doc - pdf document
* @param page - pdf page
* @param scaleFactor - factor of scaling
* @param rotation - rotated angle
* @param dpr - devicePixelRatio
* @param options - render options
* @returns task contains the rendered image or error
*/
renderThumbnail: (doc: PdfDocumentObject, page: PdfPageObject, scaleFactor: number, rotation: Rotation, dpr: number) => PdfTask<T>;
/**
* Search across all pages in the document
* @param doc - pdf document
* @param keyword - search keyword
* @param flags - match flags for search
* @returns Task contains all search results throughout the document
*/
searchAllPages: (doc: PdfDocumentObject, keyword: string, flags?: MatchFlag[]) => PdfTask<SearchAllPagesResult>;
/**
* Get all annotations in this file
* @param doc - pdf document
* @returns task that contains the annotations or error
*/
getAllAnnotations: (doc: PdfDocumentObject) => PdfTask<Record<number, PdfAnnotationObject[]>>;
/**
* Get all attachments in this file
* @param doc - pdf document
* @returns task that contains the attachments or error
*/
getAttachments: (doc: PdfDocumentObject) => PdfTask<PdfAttachmentObject[]>;
/**
* Read content of pdf attachment
* @param doc - pdf document
* @param attachment - pdf attachments
* @returns task that contains the content of specified attachment or error
*/
readAttachmentContent: (doc: PdfDocumentObject, attachment: PdfAttachmentObject) => PdfTask<ArrayBuffer>;
/**
* Set form field value
* @param doc - pdf document
* @param page - pdf page
* @param annotation - pdf annotation
* @param text - text value
*/
setFormFieldValue: (doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfWidgetAnnoObject, value: FormFieldValue) => PdfTask<boolean>;
/**
* Flatten annotations and form fields into the page contents.
* @param doc - pdf document
* @param page - pdf page
* @param flag - flatten flag
*/
flattenPage: (doc: PdfDocumentObject, page: PdfPageObject, flag: PdfPageFlattenFlag) => PdfTask<PdfPageFlattenResult>;
/**
* Extract pdf pages to a new file
* @param doc - pdf document
* @param pageIndexes - indexes of pdf pages
* @returns task contains the new pdf file content
*/
extractPages: (doc: PdfDocumentObject, pageIndexes: number[]) => PdfTask<ArrayBuffer>;
/**
* Extract text on specified pdf pages
* @param doc - pdf document
* @param pageIndexes - indexes of pdf pages
* @returns task contains the text
*/
extractText: (doc: PdfDocumentObject, pageIndexes: number[]) => PdfTask<string>;
/**
* Extract text on specified pdf pages
* @param doc - pdf document
* @param pageIndexes - indexes of pdf pages
* @returns task contains the text
*/
getTextSlices: (doc: PdfDocumentObject, slices: PageTextSlice[]) => PdfTask<string[]>;
/**
* Get all glyphs in the specified pdf page
* @param doc - pdf document
* @param page - pdf page
* @returns task contains the glyphs
*/
getPageGlyphs: (doc: PdfDocumentObject, page: PdfPageObject) => PdfTask<PdfGlyphObject[]>;
/**
* Get the geometry of the specified pdf page
* @param doc - pdf document
* @param page - pdf page
* @returns task contains the geometry
*/
getPageGeometry: (doc: PdfDocumentObject, page: PdfPageObject) => PdfTask<PdfPageGeometry>;
/**
* Merge multiple pdf documents
* @param files - all the pdf files
* @returns task contains the merged pdf file
*/
merge: (files: PdfFile[]) => PdfTask<PdfFile>;
/**
* Merge specific pages from multiple PDF documents in a custom order
* @param mergeConfigs Array of configurations specifying which pages to merge from which documents
* @returns A PdfTask that resolves with the merged PDF file
* @public
*/
mergePages: (mergeConfigs: Array<{
docId: string;
pageIndices: number[];
}>) => PdfTask<PdfFile>;
/**
* Save a copy of pdf document
* @param doc - pdf document
* @returns task contains the new pdf file content
*/
saveAsCopy: (doc: PdfDocumentObject) => PdfTask<ArrayBuffer>;
/**
* Close pdf document
* @param doc - pdf document
* @returns task that file is closed or not
*/
closeDocument: (doc: PdfDocumentObject) => PdfTask<boolean>;
}
/**
* Method name of PdfEngine interface
*
* @public
*/
export type PdfEngineMethodName = keyof Required<PdfEngine>;
/**
* Arguments of PdfEngine method
*
* @public
*/
export type PdfEngineMethodArgs<P extends PdfEngineMethodName> = Readonly<Parameters<Required<PdfEngine>[P]>>;
/**
* Return type of PdfEngine method
*
* @public
*/
export type PdfEngineMethodReturnType<P extends PdfEngineMethodName> = ReturnType<Required<PdfEngine>[P]>;
export {};
/**
* Stage of task
*
* @public
*/
export declare enum TaskStage {
/**
* Task is pending, means it just start executing
*/
Pending = 0,
/**
* Task is succeed
*/
Resolved = 1,
/**
* Task is failed
*/
Rejected = 2,
/**
* Task is aborted
*/
Aborted = 3
}
export interface TaskError<D> {
/**
* task error type
*/
type: 'reject' | 'abort';
/**
* task error
*/
reason: D;
}
/**
* callback that will be called when task is resolved
*
* @public
*/
export type ResolvedCallback<R> = (r: R) => void;
/**
* callback that will be called when task is rejected
*
* @public
*/
export type RejectedCallback<D> = (e: TaskError<D>) => void;
/**
* Task state in different stage
*
* @public
*/
export type TaskState<R, D> = {
stage: TaskStage.Pending;
} | {
stage: TaskStage.Resolved;
result: R;
} | {
stage: TaskStage.Rejected;
reason: D;
} | {
stage: TaskStage.Aborted;
reason: D;
};
/**
* Result type for allSettled
*
* @public
*/
export type TaskSettledResult<R, D> = {
status: 'resolved';
value: R;
} | {
status: 'rejected';
reason: D;
} | {
status: 'aborted';
reason: D;
};
export declare class TaskAbortedError<D> extends Error {
constructor(reason: D);
}
export declare class TaskRejectedError<D> extends Error {
constructor(reason: D);
}
/**
* Base class of task
*
* @public
*/
export declare class Task<R, D> {
state: TaskState<R, D>;
/**
* callbacks that will be executed when task is resolved
*/
resolvedCallbacks: ResolvedCallback<R>[];
/**
* callbacks that will be executed when task is rejected
*/
rejectedCallbacks: RejectedCallback<D>[];
/**
* Promise that will be resolved when task is settled
*/
private _promise;
/**
* Convert task to promise
* @returns promise that will be resolved when task is settled
*/
toPromise(): Promise<R>;
/**
* wait for task to be settled
* @param resolvedCallback - callback for resolved value
* @param rejectedCallback - callback for rejected value
*/
wait(resolvedCallback: ResolvedCallback<R>, rejectedCallback: RejectedCallback<D>): void;
/**
* resolve task with specific result
* @param result - result value
*/
resolve(result: R): void;
/**
* reject task with specific reason
* @param reason - abort reason
*
*/
reject(reason: D): void;
/**
* abort task with specific reason
* @param reason - abort reason
*/
abort(reason: D): void;
/**
* fail task with a TaskError from another task
* This is a convenience method for error propagation between tasks
* @param error - TaskError from another task
*/
fail(error: TaskError<D>): void;
/**
* Static method to wait for all tasks to resolve
* Returns a new task that resolves with an array of all results
* Rejects immediately if any task fails
*
* @param tasks - array of tasks to wait for
* @returns new task that resolves when all input tasks resolve
* @public
*/
static all<R extends readonly Task<any, any>[]>(tasks: R): Task<{
[K in keyof R]: R[K] extends Task<infer U, any> ? U : never;
}, any>;
/**
* Static method to wait for all tasks to settle (resolve, reject, or abort)
* Always resolves with an array of settlement results
*
* @param tasks - array of tasks to wait for
* @returns new task that resolves when all input tasks settle
* @public
*/
static allSettled<R extends readonly Task<any, any>[]>(tasks: R): Task<{
[K in keyof R]: R[K] extends Task<infer U, infer E> ? TaskSettledResult<U, E> : never;
}, never>;
/**
* Static method that resolves/rejects with the first task that settles
*
* @param tasks - array of tasks to race
* @returns new task that settles with the first input task that settles
* @public
*/
static race<R extends readonly Task<any, any>[]>(tasks: R): Task<R[number] extends Task<infer U, any> ? U : never, R[number] extends Task<any, infer E> ? E : never>;
/**
* Utility to track progress of multiple tasks
*
* @param tasks - array of tasks to track
* @param onProgress - callback called when any task completes
* @returns new task that resolves when all input tasks resolve
* @public
*/
static withProgress<R extends readonly Task<any, any>[]>(tasks: R, onProgress?: (completed: number, total: number) => void): Task<{
[K in keyof R]: R[K] extends Task<infer U, any> ? U : never;
}, any>;
}
/**
* Type that represent the result of executing task
*/
export type TaskReturn<T extends Task<any, any>> = T extends Task<infer R, infer E> ? {
type: 'result';
value: R;
} | {
type: 'error';
value: TaskError<E>;
} : never;
+2
-1301

@@ -1,1301 +0,2 @@

"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var index_exports = {};
__export(index_exports, {
AllLogger: () => AllLogger,
AppearanceMode: () => AppearanceMode,
ConsoleLogger: () => ConsoleLogger,
LevelLogger: () => LevelLogger,
LogLevel: () => LogLevel,
MatchFlag: () => MatchFlag,
NoopLogger: () => NoopLogger,
PDF_FORM_FIELD_FLAG: () => PDF_FORM_FIELD_FLAG,
PDF_FORM_FIELD_TYPE: () => PDF_FORM_FIELD_TYPE,
PdfActionType: () => PdfActionType,
PdfAnnotationBorderStyle: () => PdfAnnotationBorderStyle,
PdfAnnotationColorType: () => PdfAnnotationColorType,
PdfAnnotationFlagName: () => PdfAnnotationFlagName,
PdfAnnotationFlags: () => PdfAnnotationFlags,
PdfAnnotationObjectStatus: () => PdfAnnotationObjectStatus,
PdfAnnotationState: () => PdfAnnotationState,
PdfAnnotationStateModel: () => PdfAnnotationStateModel,
PdfAnnotationSubtype: () => PdfAnnotationSubtype,
PdfAnnotationSubtypeName: () => PdfAnnotationSubtypeName,
PdfBomOrZwnbsp: () => PdfBomOrZwnbsp,
PdfEngineFeature: () => PdfEngineFeature,
PdfEngineOperation: () => PdfEngineOperation,
PdfErrorCode: () => PdfErrorCode,
PdfNonCharacterFFFE: () => PdfNonCharacterFFFE,
PdfNonCharacterFFFF: () => PdfNonCharacterFFFF,
PdfPageFlattenFlag: () => PdfPageFlattenFlag,
PdfPageFlattenResult: () => PdfPageFlattenResult,
PdfPageObjectType: () => PdfPageObjectType,
PdfPermission: () => PdfPermission,
PdfSegmentObjectType: () => PdfSegmentObjectType,
PdfSoftHyphenMarker: () => PdfSoftHyphenMarker,
PdfTaskHelper: () => PdfTaskHelper,
PdfUnwantedTextMarkers: () => PdfUnwantedTextMarkers,
PdfUnwantedTextRegex: () => PdfUnwantedTextRegex,
PdfWordJoiner: () => PdfWordJoiner,
PdfZeroWidthSpace: () => PdfZeroWidthSpace,
PdfZoomMode: () => PdfZoomMode,
PerfLogger: () => PerfLogger,
Rotation: () => Rotation,
Task: () => Task,
TaskAbortedError: () => TaskAbortedError,
TaskRejectedError: () => TaskRejectedError,
TaskStage: () => TaskStage,
boundingRect: () => boundingRect,
calculateAngle: () => calculateAngle,
calculateDegree: () => calculateDegree,
compareSearchTarget: () => compareSearchTarget,
dateToPdfDate: () => dateToPdfDate,
flagsToNames: () => flagsToNames,
ignore: () => ignore,
makeMatrix: () => makeMatrix,
namesToFlags: () => namesToFlags,
pdfAlphaColorToWebAlphaColor: () => pdfAlphaColorToWebAlphaColor,
pdfDateToDate: () => pdfDateToDate,
quadToRect: () => quadToRect,
rectToQuad: () => rectToQuad,
restoreOffset: () => restoreOffset,
restorePosition: () => restorePosition,
restoreRect: () => restoreRect,
rotatePosition: () => rotatePosition,
rotateRect: () => rotateRect,
scalePosition: () => scalePosition,
scaleRect: () => scaleRect,
stripPdfUnwantedMarkers: () => stripPdfUnwantedMarkers,
swap: () => swap,
toIntPos: () => toIntPos,
toIntRect: () => toIntRect,
toIntSize: () => toIntSize,
transformPosition: () => transformPosition,
transformRect: () => transformRect,
transformSize: () => transformSize,
unionFlags: () => unionFlags,
webAlphaColorToPdfAlphaColor: () => webAlphaColorToPdfAlphaColor
});
module.exports = __toCommonJS(index_exports);
// src/geometry.ts
var Rotation = /* @__PURE__ */ ((Rotation2) => {
Rotation2[Rotation2["Degree0"] = 0] = "Degree0";
Rotation2[Rotation2["Degree90"] = 1] = "Degree90";
Rotation2[Rotation2["Degree180"] = 2] = "Degree180";
Rotation2[Rotation2["Degree270"] = 3] = "Degree270";
return Rotation2;
})(Rotation || {});
function toIntPos(p) {
return { x: Math.floor(p.x), y: Math.floor(p.y) };
}
function toIntSize(s) {
return { width: Math.ceil(s.width), height: Math.ceil(s.height) };
}
function toIntRect(r) {
return {
origin: toIntPos(r.origin),
size: toIntSize(r.size)
};
}
function calculateDegree(rotation) {
switch (rotation) {
case 0 /* Degree0 */:
return 0;
case 1 /* Degree90 */:
return 90;
case 2 /* Degree180 */:
return 180;
case 3 /* Degree270 */:
return 270;
}
}
function calculateAngle(rotation) {
return calculateDegree(rotation) * Math.PI / 180;
}
function swap(size) {
const { width, height } = size;
return {
width: height,
height: width
};
}
function transformSize(size, rotation, scaleFactor) {
size = rotation % 2 === 0 ? size : swap(size);
return {
width: size.width * scaleFactor,
height: size.height * scaleFactor
};
}
function quadToRect(q) {
const xs = [q.p1.x, q.p2.x, q.p3.x, q.p4.x];
const ys = [q.p1.y, q.p2.y, q.p3.y, q.p4.y];
return {
origin: { x: Math.min(...xs), y: Math.min(...ys) },
size: {
width: Math.max(...xs) - Math.min(...xs),
height: Math.max(...ys) - Math.min(...ys)
}
};
}
function rectToQuad(r) {
return {
p1: { x: r.origin.x, y: r.origin.y },
p2: { x: r.origin.x + r.size.width, y: r.origin.y },
p3: { x: r.origin.x + r.size.width, y: r.origin.y + r.size.height },
p4: { x: r.origin.x, y: r.origin.y + r.size.height }
};
}
function rotatePosition(containerSize, position, rotation) {
let x = position.x;
let y = position.y;
switch (rotation) {
case 0 /* Degree0 */:
x = position.x;
y = position.y;
break;
case 1 /* Degree90 */:
x = containerSize.height - position.y;
y = position.x;
break;
case 2 /* Degree180 */:
x = containerSize.width - position.x;
y = containerSize.height - position.y;
break;
case 3 /* Degree270 */:
x = position.y;
y = containerSize.width - position.x;
break;
}
return {
x,
y
};
}
function scalePosition(position, scaleFactor) {
return {
x: position.x * scaleFactor,
y: position.y * scaleFactor
};
}
function transformPosition(containerSize, position, rotation, scaleFactor) {
return scalePosition(rotatePosition(containerSize, position, rotation), scaleFactor);
}
function restorePosition(containerSize, position, rotation, scaleFactor) {
return scalePosition(
rotatePosition(containerSize, position, (4 - rotation) % 4),
1 / scaleFactor
);
}
function rotateRect(containerSize, rect, rotation) {
let x = rect.origin.x;
let y = rect.origin.y;
let size = rect.size;
switch (rotation) {
case 0 /* Degree0 */:
break;
case 1 /* Degree90 */:
x = containerSize.height - rect.origin.y - rect.size.height;
y = rect.origin.x;
size = swap(rect.size);
break;
case 2 /* Degree180 */:
x = containerSize.width - rect.origin.x - rect.size.width;
y = containerSize.height - rect.origin.y - rect.size.height;
break;
case 3 /* Degree270 */:
x = rect.origin.y;
y = containerSize.width - rect.origin.x - rect.size.width;
size = swap(rect.size);
break;
}
return {
origin: {
x,
y
},
size: {
width: size.width,
height: size.height
}
};
}
function scaleRect(rect, scaleFactor) {
return {
origin: {
x: rect.origin.x * scaleFactor,
y: rect.origin.y * scaleFactor
},
size: {
width: rect.size.width * scaleFactor,
height: rect.size.height * scaleFactor
}
};
}
function transformRect(containerSize, rect, rotation, scaleFactor) {
return scaleRect(rotateRect(containerSize, rect, rotation), scaleFactor);
}
function restoreRect(containerSize, rect, rotation, scaleFactor) {
return scaleRect(rotateRect(containerSize, rect, (4 - rotation) % 4), 1 / scaleFactor);
}
function restoreOffset(offset, rotation, scaleFactor) {
let offsetX = offset.x;
let offsetY = offset.y;
switch (rotation) {
case 0 /* Degree0 */:
offsetX = offset.x / scaleFactor;
offsetY = offset.y / scaleFactor;
break;
case 1 /* Degree90 */:
offsetX = offset.y / scaleFactor;
offsetY = -offset.x / scaleFactor;
break;
case 2 /* Degree180 */:
offsetX = -offset.x / scaleFactor;
offsetY = -offset.y / scaleFactor;
break;
case 3 /* Degree270 */:
offsetX = -offset.y / scaleFactor;
offsetY = offset.x / scaleFactor;
break;
}
return {
x: offsetX,
y: offsetY
};
}
function boundingRect(rects) {
if (rects.length === 0) return null;
let minX = rects[0].origin.x, minY = rects[0].origin.y, maxX = rects[0].origin.x + rects[0].size.width, maxY = rects[0].origin.y + rects[0].size.height;
for (const r of rects) {
minX = Math.min(minX, r.origin.x);
minY = Math.min(minY, r.origin.y);
maxX = Math.max(maxX, r.origin.x + r.size.width);
maxY = Math.max(maxY, r.origin.y + r.size.height);
}
return {
origin: {
x: minX,
y: minY
},
size: {
width: maxX - minX,
height: maxY - minY
}
};
}
var makeMatrix = (rectangle, rotation, scaleFactor) => {
const { width, height } = rectangle.size;
switch (rotation) {
case 0 /* Degree0 */:
return {
a: scaleFactor,
b: 0,
c: 0,
d: -scaleFactor,
e: 0,
f: height * scaleFactor
};
case 1 /* Degree90 */:
return {
a: 0,
b: scaleFactor,
c: scaleFactor,
d: 0,
e: 0,
f: 0
};
case 2 /* Degree180 */:
return {
a: -scaleFactor,
b: 0,
c: 0,
d: scaleFactor,
e: width * scaleFactor,
f: 0
};
case 3 /* Degree270 */:
return {
a: 0,
b: -scaleFactor,
c: -scaleFactor,
d: 0,
e: height * scaleFactor,
f: width * scaleFactor
};
}
};
// src/logger.ts
var NoopLogger = class {
/** {@inheritDoc Logger.debug} */
debug() {
}
/** {@inheritDoc Logger.info} */
info() {
}
/** {@inheritDoc Logger.warn} */
warn() {
}
/** {@inheritDoc Logger.error} */
error() {
}
/** {@inheritDoc Logger.perf} */
perf() {
}
};
var ConsoleLogger = class {
/** {@inheritDoc Logger.debug} */
debug(source, category, ...args) {
console.debug(`${source}.${category}`, ...args);
}
/** {@inheritDoc Logger.info} */
info(source, category, ...args) {
console.info(`${source}.${category}`, ...args);
}
/** {@inheritDoc Logger.warn} */
warn(source, category, ...args) {
console.warn(`${source}.${category}`, ...args);
}
/** {@inheritDoc Logger.error} */
error(source, category, ...args) {
console.error(`${source}.${category}`, ...args);
}
/** {@inheritDoc Logger.perf} */
perf(source, category, event, phase, ...args) {
console.info(`${source}.${category}.${event}.${phase}`, ...args);
}
};
var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
LogLevel2[LogLevel2["Debug"] = 0] = "Debug";
LogLevel2[LogLevel2["Info"] = 1] = "Info";
LogLevel2[LogLevel2["Warn"] = 2] = "Warn";
LogLevel2[LogLevel2["Error"] = 3] = "Error";
return LogLevel2;
})(LogLevel || {});
var LevelLogger = class {
/**
* create new LevelLogger
* @param logger - the original logger
* @param level - log level that used for filtering, all logs lower than this level will be filtered out
*/
constructor(logger, level) {
this.logger = logger;
this.level = level;
}
/** {@inheritDoc Logger.debug} */
debug(source, category, ...args) {
if (this.level <= 0 /* Debug */) {
this.logger.debug(source, category, ...args);
}
}
/** {@inheritDoc Logger.info} */
info(source, category, ...args) {
if (this.level <= 1 /* Info */) {
this.logger.info(source, category, ...args);
}
}
/** {@inheritDoc Logger.warn} */
warn(source, category, ...args) {
if (this.level <= 2 /* Warn */) {
this.logger.warn(source, category, ...args);
}
}
/** {@inheritDoc Logger.error} */
error(source, category, ...args) {
if (this.level <= 3 /* Error */) {
this.logger.error(source, category, ...args);
}
}
/** {@inheritDoc Logger.perf} */
perf(source, category, event, phase, ...args) {
this.logger.perf(source, category, event, phase, ...args);
}
};
var PerfLogger = class {
/**
* create new PerfLogger
*/
constructor() {
}
/** {@inheritDoc Logger.debug} */
debug(source, category, ...args) {
}
/** {@inheritDoc Logger.info} */
info(source, category, ...args) {
}
/** {@inheritDoc Logger.warn} */
warn(source, category, ...args) {
}
/** {@inheritDoc Logger.error} */
error(source, category, ...args) {
}
/** {@inheritDoc Logger.perf} */
perf(source, category, event, phase, identifier, ...args) {
switch (phase) {
case "Begin":
window.performance.mark(`${source}.${category}.${event}.${phase}.${identifier}`, {
detail: args
});
break;
case "End":
window.performance.mark(`${source}.${category}.${event}.${phase}.${identifier}`, {
detail: args
});
window.performance.measure(
`${source}.${category}.${event}.Measure.${identifier}`,
`${source}.${category}.${event}.Begin.${identifier}`,
`${source}.${category}.${event}.End.${identifier}`
);
break;
}
}
};
var AllLogger = class {
/**
* create new PerfLogger
*/
constructor(loggers) {
this.loggers = loggers;
}
/** {@inheritDoc Logger.debug} */
debug(source, category, ...args) {
for (const logger of this.loggers) {
logger.debug(source, category, ...args);
}
}
/** {@inheritDoc Logger.info} */
info(source, category, ...args) {
for (const logger of this.loggers) {
logger.info(source, category, ...args);
}
}
/** {@inheritDoc Logger.warn} */
warn(source, category, ...args) {
for (const logger of this.loggers) {
logger.warn(source, category, ...args);
}
}
/** {@inheritDoc Logger.error} */
error(source, category, ...args) {
for (const logger of this.loggers) {
logger.error(source, category, ...args);
}
}
/** {@inheritDoc Logger.perf} */
perf(source, category, event, phase, ...args) {
for (const logger of this.loggers) {
logger.perf(source, category, event, phase, ...args);
}
}
};
// src/task.ts
var TaskStage = /* @__PURE__ */ ((TaskStage2) => {
TaskStage2[TaskStage2["Pending"] = 0] = "Pending";
TaskStage2[TaskStage2["Resolved"] = 1] = "Resolved";
TaskStage2[TaskStage2["Rejected"] = 2] = "Rejected";
TaskStage2[TaskStage2["Aborted"] = 3] = "Aborted";
return TaskStage2;
})(TaskStage || {});
var TaskAbortedError = class extends Error {
constructor(reason) {
super(`Task aborted: ${JSON.stringify(reason)}`);
this.name = "TaskAbortedError";
}
};
var TaskRejectedError = class extends Error {
constructor(reason) {
super(`Task rejected: ${JSON.stringify(reason)}`);
this.name = "TaskRejectedError";
}
};
var Task = class _Task {
constructor() {
this.state = {
stage: 0 /* Pending */
};
/**
* callbacks that will be executed when task is resolved
*/
this.resolvedCallbacks = [];
/**
* callbacks that will be executed when task is rejected
*/
this.rejectedCallbacks = [];
/**
* Promise that will be resolved when task is settled
*/
this._promise = null;
}
/**
* Convert task to promise
* @returns promise that will be resolved when task is settled
*/
toPromise() {
if (!this._promise) {
this._promise = new Promise((resolve, reject) => {
this.wait(
(result) => resolve(result),
(error) => {
if (error.type === "abort") {
reject(new TaskAbortedError(error.reason));
} else {
reject(new TaskRejectedError(error.reason));
}
}
);
});
}
return this._promise;
}
/**
* wait for task to be settled
* @param resolvedCallback - callback for resolved value
* @param rejectedCallback - callback for rejected value
*/
wait(resolvedCallback, rejectedCallback) {
switch (this.state.stage) {
case 0 /* Pending */:
this.resolvedCallbacks.push(resolvedCallback);
this.rejectedCallbacks.push(rejectedCallback);
break;
case 1 /* Resolved */:
resolvedCallback(this.state.result);
break;
case 2 /* Rejected */:
rejectedCallback({
type: "reject",
reason: this.state.reason
});
break;
case 3 /* Aborted */:
rejectedCallback({
type: "abort",
reason: this.state.reason
});
break;
}
}
/**
* resolve task with specific result
* @param result - result value
*/
resolve(result) {
if (this.state.stage === 0 /* Pending */) {
this.state = {
stage: 1 /* Resolved */,
result
};
for (const resolvedCallback of this.resolvedCallbacks) {
try {
resolvedCallback(result);
} catch (e) {
}
}
this.resolvedCallbacks = [];
this.rejectedCallbacks = [];
}
}
/**
* reject task with specific reason
* @param reason - abort reason
*
*/
reject(reason) {
if (this.state.stage === 0 /* Pending */) {
this.state = {
stage: 2 /* Rejected */,
reason
};
for (const rejectedCallback of this.rejectedCallbacks) {
try {
rejectedCallback({
type: "reject",
reason
});
} catch (e) {
}
}
this.resolvedCallbacks = [];
this.rejectedCallbacks = [];
}
}
/**
* abort task with specific reason
* @param reason - abort reason
*/
abort(reason) {
if (this.state.stage === 0 /* Pending */) {
this.state = {
stage: 3 /* Aborted */,
reason
};
for (const rejectedCallback of this.rejectedCallbacks) {
try {
rejectedCallback({
type: "abort",
reason
});
} catch (e) {
}
}
this.resolvedCallbacks = [];
this.rejectedCallbacks = [];
}
}
/**
* fail task with a TaskError from another task
* This is a convenience method for error propagation between tasks
* @param error - TaskError from another task
*/
fail(error) {
if (error.type === "abort") {
this.abort(error.reason);
} else {
this.reject(error.reason);
}
}
/**
* Static method to wait for all tasks to resolve
* Returns a new task that resolves with an array of all results
* Rejects immediately if any task fails
*
* @param tasks - array of tasks to wait for
* @returns new task that resolves when all input tasks resolve
* @public
*/
static all(tasks) {
const combinedTask = new _Task();
if (tasks.length === 0) {
combinedTask.resolve([]);
return combinedTask;
}
const results = new Array(tasks.length);
let resolvedCount = 0;
let isSettled = false;
tasks.forEach((task, index) => {
task.wait(
(result) => {
if (isSettled) return;
results[index] = result;
resolvedCount++;
if (resolvedCount === tasks.length) {
isSettled = true;
combinedTask.resolve(results);
}
},
(error) => {
if (isSettled) return;
isSettled = true;
if (error.type === "abort") {
combinedTask.abort(error.reason);
} else {
combinedTask.reject(error.reason);
}
}
);
});
return combinedTask;
}
/**
* Static method to wait for all tasks to settle (resolve, reject, or abort)
* Always resolves with an array of settlement results
*
* @param tasks - array of tasks to wait for
* @returns new task that resolves when all input tasks settle
* @public
*/
static allSettled(tasks) {
const combinedTask = new _Task();
if (tasks.length === 0) {
combinedTask.resolve([]);
return combinedTask;
}
const results = new Array(tasks.length);
let settledCount = 0;
tasks.forEach((task, index) => {
task.wait(
(result) => {
results[index] = { status: "resolved", value: result };
settledCount++;
if (settledCount === tasks.length) {
combinedTask.resolve(results);
}
},
(error) => {
results[index] = {
status: error.type === "abort" ? "aborted" : "rejected",
reason: error.reason
};
settledCount++;
if (settledCount === tasks.length) {
combinedTask.resolve(results);
}
}
);
});
return combinedTask;
}
/**
* Static method that resolves/rejects with the first task that settles
*
* @param tasks - array of tasks to race
* @returns new task that settles with the first input task that settles
* @public
*/
static race(tasks) {
const combinedTask = new _Task();
if (tasks.length === 0) {
combinedTask.reject("No tasks provided");
return combinedTask;
}
let isSettled = false;
tasks.forEach((task) => {
task.wait(
(result) => {
if (isSettled) return;
isSettled = true;
combinedTask.resolve(result);
},
(error) => {
if (isSettled) return;
isSettled = true;
if (error.type === "abort") {
combinedTask.abort(error.reason);
} else {
combinedTask.reject(error.reason);
}
}
);
});
return combinedTask;
}
/**
* Utility to track progress of multiple tasks
*
* @param tasks - array of tasks to track
* @param onProgress - callback called when any task completes
* @returns new task that resolves when all input tasks resolve
* @public
*/
static withProgress(tasks, onProgress) {
const combinedTask = _Task.all(tasks);
if (onProgress) {
let completedCount = 0;
tasks.forEach((task) => {
task.wait(
() => {
completedCount++;
onProgress(completedCount, tasks.length);
},
() => {
completedCount++;
onProgress(completedCount, tasks.length);
}
);
});
}
return combinedTask;
}
};
// src/pdf.ts
var PdfSoftHyphenMarker = "\xAD";
var PdfZeroWidthSpace = "\u200B";
var PdfWordJoiner = "\u2060";
var PdfBomOrZwnbsp = "\uFEFF";
var PdfNonCharacterFFFE = "\uFFFE";
var PdfNonCharacterFFFF = "\uFFFF";
var PdfUnwantedTextMarkers = Object.freeze([
PdfSoftHyphenMarker,
PdfZeroWidthSpace,
PdfWordJoiner,
PdfBomOrZwnbsp,
PdfNonCharacterFFFE,
PdfNonCharacterFFFF
]);
var PdfUnwantedTextRegex = new RegExp(`[${PdfUnwantedTextMarkers.join("")}]`, "g");
function stripPdfUnwantedMarkers(text) {
return text.replace(PdfUnwantedTextRegex, "");
}
var PdfZoomMode = /* @__PURE__ */ ((PdfZoomMode2) => {
PdfZoomMode2[PdfZoomMode2["Unknown"] = 0] = "Unknown";
PdfZoomMode2[PdfZoomMode2["XYZ"] = 1] = "XYZ";
PdfZoomMode2[PdfZoomMode2["FitPage"] = 2] = "FitPage";
PdfZoomMode2[PdfZoomMode2["FitHorizontal"] = 3] = "FitHorizontal";
PdfZoomMode2[PdfZoomMode2["FitVertical"] = 4] = "FitVertical";
PdfZoomMode2[PdfZoomMode2["FitRectangle"] = 5] = "FitRectangle";
return PdfZoomMode2;
})(PdfZoomMode || {});
var PdfActionType = /* @__PURE__ */ ((PdfActionType2) => {
PdfActionType2[PdfActionType2["Unsupported"] = 0] = "Unsupported";
PdfActionType2[PdfActionType2["Goto"] = 1] = "Goto";
PdfActionType2[PdfActionType2["RemoteGoto"] = 2] = "RemoteGoto";
PdfActionType2[PdfActionType2["URI"] = 3] = "URI";
PdfActionType2[PdfActionType2["LaunchAppOrOpenFile"] = 4] = "LaunchAppOrOpenFile";
return PdfActionType2;
})(PdfActionType || {});
var PdfAnnotationSubtype = /* @__PURE__ */ ((PdfAnnotationSubtype2) => {
PdfAnnotationSubtype2[PdfAnnotationSubtype2["UNKNOWN"] = 0] = "UNKNOWN";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["TEXT"] = 1] = "TEXT";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["LINK"] = 2] = "LINK";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["FREETEXT"] = 3] = "FREETEXT";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["LINE"] = 4] = "LINE";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["SQUARE"] = 5] = "SQUARE";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["CIRCLE"] = 6] = "CIRCLE";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["POLYGON"] = 7] = "POLYGON";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["POLYLINE"] = 8] = "POLYLINE";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["HIGHLIGHT"] = 9] = "HIGHLIGHT";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["UNDERLINE"] = 10] = "UNDERLINE";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["SQUIGGLY"] = 11] = "SQUIGGLY";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["STRIKEOUT"] = 12] = "STRIKEOUT";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["STAMP"] = 13] = "STAMP";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["CARET"] = 14] = "CARET";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["INK"] = 15] = "INK";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["POPUP"] = 16] = "POPUP";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["FILEATTACHMENT"] = 17] = "FILEATTACHMENT";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["SOUND"] = 18] = "SOUND";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["MOVIE"] = 19] = "MOVIE";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["WIDGET"] = 20] = "WIDGET";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["SCREEN"] = 21] = "SCREEN";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["PRINTERMARK"] = 22] = "PRINTERMARK";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["TRAPNET"] = 23] = "TRAPNET";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["WATERMARK"] = 24] = "WATERMARK";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["THREED"] = 25] = "THREED";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["RICHMEDIA"] = 26] = "RICHMEDIA";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["XFAWIDGET"] = 27] = "XFAWIDGET";
PdfAnnotationSubtype2[PdfAnnotationSubtype2["REDACT"] = 28] = "REDACT";
return PdfAnnotationSubtype2;
})(PdfAnnotationSubtype || {});
var PdfAnnotationSubtypeName = {
[0 /* UNKNOWN */]: "unknow",
[1 /* TEXT */]: "text",
[2 /* LINK */]: "link",
[3 /* FREETEXT */]: "freetext",
[4 /* LINE */]: "line",
[5 /* SQUARE */]: "square",
[6 /* CIRCLE */]: "circle",
[7 /* POLYGON */]: "polygon",
[8 /* POLYLINE */]: "polyline",
[9 /* HIGHLIGHT */]: "highlight",
[10 /* UNDERLINE */]: "underline",
[11 /* SQUIGGLY */]: "squiggly",
[12 /* STRIKEOUT */]: "strikeout",
[13 /* STAMP */]: "stamp",
[14 /* CARET */]: "caret",
[15 /* INK */]: "ink",
[16 /* POPUP */]: "popup",
[17 /* FILEATTACHMENT */]: "fileattachment",
[18 /* SOUND */]: "sound",
[19 /* MOVIE */]: "movie",
[20 /* WIDGET */]: "widget",
[21 /* SCREEN */]: "screen",
[22 /* PRINTERMARK */]: "printermark",
[23 /* TRAPNET */]: "trapnet",
[24 /* WATERMARK */]: "watermark",
[25 /* THREED */]: "threed",
[26 /* RICHMEDIA */]: "richmedia",
[27 /* XFAWIDGET */]: "xfawidget",
[28 /* REDACT */]: "redact"
};
var PdfAnnotationObjectStatus = /* @__PURE__ */ ((PdfAnnotationObjectStatus2) => {
PdfAnnotationObjectStatus2[PdfAnnotationObjectStatus2["Created"] = 0] = "Created";
PdfAnnotationObjectStatus2[PdfAnnotationObjectStatus2["Committed"] = 1] = "Committed";
return PdfAnnotationObjectStatus2;
})(PdfAnnotationObjectStatus || {});
var AppearanceMode = /* @__PURE__ */ ((AppearanceMode2) => {
AppearanceMode2[AppearanceMode2["Normal"] = 0] = "Normal";
AppearanceMode2[AppearanceMode2["Rollover"] = 1] = "Rollover";
AppearanceMode2[AppearanceMode2["Down"] = 2] = "Down";
return AppearanceMode2;
})(AppearanceMode || {});
var PdfAnnotationState = /* @__PURE__ */ ((PdfAnnotationState2) => {
PdfAnnotationState2["Marked"] = "Marked";
PdfAnnotationState2["Unmarked"] = "Unmarked";
PdfAnnotationState2["Accepted"] = "Accepted";
PdfAnnotationState2["Rejected"] = "Rejected";
PdfAnnotationState2["Complete"] = "Complete";
PdfAnnotationState2["Cancelled"] = "Cancelled";
PdfAnnotationState2["None"] = "None";
return PdfAnnotationState2;
})(PdfAnnotationState || {});
var PdfAnnotationStateModel = /* @__PURE__ */ ((PdfAnnotationStateModel2) => {
PdfAnnotationStateModel2["Marked"] = "Marked";
PdfAnnotationStateModel2["Reviewed"] = "Reviewed";
return PdfAnnotationStateModel2;
})(PdfAnnotationStateModel || {});
var PDF_FORM_FIELD_TYPE = /* @__PURE__ */ ((PDF_FORM_FIELD_TYPE2) => {
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["UNKNOWN"] = 0] = "UNKNOWN";
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["PUSHBUTTON"] = 1] = "PUSHBUTTON";
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["CHECKBOX"] = 2] = "CHECKBOX";
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["RADIOBUTTON"] = 3] = "RADIOBUTTON";
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["COMBOBOX"] = 4] = "COMBOBOX";
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["LISTBOX"] = 5] = "LISTBOX";
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["TEXTFIELD"] = 6] = "TEXTFIELD";
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["SIGNATURE"] = 7] = "SIGNATURE";
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["XFA"] = 8] = "XFA";
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["XFA_CHECKBOX"] = 9] = "XFA_CHECKBOX";
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["XFA_COMBOBOX"] = 10] = "XFA_COMBOBOX";
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["XFA_IMAGEFIELD"] = 11] = "XFA_IMAGEFIELD";
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["XFA_LISTBOX"] = 12] = "XFA_LISTBOX";
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["XFA_PUSHBUTTON"] = 13] = "XFA_PUSHBUTTON";
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["XFA_SIGNATURE"] = 14] = "XFA_SIGNATURE";
PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["XFA_TEXTFIELD"] = 15] = "XFA_TEXTFIELD";
return PDF_FORM_FIELD_TYPE2;
})(PDF_FORM_FIELD_TYPE || {});
var PdfAnnotationColorType = /* @__PURE__ */ ((PdfAnnotationColorType2) => {
PdfAnnotationColorType2[PdfAnnotationColorType2["Color"] = 0] = "Color";
PdfAnnotationColorType2[PdfAnnotationColorType2["InteriorColor"] = 1] = "InteriorColor";
return PdfAnnotationColorType2;
})(PdfAnnotationColorType || {});
var PdfAnnotationBorderStyle = /* @__PURE__ */ ((PdfAnnotationBorderStyle2) => {
PdfAnnotationBorderStyle2[PdfAnnotationBorderStyle2["UNKNOWN"] = 0] = "UNKNOWN";
PdfAnnotationBorderStyle2[PdfAnnotationBorderStyle2["SOLID"] = 1] = "SOLID";
PdfAnnotationBorderStyle2[PdfAnnotationBorderStyle2["DASHED"] = 2] = "DASHED";
PdfAnnotationBorderStyle2[PdfAnnotationBorderStyle2["BEVELED"] = 3] = "BEVELED";
PdfAnnotationBorderStyle2[PdfAnnotationBorderStyle2["INSET"] = 4] = "INSET";
PdfAnnotationBorderStyle2[PdfAnnotationBorderStyle2["UNDERLINE"] = 5] = "UNDERLINE";
PdfAnnotationBorderStyle2[PdfAnnotationBorderStyle2["CLOUDY"] = 6] = "CLOUDY";
return PdfAnnotationBorderStyle2;
})(PdfAnnotationBorderStyle || {});
var PdfAnnotationFlags = /* @__PURE__ */ ((PdfAnnotationFlags2) => {
PdfAnnotationFlags2[PdfAnnotationFlags2["NONE"] = 0] = "NONE";
PdfAnnotationFlags2[PdfAnnotationFlags2["INVISIBLE"] = 1] = "INVISIBLE";
PdfAnnotationFlags2[PdfAnnotationFlags2["HIDDEN"] = 2] = "HIDDEN";
PdfAnnotationFlags2[PdfAnnotationFlags2["PRINT"] = 4] = "PRINT";
PdfAnnotationFlags2[PdfAnnotationFlags2["NO_ZOOM"] = 8] = "NO_ZOOM";
PdfAnnotationFlags2[PdfAnnotationFlags2["NO_ROTATE"] = 16] = "NO_ROTATE";
PdfAnnotationFlags2[PdfAnnotationFlags2["NO_VIEW"] = 32] = "NO_VIEW";
PdfAnnotationFlags2[PdfAnnotationFlags2["READ_ONLY"] = 64] = "READ_ONLY";
PdfAnnotationFlags2[PdfAnnotationFlags2["LOCKED"] = 128] = "LOCKED";
PdfAnnotationFlags2[PdfAnnotationFlags2["TOGGLE_NOVIEW"] = 256] = "TOGGLE_NOVIEW";
return PdfAnnotationFlags2;
})(PdfAnnotationFlags || {});
var PDF_FORM_FIELD_FLAG = /* @__PURE__ */ ((PDF_FORM_FIELD_FLAG2) => {
PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2["NONE"] = 0] = "NONE";
PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2["READONLY"] = 1] = "READONLY";
PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2["REQUIRED"] = 2] = "REQUIRED";
PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2["NOEXPORT"] = 4] = "NOEXPORT";
PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2["TEXT_MULTIPLINE"] = 4096] = "TEXT_MULTIPLINE";
PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2["TEXT_PASSWORD"] = 8192] = "TEXT_PASSWORD";
PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2["CHOICE_COMBO"] = 131072] = "CHOICE_COMBO";
PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2["CHOICE_EDIT"] = 262144] = "CHOICE_EDIT";
PDF_FORM_FIELD_FLAG2[PDF_FORM_FIELD_FLAG2["CHOICE_MULTL_SELECT"] = 2097152] = "CHOICE_MULTL_SELECT";
return PDF_FORM_FIELD_FLAG2;
})(PDF_FORM_FIELD_FLAG || {});
var PdfPageObjectType = /* @__PURE__ */ ((PdfPageObjectType2) => {
PdfPageObjectType2[PdfPageObjectType2["UNKNOWN"] = 0] = "UNKNOWN";
PdfPageObjectType2[PdfPageObjectType2["TEXT"] = 1] = "TEXT";
PdfPageObjectType2[PdfPageObjectType2["PATH"] = 2] = "PATH";
PdfPageObjectType2[PdfPageObjectType2["IMAGE"] = 3] = "IMAGE";
PdfPageObjectType2[PdfPageObjectType2["SHADING"] = 4] = "SHADING";
PdfPageObjectType2[PdfPageObjectType2["FORM"] = 5] = "FORM";
return PdfPageObjectType2;
})(PdfPageObjectType || {});
var PdfAnnotationFlagName = Object.freeze({
[1 /* INVISIBLE */]: "invisible",
[2 /* HIDDEN */]: "hidden",
[4 /* PRINT */]: "print",
[8 /* NO_ZOOM */]: "noZoom",
[16 /* NO_ROTATE */]: "noRotate",
[32 /* NO_VIEW */]: "noView",
[64 /* READ_ONLY */]: "readOnly",
[128 /* LOCKED */]: "locked",
[256 /* TOGGLE_NOVIEW */]: "toggleNoView"
});
var PdfAnnotationFlagValue = Object.entries(
PdfAnnotationFlagName
).reduce(
(acc, [bit, name]) => {
acc[name] = Number(bit);
return acc;
},
{}
);
function flagsToNames(raw) {
return Object.keys(PdfAnnotationFlagName).filter((flag) => (raw & flag) !== 0).map((flag) => PdfAnnotationFlagName[flag]);
}
function namesToFlags(names) {
return names.reduce(
(mask, name) => mask | PdfAnnotationFlagValue[name],
0 /* NONE */
);
}
var PdfSegmentObjectType = /* @__PURE__ */ ((PdfSegmentObjectType2) => {
PdfSegmentObjectType2[PdfSegmentObjectType2["UNKNOWN"] = -1] = "UNKNOWN";
PdfSegmentObjectType2[PdfSegmentObjectType2["LINETO"] = 0] = "LINETO";
PdfSegmentObjectType2[PdfSegmentObjectType2["BEZIERTO"] = 1] = "BEZIERTO";
PdfSegmentObjectType2[PdfSegmentObjectType2["MOVETO"] = 2] = "MOVETO";
return PdfSegmentObjectType2;
})(PdfSegmentObjectType || {});
var PdfEngineFeature = /* @__PURE__ */ ((PdfEngineFeature2) => {
PdfEngineFeature2[PdfEngineFeature2["RenderPage"] = 0] = "RenderPage";
PdfEngineFeature2[PdfEngineFeature2["RenderPageRect"] = 1] = "RenderPageRect";
PdfEngineFeature2[PdfEngineFeature2["Thumbnails"] = 2] = "Thumbnails";
PdfEngineFeature2[PdfEngineFeature2["Bookmarks"] = 3] = "Bookmarks";
PdfEngineFeature2[PdfEngineFeature2["Annotations"] = 4] = "Annotations";
return PdfEngineFeature2;
})(PdfEngineFeature || {});
var PdfEngineOperation = /* @__PURE__ */ ((PdfEngineOperation2) => {
PdfEngineOperation2[PdfEngineOperation2["Create"] = 0] = "Create";
PdfEngineOperation2[PdfEngineOperation2["Read"] = 1] = "Read";
PdfEngineOperation2[PdfEngineOperation2["Update"] = 2] = "Update";
PdfEngineOperation2[PdfEngineOperation2["Delete"] = 3] = "Delete";
return PdfEngineOperation2;
})(PdfEngineOperation || {});
var MatchFlag = /* @__PURE__ */ ((MatchFlag2) => {
MatchFlag2[MatchFlag2["None"] = 0] = "None";
MatchFlag2[MatchFlag2["MatchCase"] = 1] = "MatchCase";
MatchFlag2[MatchFlag2["MatchWholeWord"] = 2] = "MatchWholeWord";
MatchFlag2[MatchFlag2["MatchConsecutive"] = 4] = "MatchConsecutive";
return MatchFlag2;
})(MatchFlag || {});
function unionFlags(flags) {
return flags.reduce((flag, currFlag) => {
return flag | currFlag;
}, 0 /* None */);
}
function compareSearchTarget(targetA, targetB) {
const flagA = unionFlags(targetA.flags);
const flagB = unionFlags(targetB.flags);
return flagA === flagB && targetA.keyword === targetB.keyword;
}
var PdfPermission = /* @__PURE__ */ ((PdfPermission2) => {
PdfPermission2[PdfPermission2["PrintDocument"] = 8] = "PrintDocument";
PdfPermission2[PdfPermission2["ModifyContent"] = 16] = "ModifyContent";
PdfPermission2[PdfPermission2["CopyOrExtract"] = 32] = "CopyOrExtract";
PdfPermission2[PdfPermission2["AddOrModifyTextAnnot"] = 64] = "AddOrModifyTextAnnot";
PdfPermission2[PdfPermission2["FillInExistingForm"] = 512] = "FillInExistingForm";
PdfPermission2[PdfPermission2["ExtractTextOrGraphics"] = 1024] = "ExtractTextOrGraphics";
PdfPermission2[PdfPermission2["AssembleDocument"] = 2048] = "AssembleDocument";
PdfPermission2[PdfPermission2["PrintHighQuality"] = 4096] = "PrintHighQuality";
return PdfPermission2;
})(PdfPermission || {});
var PdfPageFlattenFlag = /* @__PURE__ */ ((PdfPageFlattenFlag2) => {
PdfPageFlattenFlag2[PdfPageFlattenFlag2["Display"] = 0] = "Display";
PdfPageFlattenFlag2[PdfPageFlattenFlag2["Print"] = 1] = "Print";
return PdfPageFlattenFlag2;
})(PdfPageFlattenFlag || {});
var PdfPageFlattenResult = /* @__PURE__ */ ((PdfPageFlattenResult2) => {
PdfPageFlattenResult2[PdfPageFlattenResult2["Fail"] = 0] = "Fail";
PdfPageFlattenResult2[PdfPageFlattenResult2["Success"] = 1] = "Success";
PdfPageFlattenResult2[PdfPageFlattenResult2["NothingToDo"] = 2] = "NothingToDo";
return PdfPageFlattenResult2;
})(PdfPageFlattenResult || {});
var PdfErrorCode = /* @__PURE__ */ ((PdfErrorCode2) => {
PdfErrorCode2[PdfErrorCode2["Ok"] = 0] = "Ok";
PdfErrorCode2[PdfErrorCode2["Unknown"] = 1] = "Unknown";
PdfErrorCode2[PdfErrorCode2["NotFound"] = 2] = "NotFound";
PdfErrorCode2[PdfErrorCode2["WrongFormat"] = 3] = "WrongFormat";
PdfErrorCode2[PdfErrorCode2["Password"] = 4] = "Password";
PdfErrorCode2[PdfErrorCode2["Security"] = 5] = "Security";
PdfErrorCode2[PdfErrorCode2["PageError"] = 6] = "PageError";
PdfErrorCode2[PdfErrorCode2["XFALoad"] = 7] = "XFALoad";
PdfErrorCode2[PdfErrorCode2["XFALayout"] = 8] = "XFALayout";
PdfErrorCode2[PdfErrorCode2["Cancelled"] = 9] = "Cancelled";
PdfErrorCode2[PdfErrorCode2["Initialization"] = 10] = "Initialization";
PdfErrorCode2[PdfErrorCode2["NotReady"] = 11] = "NotReady";
PdfErrorCode2[PdfErrorCode2["NotSupport"] = 12] = "NotSupport";
PdfErrorCode2[PdfErrorCode2["LoadDoc"] = 13] = "LoadDoc";
PdfErrorCode2[PdfErrorCode2["DocNotOpen"] = 14] = "DocNotOpen";
PdfErrorCode2[PdfErrorCode2["CantCloseDoc"] = 15] = "CantCloseDoc";
PdfErrorCode2[PdfErrorCode2["CantCreateNewDoc"] = 16] = "CantCreateNewDoc";
PdfErrorCode2[PdfErrorCode2["CantImportPages"] = 17] = "CantImportPages";
PdfErrorCode2[PdfErrorCode2["CantCreateAnnot"] = 18] = "CantCreateAnnot";
PdfErrorCode2[PdfErrorCode2["CantSetAnnotRect"] = 19] = "CantSetAnnotRect";
PdfErrorCode2[PdfErrorCode2["CantSetAnnotContent"] = 20] = "CantSetAnnotContent";
PdfErrorCode2[PdfErrorCode2["CantRemoveInkList"] = 21] = "CantRemoveInkList";
PdfErrorCode2[PdfErrorCode2["CantAddInkStoke"] = 22] = "CantAddInkStoke";
PdfErrorCode2[PdfErrorCode2["CantReadAttachmentSize"] = 23] = "CantReadAttachmentSize";
PdfErrorCode2[PdfErrorCode2["CantReadAttachmentContent"] = 24] = "CantReadAttachmentContent";
PdfErrorCode2[PdfErrorCode2["CantFocusAnnot"] = 25] = "CantFocusAnnot";
PdfErrorCode2[PdfErrorCode2["CantSelectText"] = 26] = "CantSelectText";
PdfErrorCode2[PdfErrorCode2["CantSelectOption"] = 27] = "CantSelectOption";
PdfErrorCode2[PdfErrorCode2["CantCheckField"] = 28] = "CantCheckField";
return PdfErrorCode2;
})(PdfErrorCode || {});
var PdfTaskHelper = class {
/**
* Create a task
* @returns new task
*/
static create() {
return new Task();
}
/**
* Create a task that has been resolved with value
* @param result - resolved value
* @returns resolved task
*/
static resolve(result) {
const task = new Task();
task.resolve(result);
return task;
}
/**
* Create a task that has been rejected with error
* @param reason - rejected error
* @returns rejected task
*/
static reject(reason) {
const task = new Task();
task.reject(reason);
return task;
}
/**
* Create a task that has been aborted with error
* @param reason - aborted error
* @returns aborted task
*/
static abort(reason) {
const task = new Task();
task.reject(reason);
return task;
}
};
// src/color.ts
function pdfAlphaColorToWebAlphaColor(c) {
const clamp = (n) => Math.max(0, Math.min(255, n));
const toHex = (n) => clamp(n).toString(16).padStart(2, "0");
const color = `#${toHex(c.red)}${toHex(c.green)}${toHex(c.blue)}`;
const opacity = clamp(c.alpha) / 255;
return { color, opacity };
}
function webAlphaColorToPdfAlphaColor({ color, opacity }) {
if (/^#?[0-9a-f]{3}$/i.test(color)) {
color = color.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i, "#$1$1$2$2$3$3").toLowerCase();
}
const [, r, g, b] = /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(color) ?? (() => {
throw new Error(`Invalid hex colour: \u201C${color}\u201D`);
})();
const clamp = (n, hi = 255) => Math.max(0, Math.min(hi, n));
return {
red: parseInt(r, 16),
green: parseInt(g, 16),
blue: parseInt(b, 16),
alpha: clamp(Math.round(opacity * 255))
};
}
// src/date.ts
function pdfDateToDate(pdf) {
if (!pdf?.startsWith("D:") || pdf.length < 16) return;
const y = +pdf.slice(2, 6);
const mo = +pdf.slice(6, 8) - 1;
const d = +pdf.slice(8, 10);
const H = +pdf.slice(10, 12);
const M = +pdf.slice(12, 14);
const S = +pdf.slice(14, 16);
return new Date(Date.UTC(y, mo, d, H, M, S));
}
function dateToPdfDate(date = /* @__PURE__ */ new Date()) {
const z = (n, len = 2) => n.toString().padStart(len, "0");
const YYYY = date.getUTCFullYear();
const MM = z(date.getUTCMonth() + 1);
const DD = z(date.getUTCDate());
const HH = z(date.getUTCHours());
const mm = z(date.getUTCMinutes());
const SS = z(date.getUTCSeconds());
return `D:${YYYY}${MM}${DD}${HH}${mm}${SS}`;
}
// src/index.ts
function ignore() {
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
AllLogger,
AppearanceMode,
ConsoleLogger,
LevelLogger,
LogLevel,
MatchFlag,
NoopLogger,
PDF_FORM_FIELD_FLAG,
PDF_FORM_FIELD_TYPE,
PdfActionType,
PdfAnnotationBorderStyle,
PdfAnnotationColorType,
PdfAnnotationFlagName,
PdfAnnotationFlags,
PdfAnnotationObjectStatus,
PdfAnnotationState,
PdfAnnotationStateModel,
PdfAnnotationSubtype,
PdfAnnotationSubtypeName,
PdfBomOrZwnbsp,
PdfEngineFeature,
PdfEngineOperation,
PdfErrorCode,
PdfNonCharacterFFFE,
PdfNonCharacterFFFF,
PdfPageFlattenFlag,
PdfPageFlattenResult,
PdfPageObjectType,
PdfPermission,
PdfSegmentObjectType,
PdfSoftHyphenMarker,
PdfTaskHelper,
PdfUnwantedTextMarkers,
PdfUnwantedTextRegex,
PdfWordJoiner,
PdfZeroWidthSpace,
PdfZoomMode,
PerfLogger,
Rotation,
Task,
TaskAbortedError,
TaskRejectedError,
TaskStage,
boundingRect,
calculateAngle,
calculateDegree,
compareSearchTarget,
dateToPdfDate,
flagsToNames,
ignore,
makeMatrix,
namesToFlags,
pdfAlphaColorToWebAlphaColor,
pdfDateToDate,
quadToRect,
rectToQuad,
restoreOffset,
restorePosition,
restoreRect,
rotatePosition,
rotateRect,
scalePosition,
scaleRect,
stripPdfUnwantedMarkers,
swap,
toIntPos,
toIntRect,
toIntSize,
transformPosition,
transformRect,
transformSize,
unionFlags,
webAlphaColorToPdfAlphaColor
});
//# sourceMappingURL=index.cjs.map
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=(e=>(e[e.Degree0=0]="Degree0",e[e.Degree90=1]="Degree90",e[e.Degree180=2]="Degree180",e[e.Degree270=3]="Degree270",e))(e||{});function t(e){return{x:Math.floor(e.x),y:Math.floor(e.y)}}function r(e){return{width:Math.ceil(e.width),height:Math.ceil(e.height)}}function o(e){switch(e){case 0:return 0;case 1:return 90;case 2:return 180;case 3:return 270}}function n(e){const{width:t,height:r}=e;return{width:r,height:t}}function s(e,t,r){let o=t.x,n=t.y;switch(r){case 0:o=t.x,n=t.y;break;case 1:o=e.height-t.y,n=t.x;break;case 2:o=e.width-t.x,n=e.height-t.y;break;case 3:o=t.y,n=e.width-t.x}return{x:o,y:n}}function a(e,t){return{x:e.x*t,y:e.y*t}}function i(e,t,r){let o=t.origin.x,s=t.origin.y,a=t.size;switch(r){case 0:break;case 1:o=e.height-t.origin.y-t.size.height,s=t.origin.x,a=n(t.size);break;case 2:o=e.width-t.origin.x-t.size.width,s=e.height-t.origin.y-t.size.height;break;case 3:o=t.origin.y,s=e.width-t.origin.x-t.size.width,a=n(t.size)}return{origin:{x:o,y:s},size:{width:a.width,height:a.height}}}function c(e,t){return{origin:{x:e.origin.x*t,y:e.origin.y*t},size:{width:e.size.width*t,height:e.size.height*t}}}var l=(e=>(e[e.Debug=0]="Debug",e[e.Info=1]="Info",e[e.Warn=2]="Warn",e[e.Error=3]="Error",e))(l||{});var d=(e=>(e[e.Pending=0]="Pending",e[e.Resolved=1]="Resolved",e[e.Rejected=2]="Rejected",e[e.Aborted=3]="Aborted",e))(d||{});class h extends Error{constructor(e){super(`Task aborted: ${JSON.stringify(e)}`),this.name="TaskAbortedError"}}class g extends Error{constructor(e){super(`Task rejected: ${JSON.stringify(e)}`),this.name="TaskRejectedError"}}class u{constructor(){this.state={stage:0},this.resolvedCallbacks=[],this.rejectedCallbacks=[],this._promise=null}toPromise(){return this._promise||(this._promise=new Promise(((e,t)=>{this.wait((t=>e(t)),(e=>{"abort"===e.type?t(new h(e.reason)):t(new g(e.reason))}))}))),this._promise}wait(e,t){switch(this.state.stage){case 0:this.resolvedCallbacks.push(e),this.rejectedCallbacks.push(t);break;case 1:e(this.state.result);break;case 2:t({type:"reject",reason:this.state.reason});break;case 3:t({type:"abort",reason:this.state.reason})}}resolve(e){if(0===this.state.stage){this.state={stage:1,result:e};for(const r of this.resolvedCallbacks)try{r(e)}catch(t){}this.resolvedCallbacks=[],this.rejectedCallbacks=[]}}reject(e){if(0===this.state.stage){this.state={stage:2,reason:e};for(const r of this.rejectedCallbacks)try{r({type:"reject",reason:e})}catch(t){}this.resolvedCallbacks=[],this.rejectedCallbacks=[]}}abort(e){if(0===this.state.stage){this.state={stage:3,reason:e};for(const r of this.rejectedCallbacks)try{r({type:"abort",reason:e})}catch(t){}this.resolvedCallbacks=[],this.rejectedCallbacks=[]}}fail(e){"abort"===e.type?this.abort(e.reason):this.reject(e.reason)}static all(e){const t=new u;if(0===e.length)return t.resolve([]),t;const r=new Array(e.length);let o=0,n=!1;return e.forEach(((s,a)=>{s.wait((s=>{n||(r[a]=s,o++,o===e.length&&(n=!0,t.resolve(r)))}),(e=>{n||(n=!0,"abort"===e.type?t.abort(e.reason):t.reject(e.reason))}))})),t}static allSettled(e){const t=new u;if(0===e.length)return t.resolve([]),t;const r=new Array(e.length);let o=0;return e.forEach(((n,s)=>{n.wait((n=>{r[s]={status:"resolved",value:n},o++,o===e.length&&t.resolve(r)}),(n=>{r[s]={status:"abort"===n.type?"aborted":"rejected",reason:n.reason},o++,o===e.length&&t.resolve(r)}))})),t}static race(e){const t=new u;if(0===e.length)return t.reject("No tasks provided"),t;let r=!1;return e.forEach((e=>{e.wait((e=>{r||(r=!0,t.resolve(e))}),(e=>{r||(r=!0,"abort"===e.type?t.abort(e.reason):t.reject(e.reason))}))})),t}static withProgress(e,t){const r=u.all(e);if(t){let r=0;e.forEach((o=>{o.wait((()=>{r++,t(r,e.length)}),(()=>{r++,t(r,e.length)}))}))}return r}}const p=Object.freeze(["­","​","⁠","\ufeff","￾","￿"]),f=new RegExp(`[${p.join("")}]`,"g");var E=(e=>(e[e.Unknown=0]="Unknown",e[e.XYZ=1]="XYZ",e[e.FitPage=2]="FitPage",e[e.FitHorizontal=3]="FitHorizontal",e[e.FitVertical=4]="FitVertical",e[e.FitRectangle=5]="FitRectangle",e))(E||{}),x=(e=>(e[e.Normal=0]="Normal",e[e.Multiply=1]="Multiply",e[e.Screen=2]="Screen",e[e.Overlay=3]="Overlay",e[e.Darken=4]="Darken",e[e.Lighten=5]="Lighten",e[e.ColorDodge=6]="ColorDodge",e[e.ColorBurn=7]="ColorBurn",e[e.HardLight=8]="HardLight",e[e.SoftLight=9]="SoftLight",e[e.Difference=10]="Difference",e[e.Exclusion=11]="Exclusion",e[e.Hue=12]="Hue",e[e.Saturation=13]="Saturation",e[e.Color=14]="Color",e[e.Luminosity=15]="Luminosity",e))(x||{});const T=Symbol("mixed"),C=Object.freeze([{id:0,label:"Normal",css:"normal"},{id:1,label:"Multiply",css:"multiply"},{id:2,label:"Screen",css:"screen"},{id:3,label:"Overlay",css:"overlay"},{id:4,label:"Darken",css:"darken"},{id:5,label:"Lighten",css:"lighten"},{id:6,label:"Color Dodge",css:"color-dodge"},{id:7,label:"Color Burn",css:"color-burn"},{id:8,label:"Hard Light",css:"hard-light"},{id:9,label:"Soft Light",css:"soft-light"},{id:10,label:"Difference",css:"difference"},{id:11,label:"Exclusion",css:"exclusion"},{id:12,label:"Hue",css:"hue"},{id:13,label:"Saturation",css:"saturation"},{id:14,label:"Color",css:"color"},{id:15,label:"Luminosity",css:"luminosity"}]),O=C.reduce(((e,t)=>(e[t.id]=t,e)),{}),N=C.reduce(((e,t)=>(e[t.css]=t.id,e)),{});function I(e){return O[e]??O[0]}function A(e){return I(e).label}const R=C.map((e=>({value:e.id,label:e.label})));var b=(e=>(e[e.Unsupported=0]="Unsupported",e[e.Goto=1]="Goto",e[e.RemoteGoto=2]="RemoteGoto",e[e.URI=3]="URI",e[e.LaunchAppOrOpenFile=4]="LaunchAppOrOpenFile",e))(b||{}),y=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.TEXT=1]="TEXT",e[e.LINK=2]="LINK",e[e.FREETEXT=3]="FREETEXT",e[e.LINE=4]="LINE",e[e.SQUARE=5]="SQUARE",e[e.CIRCLE=6]="CIRCLE",e[e.POLYGON=7]="POLYGON",e[e.POLYLINE=8]="POLYLINE",e[e.HIGHLIGHT=9]="HIGHLIGHT",e[e.UNDERLINE=10]="UNDERLINE",e[e.SQUIGGLY=11]="SQUIGGLY",e[e.STRIKEOUT=12]="STRIKEOUT",e[e.STAMP=13]="STAMP",e[e.CARET=14]="CARET",e[e.INK=15]="INK",e[e.POPUP=16]="POPUP",e[e.FILEATTACHMENT=17]="FILEATTACHMENT",e[e.SOUND=18]="SOUND",e[e.MOVIE=19]="MOVIE",e[e.WIDGET=20]="WIDGET",e[e.SCREEN=21]="SCREEN",e[e.PRINTERMARK=22]="PRINTERMARK",e[e.TRAPNET=23]="TRAPNET",e[e.WATERMARK=24]="WATERMARK",e[e.THREED=25]="THREED",e[e.RICHMEDIA=26]="RICHMEDIA",e[e.XFAWIDGET=27]="XFAWIDGET",e[e.REDACT=28]="REDACT",e))(y||{});const D={0:"unknow",1:"text",2:"link",3:"freetext",4:"line",5:"square",6:"circle",7:"polygon",8:"polyline",9:"highlight",10:"underline",11:"squiggly",12:"strikeout",13:"stamp",14:"caret",15:"ink",16:"popup",17:"fileattachment",18:"sound",19:"movie",20:"widget",21:"screen",22:"printermark",23:"trapnet",24:"watermark",25:"threed",26:"richmedia",27:"xfawidget",28:"redact"};var P=(e=>(e[e.Created=0]="Created",e[e.Committed=1]="Committed",e))(P||{}),m=(e=>(e[e.Normal=0]="Normal",e[e.Rollover=1]="Rollover",e[e.Down=2]="Down",e))(m||{}),w=(e=>(e.Marked="Marked",e.Unmarked="Unmarked",e.Accepted="Accepted",e.Rejected="Rejected",e.Complete="Complete",e.Cancelled="Cancelled",e.None="None",e))(w||{}),L=(e=>(e.Marked="Marked",e.Reviewed="Reviewed",e))(L||{}),M=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.PUSHBUTTON=1]="PUSHBUTTON",e[e.CHECKBOX=2]="CHECKBOX",e[e.RADIOBUTTON=3]="RADIOBUTTON",e[e.COMBOBOX=4]="COMBOBOX",e[e.LISTBOX=5]="LISTBOX",e[e.TEXTFIELD=6]="TEXTFIELD",e[e.SIGNATURE=7]="SIGNATURE",e[e.XFA=8]="XFA",e[e.XFA_CHECKBOX=9]="XFA_CHECKBOX",e[e.XFA_COMBOBOX=10]="XFA_COMBOBOX",e[e.XFA_IMAGEFIELD=11]="XFA_IMAGEFIELD",e[e.XFA_LISTBOX=12]="XFA_LISTBOX",e[e.XFA_PUSHBUTTON=13]="XFA_PUSHBUTTON",e[e.XFA_SIGNATURE=14]="XFA_SIGNATURE",e[e.XFA_TEXTFIELD=15]="XFA_TEXTFIELD",e))(M||{}),S=(e=>(e[e.Color=0]="Color",e[e.InteriorColor=1]="InteriorColor",e))(S||{}),F=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.SOLID=1]="SOLID",e[e.DASHED=2]="DASHED",e[e.BEVELED=3]="BEVELED",e[e.INSET=4]="INSET",e[e.UNDERLINE=5]="UNDERLINE",e[e.CLOUDY=6]="CLOUDY",e))(F||{}),k=(e=>(e[e.NONE=0]="NONE",e[e.INVISIBLE=1]="INVISIBLE",e[e.HIDDEN=2]="HIDDEN",e[e.PRINT=4]="PRINT",e[e.NO_ZOOM=8]="NO_ZOOM",e[e.NO_ROTATE=16]="NO_ROTATE",e[e.NO_VIEW=32]="NO_VIEW",e[e.READ_ONLY=64]="READ_ONLY",e[e.LOCKED=128]="LOCKED",e[e.TOGGLE_NOVIEW=256]="TOGGLE_NOVIEW",e))(k||{}),U=(e=>(e[e.NONE=0]="NONE",e[e.READONLY=1]="READONLY",e[e.REQUIRED=2]="REQUIRED",e[e.NOEXPORT=4]="NOEXPORT",e[e.TEXT_MULTIPLINE=4096]="TEXT_MULTIPLINE",e[e.TEXT_PASSWORD=8192]="TEXT_PASSWORD",e[e.CHOICE_COMBO=131072]="CHOICE_COMBO",e[e.CHOICE_EDIT=262144]="CHOICE_EDIT",e[e.CHOICE_MULTL_SELECT=2097152]="CHOICE_MULTL_SELECT",e))(U||{}),$=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.TEXT=1]="TEXT",e[e.PATH=2]="PATH",e[e.IMAGE=3]="IMAGE",e[e.SHADING=4]="SHADING",e[e.FORM=5]="FORM",e))($||{});const v=Object.freeze({1:"invisible",2:"hidden",4:"print",8:"noZoom",16:"noRotate",32:"noView",64:"readOnly",128:"locked",256:"toggleNoView"}),X=Object.entries(v).reduce(((e,[t,r])=>(e[r]=Number(t),e)),{});var H=(e=>(e[e.UNKNOWN=-1]="UNKNOWN",e[e.LINETO=0]="LINETO",e[e.BEZIERTO=1]="BEZIERTO",e[e.MOVETO=2]="MOVETO",e))(H||{}),_=(e=>(e[e.RenderPage=0]="RenderPage",e[e.RenderPageRect=1]="RenderPageRect",e[e.Thumbnails=2]="Thumbnails",e[e.Bookmarks=3]="Bookmarks",e[e.Annotations=4]="Annotations",e))(_||{}),B=(e=>(e[e.Create=0]="Create",e[e.Read=1]="Read",e[e.Update=2]="Update",e[e.Delete=3]="Delete",e))(B||{}),j=(e=>(e[e.None=0]="None",e[e.MatchCase=1]="MatchCase",e[e.MatchWholeWord=2]="MatchWholeWord",e[e.MatchConsecutive=4]="MatchConsecutive",e))(j||{});function z(e){return e.reduce(((e,t)=>e|t),0)}var G=(e=>(e[e.PrintDocument=8]="PrintDocument",e[e.ModifyContent=16]="ModifyContent",e[e.CopyOrExtract=32]="CopyOrExtract",e[e.AddOrModifyTextAnnot=64]="AddOrModifyTextAnnot",e[e.FillInExistingForm=512]="FillInExistingForm",e[e.ExtractTextOrGraphics=1024]="ExtractTextOrGraphics",e[e.AssembleDocument=2048]="AssembleDocument",e[e.PrintHighQuality=4096]="PrintHighQuality",e))(G||{}),W=(e=>(e[e.Display=0]="Display",e[e.Print=1]="Print",e))(W||{}),K=(e=>(e[e.Fail=0]="Fail",e[e.Success=1]="Success",e[e.NothingToDo=2]="NothingToDo",e))(K||{}),V=(e=>(e[e.Ok=0]="Ok",e[e.Unknown=1]="Unknown",e[e.NotFound=2]="NotFound",e[e.WrongFormat=3]="WrongFormat",e[e.Password=4]="Password",e[e.Security=5]="Security",e[e.PageError=6]="PageError",e[e.XFALoad=7]="XFALoad",e[e.XFALayout=8]="XFALayout",e[e.Cancelled=9]="Cancelled",e[e.Initialization=10]="Initialization",e[e.NotReady=11]="NotReady",e[e.NotSupport=12]="NotSupport",e[e.LoadDoc=13]="LoadDoc",e[e.DocNotOpen=14]="DocNotOpen",e[e.CantCloseDoc=15]="CantCloseDoc",e[e.CantCreateNewDoc=16]="CantCreateNewDoc",e[e.CantImportPages=17]="CantImportPages",e[e.CantCreateAnnot=18]="CantCreateAnnot",e[e.CantSetAnnotRect=19]="CantSetAnnotRect",e[e.CantSetAnnotContent=20]="CantSetAnnotContent",e[e.CantRemoveInkList=21]="CantRemoveInkList",e[e.CantAddInkStoke=22]="CantAddInkStoke",e[e.CantReadAttachmentSize=23]="CantReadAttachmentSize",e[e.CantReadAttachmentContent=24]="CantReadAttachmentContent",e[e.CantFocusAnnot=25]="CantFocusAnnot",e[e.CantSelectText=26]="CantSelectText",e[e.CantSelectOption=27]="CantSelectOption",e[e.CantCheckField=28]="CantCheckField",e))(V||{});exports.AllLogger=class{constructor(e){this.loggers=e}debug(e,t,...r){for(const o of this.loggers)o.debug(e,t,...r)}info(e,t,...r){for(const o of this.loggers)o.info(e,t,...r)}warn(e,t,...r){for(const o of this.loggers)o.warn(e,t,...r)}error(e,t,...r){for(const o of this.loggers)o.error(e,t,...r)}perf(e,t,r,o,...n){for(const s of this.loggers)s.perf(e,t,r,o,...n)}},exports.AppearanceMode=m,exports.ConsoleLogger=class{debug(e,t,...r){console.debug(`${e}.${t}`,...r)}info(e,t,...r){console.info(`${e}.${t}`,...r)}warn(e,t,...r){console.warn(`${e}.${t}`,...r)}error(e,t,...r){console.error(`${e}.${t}`,...r)}perf(e,t,r,o,...n){console.info(`${e}.${t}.${r}.${o}`,...n)}},exports.LevelLogger=class{constructor(e,t){this.logger=e,this.level=t}debug(e,t,...r){this.level<=0&&this.logger.debug(e,t,...r)}info(e,t,...r){this.level<=1&&this.logger.info(e,t,...r)}warn(e,t,...r){this.level<=2&&this.logger.warn(e,t,...r)}error(e,t,...r){this.level<=3&&this.logger.error(e,t,...r)}perf(e,t,r,o,...n){this.logger.perf(e,t,r,o,...n)}},exports.LogLevel=l,exports.MatchFlag=j,exports.MixedBlendMode=T,exports.NoopLogger=class{debug(){}info(){}warn(){}error(){}perf(){}},exports.PDF_FORM_FIELD_FLAG=U,exports.PDF_FORM_FIELD_TYPE=M,exports.PdfActionType=b,exports.PdfAnnotationBorderStyle=F,exports.PdfAnnotationColorType=S,exports.PdfAnnotationFlagName=v,exports.PdfAnnotationFlags=k,exports.PdfAnnotationObjectStatus=P,exports.PdfAnnotationState=w,exports.PdfAnnotationStateModel=L,exports.PdfAnnotationSubtype=y,exports.PdfAnnotationSubtypeName=D,exports.PdfBlendMode=x,exports.PdfBomOrZwnbsp="\ufeff",exports.PdfEngineFeature=_,exports.PdfEngineOperation=B,exports.PdfErrorCode=V,exports.PdfNonCharacterFFFE="￾",exports.PdfNonCharacterFFFF="￿",exports.PdfPageFlattenFlag=W,exports.PdfPageFlattenResult=K,exports.PdfPageObjectType=$,exports.PdfPermission=G,exports.PdfSegmentObjectType=H,exports.PdfSoftHyphenMarker="­",exports.PdfTaskHelper=class{static create(){return new u}static resolve(e){const t=new u;return t.resolve(e),t}static reject(e){const t=new u;return t.reject(e),t}static abort(e){const t=new u;return t.reject(e),t}},exports.PdfUnwantedTextMarkers=p,exports.PdfUnwantedTextRegex=f,exports.PdfWordJoiner="⁠",exports.PdfZeroWidthSpace="​",exports.PdfZoomMode=E,exports.PerfLogger=class{constructor(){}debug(e,t,...r){}info(e,t,...r){}warn(e,t,...r){}error(e,t,...r){}perf(e,t,r,o,n,...s){switch(o){case"Begin":window.performance.mark(`${e}.${t}.${r}.${o}.${n}`,{detail:s});break;case"End":window.performance.mark(`${e}.${t}.${r}.${o}.${n}`,{detail:s}),window.performance.measure(`${e}.${t}.${r}.Measure.${n}`,`${e}.${t}.${r}.Begin.${n}`,`${e}.${t}.${r}.End.${n}`)}}},exports.Rotation=e,exports.Task=u,exports.TaskAbortedError=h,exports.TaskRejectedError=g,exports.TaskStage=d,exports.blendModeLabel=A,exports.blendModeSelectOptions=R,exports.blendModeToCss=function(e){return I(e).css},exports.boundingRect=function(e){if(0===e.length)return null;let t=e[0].origin.x,r=e[0].origin.y,o=e[0].origin.x+e[0].size.width,n=e[0].origin.y+e[0].size.height;for(const s of e)t=Math.min(t,s.origin.x),r=Math.min(r,s.origin.y),o=Math.max(o,s.origin.x+s.size.width),n=Math.max(n,s.origin.y+s.size.height);return{origin:{x:t,y:r},size:{width:o-t,height:n-r}}},exports.calculateAngle=function(e){return o(e)*Math.PI/180},exports.calculateDegree=o,exports.compareSearchTarget=function(e,t){return z(e.flags)===z(t.flags)&&e.keyword===t.keyword},exports.cssToBlendMode=function(e){return N[e]},exports.dateToPdfDate=function(e=new Date){const t=(e,t=2)=>e.toString().padStart(t,"0");return`D:${e.getUTCFullYear()}${t(e.getUTCMonth()+1)}${t(e.getUTCDate())}${t(e.getUTCHours())}${t(e.getUTCMinutes())}${t(e.getUTCSeconds())}`},exports.flagsToNames=function(e){return Object.keys(v).filter((t=>!!(e&t))).map((e=>v[e]))},exports.getBlendModeInfo=I,exports.ignore=function(){},exports.makeMatrix=(e,t,r)=>{const{width:o,height:n}=e.size;switch(t){case 0:return{a:r,b:0,c:0,d:-r,e:0,f:n*r};case 1:return{a:0,b:r,c:r,d:0,e:0,f:0};case 2:return{a:-r,b:0,c:0,d:r,e:o*r,f:0};case 3:return{a:0,b:-r,c:-r,d:0,e:n*r,f:o*r}}},exports.namesToFlags=function(e){return e.reduce(((e,t)=>e|X[t]),0)},exports.pdfAlphaColorToWebAlphaColor=function(e){const t=e=>Math.max(0,Math.min(255,e)),r=e=>t(e).toString(16).padStart(2,"0");return{color:`#${r(e.red)}${r(e.green)}${r(e.blue)}`,opacity:t(e.alpha)/255}},exports.pdfDateToDate=function(e){if(!(null==e?void 0:e.startsWith("D:"))||e.length<16)return;const t=+e.slice(2,6),r=+e.slice(6,8)-1,o=+e.slice(8,10),n=+e.slice(10,12),s=+e.slice(12,14),a=+e.slice(14,16);return new Date(Date.UTC(t,r,o,n,s,a))},exports.quadToRect=function(e){const t=[e.p1.x,e.p2.x,e.p3.x,e.p4.x],r=[e.p1.y,e.p2.y,e.p3.y,e.p4.y];return{origin:{x:Math.min(...t),y:Math.min(...r)},size:{width:Math.max(...t)-Math.min(...t),height:Math.max(...r)-Math.min(...r)}}},exports.rectToQuad=function(e){return{p1:{x:e.origin.x,y:e.origin.y},p2:{x:e.origin.x+e.size.width,y:e.origin.y},p3:{x:e.origin.x+e.size.width,y:e.origin.y+e.size.height},p4:{x:e.origin.x,y:e.origin.y+e.size.height}}},exports.reduceBlendModes=function(e){if(!e.length)return 0;const t=e[0];return e.every((e=>e===t))?t:T},exports.restoreOffset=function(e,t,r){let o=e.x,n=e.y;switch(t){case 0:o=e.x/r,n=e.y/r;break;case 1:o=e.y/r,n=-e.x/r;break;case 2:o=-e.x/r,n=-e.y/r;break;case 3:o=-e.y/r,n=e.x/r}return{x:o,y:n}},exports.restorePosition=function(e,t,r,o){return a(s(e,t,(4-r)%4),1/o)},exports.restoreRect=function(e,t,r,o){return c(i(e,t,(4-r)%4),1/o)},exports.rotatePosition=s,exports.rotateRect=i,exports.scalePosition=a,exports.scaleRect=c,exports.stripPdfUnwantedMarkers=function(e){return e.replace(f,"")},exports.swap=n,exports.toIntPos=t,exports.toIntRect=function(e){return{origin:t(e.origin),size:r(e.size)}},exports.toIntSize=r,exports.transformPosition=function(e,t,r,o){return a(s(e,t,r),o)},exports.transformRect=function(e,t,r,o){return c(i(e,t,r),o)},exports.transformSize=function(e,t,r){return{width:(e=t%2==0?e:n(e)).width*r,height:e.height*r}},exports.uiBlendModeDisplay=function(e){return e===T?"(mixed)":A(e)},exports.unionFlags=z,exports.webAlphaColorToPdfAlphaColor=function({color:e,opacity:t}){/^#?[0-9a-f]{3}$/i.test(e)&&(e=e.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i,"#$1$1$2$2$3$3").toLowerCase());const[,r,o,n]=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e)??(()=>{throw new Error(`Invalid hex colour: “${e}”`)})();return{red:parseInt(r,16),green:parseInt(o,16),blue:parseInt(n,16),alpha:((e,t=255)=>Math.max(0,Math.min(t,e)))(Math.round(255*t))}};
//# sourceMappingURL=index.cjs.map

@@ -1,2 +0,1 @@

// src/geometry.ts
var Rotation = /* @__PURE__ */ ((Rotation2) => {

@@ -23,9 +22,9 @@ Rotation2[Rotation2["Degree0"] = 0] = "Degree0";

switch (rotation) {
case 0 /* Degree0 */:
case 0:
return 0;
case 1 /* Degree90 */:
case 1:
return 90;
case 2 /* Degree180 */:
case 2:
return 180;
case 3 /* Degree270 */:
case 3:
return 270;

@@ -74,15 +73,15 @@ }

switch (rotation) {
case 0 /* Degree0 */:
case 0:
x = position.x;
y = position.y;
break;
case 1 /* Degree90 */:
case 1:
x = containerSize.height - position.y;
y = position.x;
break;
case 2 /* Degree180 */:
case 2:
x = containerSize.width - position.x;
y = containerSize.height - position.y;
break;
case 3 /* Degree270 */:
case 3:
x = position.y;

@@ -117,5 +116,5 @@ y = containerSize.width - position.x;

switch (rotation) {
case 0 /* Degree0 */:
case 0:
break;
case 1 /* Degree90 */:
case 1:
x = containerSize.height - rect.origin.y - rect.size.height;

@@ -125,7 +124,7 @@ y = rect.origin.x;

break;
case 2 /* Degree180 */:
case 2:
x = containerSize.width - rect.origin.x - rect.size.width;
y = containerSize.height - rect.origin.y - rect.size.height;
break;
case 3 /* Degree270 */:
case 3:
x = rect.origin.y;

@@ -169,15 +168,15 @@ y = containerSize.width - rect.origin.x - rect.size.width;

switch (rotation) {
case 0 /* Degree0 */:
case 0:
offsetX = offset.x / scaleFactor;
offsetY = offset.y / scaleFactor;
break;
case 1 /* Degree90 */:
case 1:
offsetX = offset.y / scaleFactor;
offsetY = -offset.x / scaleFactor;
break;
case 2 /* Degree180 */:
case 2:
offsetX = -offset.x / scaleFactor;
offsetY = -offset.y / scaleFactor;
break;
case 3 /* Degree270 */:
case 3:
offsetX = -offset.y / scaleFactor;

@@ -212,6 +211,6 @@ offsetY = offset.x / scaleFactor;

}
var makeMatrix = (rectangle, rotation, scaleFactor) => {
const makeMatrix = (rectangle, rotation, scaleFactor) => {
const { width, height } = rectangle.size;
switch (rotation) {
case 0 /* Degree0 */:
case 0:
return {

@@ -225,3 +224,3 @@ a: scaleFactor,

};
case 1 /* Degree90 */:
case 1:
return {

@@ -235,3 +234,3 @@ a: 0,

};
case 2 /* Degree180 */:
case 2:
return {

@@ -245,3 +244,3 @@ a: -scaleFactor,

};
case 3 /* Degree270 */:
case 3:
return {

@@ -257,5 +256,3 @@ a: 0,

};
// src/logger.ts
var NoopLogger = class {
class NoopLogger {
/** {@inheritDoc Logger.debug} */

@@ -276,4 +273,4 @@ debug() {

}
};
var ConsoleLogger = class {
}
class ConsoleLogger {
/** {@inheritDoc Logger.debug} */

@@ -299,3 +296,3 @@ debug(source, category, ...args) {

}
};
}
var LogLevel = /* @__PURE__ */ ((LogLevel2) => {

@@ -308,3 +305,3 @@ LogLevel2[LogLevel2["Debug"] = 0] = "Debug";

})(LogLevel || {});
var LevelLogger = class {
class LevelLogger {
/**

@@ -321,3 +318,3 @@ * create new LevelLogger

debug(source, category, ...args) {
if (this.level <= 0 /* Debug */) {
if (this.level <= 0) {
this.logger.debug(source, category, ...args);

@@ -328,3 +325,3 @@ }

info(source, category, ...args) {
if (this.level <= 1 /* Info */) {
if (this.level <= 1) {
this.logger.info(source, category, ...args);

@@ -335,3 +332,3 @@ }

warn(source, category, ...args) {
if (this.level <= 2 /* Warn */) {
if (this.level <= 2) {
this.logger.warn(source, category, ...args);

@@ -342,3 +339,3 @@ }

error(source, category, ...args) {
if (this.level <= 3 /* Error */) {
if (this.level <= 3) {
this.logger.error(source, category, ...args);

@@ -351,4 +348,4 @@ }

}
};
var PerfLogger = class {
}
class PerfLogger {
/**

@@ -391,4 +388,4 @@ * create new PerfLogger

}
};
var AllLogger = class {
}
class AllLogger {
/**

@@ -430,5 +427,3 @@ * create new PerfLogger

}
};
// src/task.ts
}
var TaskStage = /* @__PURE__ */ ((TaskStage2) => {

@@ -441,3 +436,3 @@ TaskStage2[TaskStage2["Pending"] = 0] = "Pending";

})(TaskStage || {});
var TaskAbortedError = class extends Error {
class TaskAbortedError extends Error {
constructor(reason) {

@@ -447,4 +442,4 @@ super(`Task aborted: ${JSON.stringify(reason)}`);

}
};
var TaskRejectedError = class extends Error {
}
class TaskRejectedError extends Error {
constructor(reason) {

@@ -454,19 +449,11 @@ super(`Task rejected: ${JSON.stringify(reason)}`);

}
};
var Task = class _Task {
}
class Task {
constructor() {
this.state = {
stage: 0 /* Pending */
stage: 0
/* Pending */
};
/**
* callbacks that will be executed when task is resolved
*/
this.resolvedCallbacks = [];
/**
* callbacks that will be executed when task is rejected
*/
this.rejectedCallbacks = [];
/**
* Promise that will be resolved when task is settled
*/
this._promise = null;

@@ -502,10 +489,10 @@ }

switch (this.state.stage) {
case 0 /* Pending */:
case 0:
this.resolvedCallbacks.push(resolvedCallback);
this.rejectedCallbacks.push(rejectedCallback);
break;
case 1 /* Resolved */:
case 1:
resolvedCallback(this.state.result);
break;
case 2 /* Rejected */:
case 2:
rejectedCallback({

@@ -516,3 +503,3 @@ type: "reject",

break;
case 3 /* Aborted */:
case 3:
rejectedCallback({

@@ -530,5 +517,5 @@ type: "abort",

resolve(result) {
if (this.state.stage === 0 /* Pending */) {
if (this.state.stage === 0) {
this.state = {
stage: 1 /* Resolved */,
stage: 1,
result

@@ -552,5 +539,5 @@ };

reject(reason) {
if (this.state.stage === 0 /* Pending */) {
if (this.state.stage === 0) {
this.state = {
stage: 2 /* Rejected */,
stage: 2,
reason

@@ -576,5 +563,5 @@ };

abort(reason) {
if (this.state.stage === 0 /* Pending */) {
if (this.state.stage === 0) {
this.state = {
stage: 3 /* Aborted */,
stage: 3,
reason

@@ -617,3 +604,3 @@ };

static all(tasks) {
const combinedTask = new _Task();
const combinedTask = new Task();
if (tasks.length === 0) {

@@ -659,3 +646,3 @@ combinedTask.resolve([]);

static allSettled(tasks) {
const combinedTask = new _Task();
const combinedTask = new Task();
if (tasks.length === 0) {

@@ -698,3 +685,3 @@ combinedTask.resolve([]);

static race(tasks) {
const combinedTask = new _Task();
const combinedTask = new Task();
if (tasks.length === 0) {

@@ -734,3 +721,3 @@ combinedTask.reject("No tasks provided");

static withProgress(tasks, onProgress) {
const combinedTask = _Task.all(tasks);
const combinedTask = Task.all(tasks);
if (onProgress) {

@@ -753,12 +740,10 @@ let completedCount = 0;

}
};
// src/pdf.ts
var PdfSoftHyphenMarker = "\xAD";
var PdfZeroWidthSpace = "\u200B";
var PdfWordJoiner = "\u2060";
var PdfBomOrZwnbsp = "\uFEFF";
var PdfNonCharacterFFFE = "\uFFFE";
var PdfNonCharacterFFFF = "\uFFFF";
var PdfUnwantedTextMarkers = Object.freeze([
}
const PdfSoftHyphenMarker = "­";
const PdfZeroWidthSpace = "​";
const PdfWordJoiner = "⁠";
const PdfBomOrZwnbsp = "\uFEFF";
const PdfNonCharacterFFFE = "￾";
const PdfNonCharacterFFFF = "￿";
const PdfUnwantedTextMarkers = Object.freeze([
PdfSoftHyphenMarker,

@@ -771,3 +756,3 @@ PdfZeroWidthSpace,

]);
var PdfUnwantedTextRegex = new RegExp(`[${PdfUnwantedTextMarkers.join("")}]`, "g");
const PdfUnwantedTextRegex = new RegExp(`[${PdfUnwantedTextMarkers.join("")}]`, "g");
function stripPdfUnwantedMarkers(text) {

@@ -785,2 +770,81 @@ return text.replace(PdfUnwantedTextRegex, "");

})(PdfZoomMode || {});
var PdfBlendMode = /* @__PURE__ */ ((PdfBlendMode2) => {
PdfBlendMode2[PdfBlendMode2["Normal"] = 0] = "Normal";
PdfBlendMode2[PdfBlendMode2["Multiply"] = 1] = "Multiply";
PdfBlendMode2[PdfBlendMode2["Screen"] = 2] = "Screen";
PdfBlendMode2[PdfBlendMode2["Overlay"] = 3] = "Overlay";
PdfBlendMode2[PdfBlendMode2["Darken"] = 4] = "Darken";
PdfBlendMode2[PdfBlendMode2["Lighten"] = 5] = "Lighten";
PdfBlendMode2[PdfBlendMode2["ColorDodge"] = 6] = "ColorDodge";
PdfBlendMode2[PdfBlendMode2["ColorBurn"] = 7] = "ColorBurn";
PdfBlendMode2[PdfBlendMode2["HardLight"] = 8] = "HardLight";
PdfBlendMode2[PdfBlendMode2["SoftLight"] = 9] = "SoftLight";
PdfBlendMode2[PdfBlendMode2["Difference"] = 10] = "Difference";
PdfBlendMode2[PdfBlendMode2["Exclusion"] = 11] = "Exclusion";
PdfBlendMode2[PdfBlendMode2["Hue"] = 12] = "Hue";
PdfBlendMode2[PdfBlendMode2["Saturation"] = 13] = "Saturation";
PdfBlendMode2[PdfBlendMode2["Color"] = 14] = "Color";
PdfBlendMode2[PdfBlendMode2["Luminosity"] = 15] = "Luminosity";
return PdfBlendMode2;
})(PdfBlendMode || {});
const MixedBlendMode = Symbol("mixed");
const BLEND_MODE_INFOS = Object.freeze([
{ id: 0, label: "Normal", css: "normal" },
{ id: 1, label: "Multiply", css: "multiply" },
{ id: 2, label: "Screen", css: "screen" },
{ id: 3, label: "Overlay", css: "overlay" },
{ id: 4, label: "Darken", css: "darken" },
{ id: 5, label: "Lighten", css: "lighten" },
{ id: 6, label: "Color Dodge", css: "color-dodge" },
{ id: 7, label: "Color Burn", css: "color-burn" },
{ id: 8, label: "Hard Light", css: "hard-light" },
{ id: 9, label: "Soft Light", css: "soft-light" },
{ id: 10, label: "Difference", css: "difference" },
{ id: 11, label: "Exclusion", css: "exclusion" },
{ id: 12, label: "Hue", css: "hue" },
{ id: 13, label: "Saturation", css: "saturation" },
{ id: 14, label: "Color", css: "color" },
{ id: 15, label: "Luminosity", css: "luminosity" }
]);
const enumToInfo = BLEND_MODE_INFOS.reduce(
(m, info) => {
m[info.id] = info;
return m;
},
{}
);
const cssToEnum = BLEND_MODE_INFOS.reduce(
(m, info) => {
m[info.css] = info.id;
return m;
},
{}
);
function getBlendModeInfo(mode) {
return enumToInfo[mode] ?? enumToInfo[
0
/* Normal */
];
}
function blendModeToCss(mode) {
return getBlendModeInfo(mode).css;
}
function cssToBlendMode(value) {
return cssToEnum[value];
}
function blendModeLabel(mode) {
return getBlendModeInfo(mode).label;
}
function reduceBlendModes(modes) {
if (!modes.length) return 0;
const first = modes[0];
return modes.every((m) => m === first) ? first : MixedBlendMode;
}
const blendModeSelectOptions = BLEND_MODE_INFOS.map((info) => ({
value: info.id,
label: info.label
}));
function uiBlendModeDisplay(value) {
return value === MixedBlendMode ? "(mixed)" : blendModeLabel(value);
}
var PdfActionType = /* @__PURE__ */ ((PdfActionType2) => {

@@ -826,32 +890,119 @@ PdfActionType2[PdfActionType2["Unsupported"] = 0] = "Unsupported";

})(PdfAnnotationSubtype || {});
var PdfAnnotationSubtypeName = {
[0 /* UNKNOWN */]: "unknow",
[1 /* TEXT */]: "text",
[2 /* LINK */]: "link",
[3 /* FREETEXT */]: "freetext",
[4 /* LINE */]: "line",
[5 /* SQUARE */]: "square",
[6 /* CIRCLE */]: "circle",
[7 /* POLYGON */]: "polygon",
[8 /* POLYLINE */]: "polyline",
[9 /* HIGHLIGHT */]: "highlight",
[10 /* UNDERLINE */]: "underline",
[11 /* SQUIGGLY */]: "squiggly",
[12 /* STRIKEOUT */]: "strikeout",
[13 /* STAMP */]: "stamp",
[14 /* CARET */]: "caret",
[15 /* INK */]: "ink",
[16 /* POPUP */]: "popup",
[17 /* FILEATTACHMENT */]: "fileattachment",
[18 /* SOUND */]: "sound",
[19 /* MOVIE */]: "movie",
[20 /* WIDGET */]: "widget",
[21 /* SCREEN */]: "screen",
[22 /* PRINTERMARK */]: "printermark",
[23 /* TRAPNET */]: "trapnet",
[24 /* WATERMARK */]: "watermark",
[25 /* THREED */]: "threed",
[26 /* RICHMEDIA */]: "richmedia",
[27 /* XFAWIDGET */]: "xfawidget",
[28 /* REDACT */]: "redact"
const PdfAnnotationSubtypeName = {
[
0
/* UNKNOWN */
]: "unknow",
[
1
/* TEXT */
]: "text",
[
2
/* LINK */
]: "link",
[
3
/* FREETEXT */
]: "freetext",
[
4
/* LINE */
]: "line",
[
5
/* SQUARE */
]: "square",
[
6
/* CIRCLE */
]: "circle",
[
7
/* POLYGON */
]: "polygon",
[
8
/* POLYLINE */
]: "polyline",
[
9
/* HIGHLIGHT */
]: "highlight",
[
10
/* UNDERLINE */
]: "underline",
[
11
/* SQUIGGLY */
]: "squiggly",
[
12
/* STRIKEOUT */
]: "strikeout",
[
13
/* STAMP */
]: "stamp",
[
14
/* CARET */
]: "caret",
[
15
/* INK */
]: "ink",
[
16
/* POPUP */
]: "popup",
[
17
/* FILEATTACHMENT */
]: "fileattachment",
[
18
/* SOUND */
]: "sound",
[
19
/* MOVIE */
]: "movie",
[
20
/* WIDGET */
]: "widget",
[
21
/* SCREEN */
]: "screen",
[
22
/* PRINTERMARK */
]: "printermark",
[
23
/* TRAPNET */
]: "trapnet",
[
24
/* WATERMARK */
]: "watermark",
[
25
/* THREED */
]: "threed",
[
26
/* RICHMEDIA */
]: "richmedia",
[
27
/* XFAWIDGET */
]: "xfawidget",
[
28
/* REDACT */
]: "redact"
};

@@ -952,14 +1103,41 @@ var PdfAnnotationObjectStatus = /* @__PURE__ */ ((PdfAnnotationObjectStatus2) => {

})(PdfPageObjectType || {});
var PdfAnnotationFlagName = Object.freeze({
[1 /* INVISIBLE */]: "invisible",
[2 /* HIDDEN */]: "hidden",
[4 /* PRINT */]: "print",
[8 /* NO_ZOOM */]: "noZoom",
[16 /* NO_ROTATE */]: "noRotate",
[32 /* NO_VIEW */]: "noView",
[64 /* READ_ONLY */]: "readOnly",
[128 /* LOCKED */]: "locked",
[256 /* TOGGLE_NOVIEW */]: "toggleNoView"
const PdfAnnotationFlagName = Object.freeze({
[
1
/* INVISIBLE */
]: "invisible",
[
2
/* HIDDEN */
]: "hidden",
[
4
/* PRINT */
]: "print",
[
8
/* NO_ZOOM */
]: "noZoom",
[
16
/* NO_ROTATE */
]: "noRotate",
[
32
/* NO_VIEW */
]: "noView",
[
64
/* READ_ONLY */
]: "readOnly",
[
128
/* LOCKED */
]: "locked",
[
256
/* TOGGLE_NOVIEW */
]: "toggleNoView"
});
var PdfAnnotationFlagValue = Object.entries(
const PdfAnnotationFlagValue = Object.entries(
PdfAnnotationFlagName

@@ -979,3 +1157,4 @@ ).reduce(

(mask, name) => mask | PdfAnnotationFlagValue[name],
0 /* NONE */
0
/* NONE */
);

@@ -1013,5 +1192,9 @@ }

function unionFlags(flags) {
return flags.reduce((flag, currFlag) => {
return flag | currFlag;
}, 0 /* None */);
return flags.reduce(
(flag, currFlag) => {
return flag | currFlag;
},
0
/* None */
);
}

@@ -1077,3 +1260,3 @@ function compareSearchTarget(targetA, targetB) {

})(PdfErrorCode || {});
var PdfTaskHelper = class {
class PdfTaskHelper {
/**

@@ -1116,5 +1299,3 @@ * Create a task

}
};
// src/color.ts
}
function pdfAlphaColorToWebAlphaColor(c) {

@@ -1132,3 +1313,3 @@ const clamp = (n) => Math.max(0, Math.min(255, n));

const [, r, g, b] = /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(color) ?? (() => {
throw new Error(`Invalid hex colour: \u201C${color}\u201D`);
throw new Error(`Invalid hex colour: “${color}”`);
})();

@@ -1143,6 +1324,4 @@ const clamp = (n, hi = 255) => Math.max(0, Math.min(hi, n));

}
// src/date.ts
function pdfDateToDate(pdf) {
if (!pdf?.startsWith("D:") || pdf.length < 16) return;
if (!(pdf == null ? void 0 : pdf.startsWith("D:")) || pdf.length < 16) return;
const y = +pdf.slice(2, 6);

@@ -1166,4 +1345,2 @@ const mo = +pdf.slice(6, 8) - 1;

}
// src/index.ts
function ignore() {

@@ -1178,2 +1355,3 @@ }

MatchFlag,
MixedBlendMode,
NoopLogger,

@@ -1192,2 +1370,3 @@ PDF_FORM_FIELD_FLAG,

PdfAnnotationSubtypeName,
PdfBlendMode,
PdfBomOrZwnbsp,

@@ -1217,2 +1396,5 @@ PdfEngineFeature,

TaskStage,
blendModeLabel,
blendModeSelectOptions,
blendModeToCss,
boundingRect,

@@ -1222,4 +1404,6 @@ calculateAngle,

compareSearchTarget,
cssToBlendMode,
dateToPdfDate,
flagsToNames,
getBlendModeInfo,
ignore,

@@ -1232,2 +1416,3 @@ makeMatrix,

rectToQuad,
reduceBlendModes,
restoreOffset,

@@ -1248,5 +1433,6 @@ restorePosition,

transformSize,
uiBlendModeDisplay,
unionFlags,
webAlphaColorToPdfAlphaColor
};
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map
{
"name": "@embedpdf/models",
"version": "1.0.11",
"version": "1.0.12",
"private": false,

@@ -33,6 +33,6 @@ "description": "Shared type definitions, data models, and utility helpers (geometry, tasks, logging, PDF primitives) that underpin every package in the EmbedPDF ecosystem.",

"devDependencies": {
"tsup": "^8.0.0",
"typescript": "^5.0.0",
"@types/jest": "^29.5.14",
"jest": "^29.7.0"
"jest": "^29.7.0",
"@embedpdf/build": "1.0.0"
},

@@ -43,9 +43,7 @@ "publishConfig": {

"scripts": {
"build": "PROJECT_CWD=$(pwd) pnpm -w p:build",
"build:watch": "PROJECT_CWD=$(pwd) pnpm -w p:build:watch",
"clean": "PROJECT_CWD=$(pwd) pnpm -w p:clean",
"lint": "PROJECT_CWD=$(pwd) pnpm -w p:lint",
"lint:fix": "PROJECT_CWD=$(pwd) pnpm -w p:lint:fix",
"typecheck": "PROJECT_CWD=$(pwd) pnpm -w p:typecheck"
"build": "pnpm run clean && vite build",
"clean": "rimraf dist",
"lint": "eslint src --color",
"lint:fix": "eslint src --color --fix"
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display