Symbol referencePDF
Every symbol exported by @birchui/pdf and @birchui/pdf/engine with its declaration, grouped by area and generated from the source.
This page lists every exported symbol with its declaration. It is generated from the source by packages/pdf/scripts/generate-reference.mjs, and a test fails when it is out of date. Types can be imported from either entry; for values, the entry is given.
Viewer#
AnnotationSyncChannel#
Type.
interface AnnotationSyncChannel {
actorId?: string;
color?: string;
send(operations: SyncOperation[]): void;
onRemote(receive: (operations: SyncOperation | SyncOperation[]) => void): (() => void) | void;
sendPresence?(message: PresenceMessage): void;
onRemotePresence?(receive: (message: PresenceMessage) => void): (() => void) | void;
onConflict?(conflict: SyncConflict): void;
snapshot?: SyncSnapshot;
sendFormValues?(operations: FormSyncOperation[]): void;
onRemoteFormValues?(receive: (operations: FormSyncOperation | FormSyncOperation[]) => void): (() => void) | void;
onFormConflict?(conflict: FormSyncConflict): void;
sendPageOperations?(operations: PageSyncOperation[]): void;
onRemotePageOperations?(receive: (operations: PageSyncOperation | PageSyncOperation[]) => void): (() => void) | void;
onPageConflict?(conflict: PageSyncConflict): void;
presenceTimeout?: number;
onPresenceChange?(collaborators: PresenceState[]): void;
}AttachmentOpenEvent#
Type.
interface AttachmentOpenEvent {
name: string;
mimeType: string;
size: number;
data: Uint8Array;
source: 'document' | 'annotation';
pageIndex?: number;
relationship?: AttachmentRelationship;
description?: string;
}CommentFilter#
Type.
interface CommentFilter {
author?: string;
type?: AnnotationType;
status?: ReviewStatus;
pages?: number[];
}CommentSort#
Type.
type CommentSort = 'page' | 'date' | 'author' | 'type';CommentSummaryFormat#
Type.
type CommentSummaryFormat = 'pdf' | 'html' | 'csv';CommentSummaryOptions#
Type.
interface CommentSummaryOptions extends CommentFilter {
format: CommentSummaryFormat;
sort?: CommentSort;
title?: string;
includeReplies?: boolean;
fonts?: PdfFontSource[];
allowMissingGlyphs?: boolean;
}createPdfViewer#
Value, from @birchui/pdf.
function createPdfViewer(container: HTMLElement, options?: PdfViewerOptions): PdfViewerApi;createSyncChannel#
Value, from @birchui/pdf.
function createSyncChannel(transport: SyncTransport, options?: SyncChannelOptions): AnnotationSyncChannel;CustomToolbarItem#
Type.
interface CustomToolbarItem {
type: 'custom';
id: string;
label: string;
icon?: string;
onClick: (viewer: PdfViewerApi) => void;
isDisabled?: (viewer: PdfViewerApi) => boolean;
}DEFAULT_LABELS#
Value, from @birchui/pdf.
const DEFAULT_LABELS: Record<"save" | "attachmentOpen" | "password" | "theme" | "toolbar" | "shortcuts" | "sidebar" | "zoom" | "keepToolSelected" | "fullscreen" | "openFile" | "properties" | "calibrate" | ... 1249 more ... | "exportNoTables", string> & { ...; };DocCommandId#
Type.
type DocCommandId =
| 'fullscreen'
| 'openFile'
| 'properties'
| 'calibrate'
| 'contentAddImage'
| 'contentReplaceImage'
| 'contentDeleteImage'
| 'contentRotateImageLeft'
| 'contentRotateImageRight'
| 'contentImageProperties'
| 'contentTextStyle'
| 'findReplace'
| 'pageObjectsPanel'
| 'pageDecorations'
| 'background'
| 'imagesToPdf'
| 'watermark'
| 'headerFooter'
| 'bates'
| 'fieldsPanel'
| 'formCheck'
| 'detectFields'
| 'accessibilityCheck'
| 'formImport'
| 'formExportFdf'
| 'formExportXfdf'
| 'formExportJson'
| 'formExportXml'
| 'searchRedact'
| 'applyRedactions'
| 'signDocument'
| 'signaturesPanel'
| 'security'
| 'sanitize'
| 'recognizeText'
| 'optimize'
| 'compare'
| 'exportImages'
| 'exportText'
| 'flattenAnnotations'
| 'flattenForms'
| 'flattenAll'
| 'attachmentsPanel';DynamicStampContext#
Type.
interface DynamicStampContext {
user: PdfUser;
now: Date;
locale: string;
}ExportedPageFile#
Type.
interface ExportedPageFile {
pageIndex: number;
fileName: string;
mimeType: 'image/png' | 'image/jpeg';
data: Uint8Array;
}ExportPageImagesOptions#
Type.
interface ExportPageImagesOptions {
/** Pages to export, from 0. All pages by default. */
pages?: number[];
format?: 'png' | 'jpeg';
/** Resolution, 36 to 600. 150 by default. */
dpi?: number;
/** JPEG quality, 0.1 to 1. 0.85 by default. */
quality?: number;
signal?: AbortSignal;
onProgress?: (progress: { pageIndex: number; position: number; total: number }) => void;
}ExportTextOptions#
Type.
interface ExportTextOptions {
pages?: number[];
/** `false` leaves out the line that marks where each page starts. */
pageBreaks?: boolean;
}ExtractImagesOptions#
Type.
interface ExtractImagesOptions {
renderFallback?: boolean;
}FormDataFormat#
Type.
type FormDataFormat = 'fdf' | 'xfdf' | 'json' | 'xml';FormFieldDraft#
Type.
interface FormFieldDraft {
type: FormFieldInput['type'];
name?: string;
options?: string[];
}FormSubmitEvent#
Type.
interface FormSubmitEvent {
url: string;
method: 'get' | 'post';
format: SubmitFormat;
body: PdfBytes | string;
contentType: string;
fieldNames: string[];
fieldName?: string;
}KEYBOARD_SHORTCUTS#
Value, from @birchui/pdf.
const KEYBOARD_SHORTCUTS: readonly Shortcut[];MailConversionEvent#
Type.
interface MailConversionEvent {
format: MailFormat;
sourceFileName: string;
fileName: string;
pageCount: number;
message: MailConversionSummary;
warnings: MailPdfWarning[];
}MailConversionOptions#
Type.
interface MailConversionOptions extends Omit<MailToPdfOptions, 'attachOriginal'> {
attachOriginal?: boolean;
}MailConversionSummary#
Type.
interface MailConversionSummary {
subject: string;
from?: MailAddress;
to: MailAddress[];
cc: MailAddress[];
sentAt?: Date;
attachments: { fileName: string; mimeType: string; size: number; isInline: boolean }[];
}MentionCandidate#
Type.
interface MentionCandidate {
id: string;
name: string;
description?: string;
}MentionEvent#
Type.
interface MentionEvent {
user: MentionCandidate;
annotation: PdfAnnotation;
replyId?: string;
}MentionOptions#
Type.
interface MentionOptions {
search(query: string, context: { signal: AbortSignal }): MentionCandidate[] | Promise<MentionCandidate[]>;
onMention?(event: MentionEvent): void;
debounce?: number;
}OcrPageOutcome#
Type.
interface OcrPageOutcome {
pageIndex: number;
status: 'recognized' | 'has-text' | 'no-text' | 'failed';
/** Words written to the invisible text layer. */
words: number;
message?: string;
}OcrPageState#
Type.
type OcrPageState = 'running' | 'recognized' | 'failed' | 'no-text';OptimizePreset#
Type.
type OptimizePreset = 'lossless' | 'balanced' | 'smallest';PageCommandId#
Type.
type PageCommandId =
| 'pagesOrganize'
| 'pagesMerge'
| 'pagesInsertBlank'
| 'pagesInsertPdf'
| 'pagesInsertImages'
| 'pagesInsertClipboard'
| 'pagesDelete'
| 'pagesRotateLeft'
| 'pagesRotateRight'
| 'pagesDuplicate'
| 'pagesExtract'
| 'pagesSplit'
| 'pagesReplace'
| 'pagesMove'
| 'pagesReverse'
| 'pagesCrop'
| 'pagesResize'
| 'pagesNumbers'
| 'pagesRemoveNumbers'
| 'pagesLabels'
| 'pagesBoxes'
| 'pagesDeleteBlank'
| 'pagesAutoRotate'
| 'pagesInterleave'
| 'pagesImpose'
| 'pagesOptimize';PDF_VIEWER_EVENT_NAMES#
Value, from @birchui/pdf.
const PDF_VIEWER_EVENT_NAMES: readonly (keyof PdfViewerEvents)[];PdfFileConverter#
Type.
type PdfFileConverter = (
data: Uint8Array,
file: { name: string; type: string },
) => Promise<Uint8Array | ArrayBuffer | undefined> | Uint8Array | ArrayBuffer | undefined;PdfLayer#
Type.
interface PdfLayer {
id: string;
name: string;
isVisible: boolean;
depth: number;
groups: string[];
radioGroup: string[];
}pdfLocaleDe#
Value, from @birchui/pdf.
const pdfLocaleDe: PdfViewerLabels;pdfLocaleEn#
Value, from @birchui/pdf.
const pdfLocaleEn: PdfViewerLabels;pdfLocaleEs#
Value, from @birchui/pdf.
const pdfLocaleEs: PdfViewerLabels;pdfLocaleFr#
Value, from @birchui/pdf.
const pdfLocaleFr: PdfViewerLabels;pdfLocaleJa#
Value, from @birchui/pdf.
const pdfLocaleJa: PdfViewerLabels;pdfLocalePt#
Value, from @birchui/pdf.
const pdfLocalePt: PdfViewerLabels;pdfLocaleZh#
Value, from @birchui/pdf.
const pdfLocaleZh: PdfViewerLabels;PdfProgressiveSource#
Type.
type PdfProgressiveSource = PdfUrlSource | PdfRangeSource;PdfRangeLoader#
Type.
interface PdfRangeLoader {
length: number;
read(begin: number, end: number): Promise<Uint8Array>;
initialData?: Uint8Array;
}PdfRangeSource#
Type.
interface PdfRangeSource {
rangeLoader: PdfRangeLoader;
}PdfRenderer#
Type.
interface PdfRenderer {
getDocument(source: RendererDocumentSource): RendererLoadingTask;
AnnotationMode?: { DISABLE: number; ENABLE?: number };
RangeTransport?: new (length: number, initialData: Uint8Array | null) => RendererRangeTransport;
readonly mode?: 'worker' | 'main';
destroy?(): void;
}PdfRendererSource#
Type.
type PdfRendererSource = PdfRenderer | (() => PdfRenderer | Promise<PdfRenderer>);PdfRenderOptions#
Type.
interface PdfRenderOptions {
renderLimits?: Partial<RenderLimits>;
maxRenderMs?: number;
substituteFont?: SubstituteFontProvider;
/**
* Draw fonts a document does not embed from the bundled substitute outlines, loaded on first use. On by
* default; `false` leaves that text to the fonts of the device.
*/
standardFonts?: boolean;
/**
* Read fonts encoded with a predefined CJK CMap through the bundled tables, loaded per character collection on
* first use. On by default; `false` leaves such fonts undrawn when they are embedded.
*/
predefinedCMaps?: boolean;
}PdfSource#
Type.
type PdfSource = Uint8Array | ArrayBuffer | Blob;PdfTabInfo#
Type.
interface PdfTabInfo {
id: string;
fileName: string;
isActive: boolean;
isModified: boolean;
pageCount: number;
}PdfUrlSource#
Type.
interface PdfUrlSource {
url: string;
httpHeaders?: Record<string, string>;
withCredentials?: boolean;
}PdfUser#
Type.
interface PdfUser {
name: string;
id?: string;
isAdmin?: boolean;
}PdfViewerApi#
Type.
interface PdfViewerApi extends Widget<PdfViewerOptions, PdfViewerEvents> {
readonly ready: Promise<void>;
load(source: PdfSource | PdfProgressiveSource, options?: { fileName?: string; password?: string }): Promise<void>;
isEditable(): boolean;
openTab(
source: PdfSource | PdfProgressiveSource,
options?: { fileName?: string; password?: string },
): Promise<string>;
closeTab(id: string): boolean;
activateTab(id: string): boolean;
getTabs(): PdfTabInfo[];
getViewState(): PdfViewState;
setViewState(state: Partial<PdfViewState>): void;
runCommand(command: ViewerCommand): boolean;
getCommands(): ViewerCommandInfo[];
openCommandPalette(): void;
getLayers(): Promise<PdfLayer[]>;
setLayerVisibility(id: string, isVisible: boolean): Promise<void>;
getPageCount(): number;
getPages(): PdfPageSummary[];
getCurrentPage(): number;
goToPage(pageIndex: number, options?: { point?: PdfPoint }): void;
nextPage(): void;
previousPage(): void;
getZoom(): number;
setZoom(zoom: ZoomValue): void;
zoomIn(): void;
zoomOut(): void;
getRotation(): number;
rotateView(delta?: number): void;
search(query: string, options?: SearchOptions): Promise<{ total: number }>;
searchNext(): void;
searchPrevious(): void;
clearSearch(): void;
print(options?: PrintOptions): Promise<void>;
getScrollMode(): ScrollMode;
setScrollMode(mode: ScrollMode): void;
getSpread(): SpreadMode;
setSpread(spread: SpreadMode): void;
getPageLabel(pageIndex: number): string;
enterPresentation(): void;
exitPresentation(): void;
toggleFullscreen(): void;
zoomToRect(pageIndex: number, rect: PdfRect): void;
getRenderStats(): RenderStats;
download(fileName?: string): Promise<void>;
save(options?: SaveOptions): Promise<SaveResult>;
isModified(): boolean;
getTool(): ViewerTool;
setTool(tool: ViewerTool, options?: { stamp?: BuiltInStamp | string; field?: FormFieldDraft }): void;
getAnnotations(pageIndex?: number): PdfAnnotation[];
getAnnotation(id: string): PdfAnnotation | undefined;
addAnnotation(input: AnnotationInput): PdfAnnotation;
addAnnotations(inputs: AnnotationInput[]): PdfAnnotation[];
addTextMarkup(
type: TextMarkupType,
pageIndex: number,
rects: PdfRect[],
options?: Partial<AnnotationInput>,
): PdfAnnotation;
updateAnnotation(id: string, patch: AnnotationPatch): PdfAnnotation | undefined;
removeAnnotation(id: string | string[]): void;
selectAnnotation(id: string | null): void;
getSelectedAnnotation(): PdfAnnotation | undefined;
getSelectedAnnotations(): PdfAnnotation[];
selectAnnotations(ids: string[]): void;
addReply(annotationId: string, reply: { contents: string; author?: string }): AnnotationReply | undefined;
updateReply(annotationId: string, replyId: string, contents: string): AnnotationReply | undefined;
removeReply(annotationId: string, replyId: string): boolean;
setAuthor(author: string): void;
undo(): boolean;
redo(): boolean;
canUndo(): boolean;
canRedo(): boolean;
markRedactions(query: RedactionQuery, options?: RedactionSearchOptions): PdfAnnotation[];
applyRedactions(ids?: string[]): number;
applyRedactionsAsync(ids?: string[]): Promise<number>;
getCollaborators(): PresenceState[];
getSyncSnapshot(): SyncSnapshot | undefined;
mergeSyncSnapshot(snapshot: SyncSnapshot): void;
getFormFields(): PdfFormField[];
getFormValues(): Record<string, FormValue>;
setFormValue(name: string, value: FormValue): void;
setFormValues(values: Record<string, FormValue>): void;
resetForm(names?: string[]): void;
validateForm(): FormIssue[];
exportFormData(format: 'fdf'): PdfBytes;
exportFormData(format: 'xfdf' | 'json' | 'xml'): string;
importFormData(
data: Uint8Array | ArrayBuffer | string | Record<string, unknown>,
format?: FormDataFormat,
): FormImportResult;
downloadFormData(format: FormDataFormat): void;
addFormField(input: FormFieldInput): PdfFormField;
detectFormFields(pageIndexes?: readonly number[]): DetectedField[];
checkAccessibility(): AccessibilityReport;
getFigures(): PdfFigure[];
setAlternateText(figureId: string, alternateText: string): Promise<boolean>;
setLanguage(language: string): Promise<void>;
addDetectedFields(fields?: readonly DetectedField[]): PdfFormField[];
updateFormField(name: string, patch: FormFieldPatch): PdfFormField | undefined;
removeFormField(name: string): boolean;
getSignatures(): Promise<(SignatureInfo & { fieldName: string })[]>;
verifySignatures(): Promise<PdfSignatureVerification[]>;
signDocument(options: SignPdfOptions): Promise<PdfBytes>;
compareWith(
other: PdfSource,
options?: { fileName?: string; password?: string; view?: 'text' | 'visual' },
): Promise<void>;
movePage(from: number, to: number): void;
movePages(indices: number[], target: number): void;
reversePages(indices?: number[]): void;
duplicatePages(indices: number[]): Promise<number>;
insertPagesFrom(source: PdfSource, pageIndexes: number[], at?: number): Promise<number>;
insertImagePages(images: (Uint8Array | ImagePageInput)[], at?: number, options?: ImagesToPdfOptions): Promise<number>;
resizePages(indices: number[], options: ResizePagesOptions): Promise<void>;
getPageBoxes(pageIndex: number): PageBoxes;
setPageBoxes(indices: number[], boxes: PageBoxesPatch): Promise<void>;
splitDocument(options: SplitOptions): Promise<SplitPart[]>;
openPageOrganizer(): void;
closePageOrganizer(): void;
rotatePages(indices: number[], degrees?: number): void;
deletePages(indices: number[]): void;
insertBlankPage(at: number, size?: { width: number; height: number }): number;
mergeDocument(source: PdfSource, at?: number): Promise<number>;
extractPages(indices: number[], options?: { deleteExtracted?: boolean }): Promise<PdfBytes>;
replacePages(indices: number[], source: PdfSource, sourceIndices?: number[]): Promise<number>;
interleaveDocument(source: PdfSource, options?: InterleaveOptions): Promise<numbe
// continues in the sourcepdfViewerDefinition#
Value, from @birchui/pdf.
const pdfViewerDefinition: WidgetDefinition<PdfViewerOptions | undefined, { documentLoad: any; documentPreview: any; layersChange: any; viewStateChange: any; tabChange: any; documentError: any; pageChange: any; ... 32 more ...; documentSanitize: any; }, PdfViewerApi>;PdfViewerEvents#
Type.
interface PdfViewerEvents {
documentLoad: { pageCount: number; fileName?: string; title?: string };
documentPreview: { pageCount: number; fileName?: string };
layersChange: { layers: PdfLayer[] };
viewStateChange: { state: PdfViewState };
tabChange: { tabs: PdfTabInfo[]; activeId: string | undefined };
documentError: { error: unknown; message: string };
pageChange: { pageIndex: number; previousPageIndex: number; pageCount: number };
zoomChange: { zoom: number; mode: ZoomValue };
annotationPresetsChange: { presets: AnnotationPreset[] };
annotationAdd: { annotations: PdfAnnotation[]; source: ChangeSource };
annotationChange: { changes: { before: PdfAnnotation; after: PdfAnnotation }[]; source: ChangeSource };
annotationRemove: { annotations: PdfAnnotation[]; source: ChangeSource };
annotationSelect: { annotation: PdfAnnotation | null; annotations: PdfAnnotation[] };
layoutChange: { scrollMode: ScrollMode; spread: SpreadMode };
presentationChange: { isPresenting: boolean };
printProgress: { page: number; total: number; isDone: boolean; isCancelled: boolean };
formFieldChange: { name: string; value: FormValue; previousValue: FormValue; source: ChangeSource };
pagesChange: { pages: PdfPageSummary[]; reason: string };
documentChange: { reason: string };
fontMissing: MissingGlyphReport;
toolChange: { tool: ViewerTool };
searchResult: { query: string; total: number; current: number };
historyChange: { canUndo: boolean; canRedo: boolean };
save: { bytes: PdfBytes; mode: 'incremental' | 'full'; fileName: string };
formValidation: { issues: FormIssue[]; isValid: boolean };
formSubmit: FormSubmitEvent;
formReset: { names: string[]; changed: string[] };
formDataExport: { format: FormDataFormat; data: Uint8Array | string; fileName: string };
pagesSplit: { parts: SplitPart[] };
filesMerge: { files: string[]; pageCount: number; result: 'inserted' | 'new'; bytes?: PdfBytes };
mailConversion: MailConversionEvent;
attachmentOpen: AttachmentOpenEvent;
textRecognition: { pages: OcrPageOutcome[]; isCancelled: boolean };
pagesExport: { format: 'png' | 'jpeg'; files: ExportedPageFile[] };
textExport: { text: string; pages: number[] };
officeExport: { format: 'docx' | 'xlsx'; bytes: Uint8Array; pages: number[]; tables: number };
fillInitialsChange: { initials: string };
organizerSecondChange: { bytes: Uint8Array; fileName: string; pageCount: number };
compareReport: { format: CompareReportFormat; report: string; summary: PdfComparisonSummary };
documentSanitize: { report: SanitizeReport };
}PdfViewerLabels#
Type.
type PdfViewerLabels = Record<LabelKey, string> & { tools: Record<ViewerTool, string> };PdfViewerOptions#
Type.
interface PdfViewerOptions {
document?: PdfSource | PdfProgressiveSource;
rangeChunkSize?: number;
fileName?: string;
password?: string;
allowFetch?: boolean;
fetchDocument?: RendererFetchDocument;
renderer?: PdfRendererSource;
worker?: PdfWorkerSource;
renderOptions?: PdfRenderOptions;
renderPage?: (context: RenderPageContext) => Promise<void> | void;
licenseKey?: string;
injectStyles?: boolean;
theme?: 'light' | 'dark' | 'auto';
invertPagesInDark?: boolean;
height?: number | string;
ariaLabel?: string;
toolbar?: boolean | ToolbarItem[];
toolbarPreset?: ToolbarPreset;
initialViewState?: Partial<PdfViewState>;
shortcuts?: ShortcutOverrides;
tools?: ViewerTool[];
sidebar?: false | SidebarPanel;
sidebarPanels?: SidebarPanel[];
isSidebarOpen?: boolean;
initialPage?: number;
zoom?: ZoomValue;
minZoom?: number;
maxZoom?: number;
spread?: SpreadMode;
scrollMode?: ScrollMode;
pageDirection?: 'ltr' | 'rtl';
toolGroup?: ToolGroup;
author?: string;
currentUser?: string | PdfUser;
canEdit?: (annotation: PdfAnnotation, user: PdfUser) => boolean;
readOnly?: boolean;
annotationSync?: AnnotationSyncChannel;
ignorePermissions?: boolean;
locale?: string;
localeText?: LocaleTextInput;
rtl?: boolean;
onPasswordRequest?: (request: {
isRetry: boolean;
fileName: string;
}) => string | undefined | null | Promise<string | undefined | null>;
signatureStorage?: SignatureStorage;
ocr?: ViewerOcrOptions;
trustedCertificates?: (Uint8Array | string)[];
/** Trust lists read with `loadTrustList`; a list past its expiry date is not used. */
trustLists?: PdfTrustList[];
allowFileDrop?: boolean;
fileConverters?: Record<string, PdfFileConverter>;
fillInitials?: string;
welcome?: boolean;
convertMail?: boolean | MailConversionOptions;
decodeImage?: ImageDecoder;
tabs?: boolean;
printResolution?: number;
snapping?: boolean;
keepToolSelected?: boolean;
pixelRatio?: number;
maxRenderPixels?: number;
placeholders?: boolean;
enableForms?: boolean;
enablePageTools?: boolean;
enableFormDesigner?: boolean;
highlightRequiredFields?: boolean;
tool?: ViewerTool;
annotationDefaults?: Partial<Record<AnnotationType, Partial<AnnotationDefaults>>>;
annotationPresets?: AnnotationPreset[];
fonts?: PdfFontSource[];
fontFallback?: PdfFontFallback;
mentions?: MentionOptions;
allowMissingGlyphs?: boolean;
/**
* How annotation text is saved when no supplied font has its characters. By default the viewer draws it with the
* fonts of the browser and stores the drawing in the appearance, so the save never fails; `false` turns that off.
*/
textRasterizer?: PdfTextRasterizer | false;
annotationScope?: 'markup' | 'all';
stamps?: StampDefinition[];
/** Called with the whole list when a stamp is created or deleted in the stamp gallery. */
onStampsChange?: (stamps: StampDefinition[]) => void;
labels?: Partial<Record<LabelKey, string>> & { tools?: Partial<Record<ViewerTool, string>> };
maxCanvasPixels?: number;
pageGap?: number;
createId?: () => string;
now?: () => Date;
}PdfViewState#
Type.
interface PdfViewState {
pageIndex: number;
zoom: ZoomValue;
scrollMode: ScrollMode;
spread: SpreadMode;
rotation: number;
sidebar: { isOpen: boolean; panel: SidebarPanel };
scrollOffset: { x: number; y: number };
}PdfWorkerSource#
Type.
type PdfWorkerSource = boolean | Worker | (() => Worker);PrintMode#
Type.
type PrintMode = 'auto' | 'vector' | 'raster';PrintOptions#
Type.
interface PrintOptions {
pages?: 'all' | 'current' | number[] | string;
resolution?: number;
annotations?: boolean;
mode?: PrintMode;
/** Size on paper: the size of the page, fitted to the paper, or a percentage. Anything but `'actual'` prints as images. */
scale?: PrintScale;
}PrintScale#
Type.
type PrintScale = 'actual' | 'fit' | number;ReadAloudChunk#
Type.
interface ReadAloudChunk {
pageIndex: number;
text: string;
quads: PdfQuad[];
}ReadAloudHandle#
Type.
interface ReadAloudHandle {
readonly isPaused: boolean;
readonly isStopped: boolean;
readonly finished: Promise<void>;
pause(): void;
resume(): void;
stop(): void;
}ReadAloudOptions#
Type.
interface ReadAloudOptions {
fromPage?: number;
onText?: (chunk: ReadAloudChunk) => void | Promise<void>;
lang?: string;
rate?: number;
}RecognizeTextRequest#
Type.
interface RecognizeTextRequest {
/** Pages to work on, from 0. All pages by default. */
pages?: number[];
/** Also recognise pages that already have text. */
includePagesWithText?: boolean;
language?: string;
signal?: AbortSignal;
onProgress?: (progress: { pageIndex: number; position: number; total: number; progress: number }) => void;
}RendererDocument#
Type.
interface RendererDocument {
numPages: number;
getPage(pageNumber: number): Promise<RendererPage>;
getOutline(): Promise<RendererOutlineItem[] | null>;
getDestination(id: string): Promise<unknown[] | null>;
getPageIndex(ref: unknown): Promise<number>;
getPageLabels?(): Promise<string[] | null>;
getMetadata?(): Promise<{ info?: Record<string, unknown> } | null>;
getAttachments?(): Promise<Record<string, { filename?: string; content?: Uint8Array; description?: string }> | null>;
getData?(): Promise<Uint8Array>;
getOptionalContentConfig?(params?: { intent?: string }): Promise<RendererOptionalContentConfig>;
destroy(): Promise<void>;
}RendererDocumentSource#
Type.
interface RendererDocumentSource {
data?: Uint8Array;
url?: string;
httpHeaders?: Record<string, string>;
withCredentials?: boolean;
range?: RendererRangeTransport;
length?: number;
password?: string;
rangeChunkSize?: number;
allowFetch?: boolean;
fetchDocument?: RendererFetchDocument;
}RendererFetchDocument#
Type.
type RendererFetchDocument = (request: RendererFetchRequest) => Promise<RendererFetchReply>;RendererFetchReply#
Type.
interface RendererFetchReply {
bytes: Uint8Array | ArrayBuffer;
total?: number;
}RendererFetchRequest#
Type.
interface RendererFetchRequest {
url: string;
range?: { begin: number; end: number };
headers?: Record<string, string>;
withCredentials: boolean;
signal: AbortSignal;
}RendererLoadingTask#
Type.
interface RendererLoadingTask {
promise: Promise<RendererDocument>;
destroy(): Promise<void>;
onPassword?: (update: (password: string) => void, reason: number) => void;
}RendererPage#
Type.
interface RendererPage {
view: number[];
rotate: number;
getViewport(params: { scale: number; rotation?: number; offsetX?: number; offsetY?: number }): RendererViewport;
render(params: {
canvas?: HTMLCanvasElement | OffscreenCanvas | null;
canvasContext?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
viewport: RendererViewport;
transform?: number[];
annotationMode?: number;
background?: string | null;
intent?: string;
optionalContentConfigPromise?: Promise<RendererOptionalContentConfig | null | undefined>;
}): RendererRenderTask;
getTextContent(params?: { includeMarkedContent?: boolean }): Promise<RendererTextContent>;
getStructTree?(): Promise<RendererStructNode | null | undefined>;
getAnnotations?(params?: { intent?: string }): Promise<RendererLinkAnnotation[]>;
cleanup?(): void;
}RenderPageContext#
Type.
interface RenderPageContext {
pageIndex: number;
canvas: HTMLCanvasElement;
viewport: RendererViewport;
scale: number;
pixelRatio: number;
area?: { x: number; y: number; width: number; height: number };
signal: AbortSignal;
defaultRender(): Promise<void>;
}RenderStats#
Type.
interface RenderStats {
views: number;
renderedViews: number;
canvasPixels: number;
queued: number;
thumbnails: number;
thumbnailPixels: number;
renderMode: 'worker' | 'main';
}resolveShortcuts#
Value, from @birchui/pdf.
function resolveShortcuts(overrides: ShortcutOverrides | undefined, warn?: (message: string) => void): readonly Shortcut[];SavedSignature#
Type.
interface SavedSignature {
id: string;
draft: SignatureDraft;
createdAt: string;
}ScrollMode#
Type.
type ScrollMode = 'vertical' | 'horizontal' | 'page';SearchOptions#
Type.
interface SearchOptions {
caseSensitive?: boolean;
wholeWord?: boolean;
diacriticSensitive?: boolean;
regex?: boolean;
}Shortcut#
Type.
interface Shortcut {
keys: string;
command: ViewerCommand;
description: string;
}shortcutFor#
Value, from @birchui/pdf.
function shortcutFor(event: KeyLike, isPresenting?: boolean, shortcuts?: readonly Shortcut[]): ViewerCommand | undefined;ShortcutOverrides#
Type.
type ShortcutOverrides = Partial<Record<ViewerCommand, string | string[] | false>>;SidebarPanel#
Type.
type SidebarPanel =
| 'thumbnails'
| 'outline'
| 'annotations'
| 'fields'
| 'search'
| 'redaction'
| 'attachments'
| 'signatures'
| 'layers'
| 'objects';SignatureDraft#
Type.
interface SignatureDraft {
kind: 'drawn' | 'typed' | 'image';
inkList?: PdfPoint[][];
text?: string;
image?: { data: Uint8Array; mimeType: 'image/png' | 'image/jpeg'; width: number; height: number };
}SignatureStorage#
Type.
interface SignatureStorage {
load(): SavedSignature[] | Promise<SavedSignature[]>;
save(signatures: SavedSignature[]): void | Promise<void>;
}SpreadMode#
Type.
type SpreadMode = 'none' | 'odd' | 'even';StampDefinition#
Type.
interface StampDefinition {
name: string;
label: string | ((context: DynamicStampContext) => string);
color?: string;
/** A function, or text in which `{name}` and `{date}` stand for the current user and the date and time. */
subtitle?: string | ((context: DynamicStampContext) => string);
/** Set on stamps made in the stamp gallery; these can be deleted there. */
isUserMade?: boolean;
}SyncChannelName#
Type.
type SyncChannelName = SyncMessage['channel'];SyncChannelOptions#
Type.
interface SyncChannelOptions {
actorId?: string;
color?: string;
channels?: readonly SyncChannelName[];
snapshot?: SyncSnapshot;
presenceTimeout?: number;
onConflict?: (conflict: SyncConflict) => void;
onPresenceChange?: (collaborators: PresenceState[]) => void;
}SyncMessage#
Type.
type SyncMessage =
| { channel: 'annotations'; operations: SyncOperation[] }
| { channel: 'forms'; operations: FormSyncOperation[] }
| { channel: 'pages'; operations: PageSyncOperation[] }
| { channel: 'presence'; message: PresenceMessage };SyncTransport#
Type.
interface SyncTransport {
actorId?: string;
send(message: SyncMessage): void;
subscribe(receive: (message: SyncMessage) => void): (() => void) | void;
}ToolbarItem#
Type.
type ToolbarItem = ToolbarItemName | CustomToolbarItem;ToolbarItemName#
Type.
type ToolbarItemName =
| 'sidebar'
| 'pageNavigation'
| 'zoom'
| 'rotate'
| 'view'
| 'pointer'
| 'search'
| 'tools'
| 'undoRedo'
| 'print'
| 'download'
| 'theme'
| 'menu'
| 'separator'
| 'spacer';ToolbarPreset#
Type.
type ToolbarPreset = 'viewer' | 'reviewer' | 'editor' | 'form-filler' | 'full';toolbarPresetOptions#
Value, from @birchui/pdf.
function toolbarPresetOptions(preset: ToolbarPreset, allTools: readonly ViewerTool[]): Partial<PdfViewerOptions>;ToolbarTab#
Type.
type ToolbarTab = 'view' | 'comment' | 'edit' | 'pages' | 'forms' | 'protect' | 'tools';ToolGroup#
Type.
type ToolGroup = ToolbarTab | 'annotate' | 'shapes' | 'insert' | 'measure' | 'redact' | 'content';ViewerCommand#
Type.
type ViewerCommand =
| PageCommandId
| DocCommandId
| 'zoomIn'
| 'zoomOut'
| 'zoomReset'
| 'fitWidth'
| 'fitPage'
| 'nextPage'
| 'previousPage'
| 'firstPage'
| 'lastPage'
| 'find'
| 'findNext'
| 'findPrevious'
| 'print'
| 'download'
| 'rotateClockwise'
| 'rotateCounterClockwise'
| 'undo'
| 'redo'
| 'deleteSelection'
| 'escape'
| 'toggleSidebar'
| 'selectAll'
| 'copy'
| 'cut'
| 'paste'
| 'duplicate'
| 'bringForward'
| 'sendBackward'
| 'bringToFront'
| 'sendToBack'
| 'presentation'
| 'shortcutHelp'
| 'contextMenu'
| 'focusToolbar'
| 'placeAtCenter'
| 'commandPalette'
| 'readAloud'
| 'snapshotPage'
| `tool:${ViewerTool}`
| 'tool:select'
| 'tool:pan'
| 'tool:marqueeZoom'
| 'tool:eraser'
| 'tool:stamp'
| 'tool:highlight'
| 'tool:underline'
| 'tool:strikeout'
| 'tool:note'
| 'tool:freeText'
| 'tool:ink'
| 'tool:rectangle'
| 'tool:ellipse'
| 'tool:line'
| 'tool:arrow'
| 'tool:redaction';ViewerCommandInfo#
Type.
interface ViewerCommandInfo {
id: ViewerCommand;
label: string;
shortcut?: string;
isEnabled: boolean;
}ViewerOcrEngine#
Type.
type ViewerOcrEngine = Pick<OcrEngine, 'recognizePage'>;ViewerOcrOptions#
Type.
interface ViewerOcrOptions {
/**
* The recognition model shipped as `@birchui/pdf/assets/ocr/latin.lqocr`: its bytes, or a function that
* loads them. The viewer never fetches it; it is read the first time text recognition runs.
*/
model?: Uint8Array | (() => Uint8Array | Promise<Uint8Array>);
/** `true` starts the packaged worker, or pass a worker running `@birchui/pdf/ocr-worker` or a function creating one. */
worker?: boolean | OcrWorkerLike | (() => OcrWorkerLike);
/** An engine of your own instead of the packaged one; `model` and `worker` are then ignored. */
engine?: ViewerOcrEngine;
/** Languages offered in the dialog. Read from the model by default. */
languages?: string[];
/** Resolution pages are rendered at for recognition. 200 by default. */
dpi?: number;
/** `false` hides the banner offered on scanned pages. */
banner?: boolean;
}ViewerTool#
Type.
type ViewerTool =
| 'select'
| 'pan'
| 'marqueeZoom'
| 'snapshot'
| TextMarkupType
| 'insertText'
| 'replaceText'
| 'note'
| 'freeText'
| 'callout'
| 'ink'
| 'eraser'
| 'rectangle'
| 'ellipse'
| 'cloud'
| 'line'
| 'arrow'
| 'polygon'
| 'polyline'
| 'distance'
| 'perimeter'
| 'area'
| 'stamp'
| 'image'
| 'signature'
| 'redaction'
| 'formField'
| 'editText'
| 'addText'
| 'editImage'
| 'count'
| 'arc'
| 'angle'
| 'link';ZoomValue#
Type.
type ZoomValue = number | 'fit-width' | 'fit-page' | 'auto';Documents and saving#
ApplyRedactionsAsyncOptions#
Type.
interface ApplyRedactionsAsyncOptions {
decodeImage?: AsyncRedactionImageDecoder;
}ApplyRedactionsOptions#
Type.
interface ApplyRedactionsOptions {
decodeImage?: RedactionImageDecoder;
}AsyncRedactionImageDecoder#
Type.
type AsyncRedactionImageDecoder = (
image: PageRedactionImage,
) => DecodedRedactionImage | undefined | Promise<DecodedRedactionImage | undefined>;decryptPdf#
Value, from @birchui/pdf/engine.
function decryptPdf(data: Uint8Array | ArrayBuffer, password?: string): Promise<PdfBytes>;DocumentChangeReason#
Type.
type DocumentChangeReason =
| 'metadata'
| 'outline'
| 'attachments'
| 'watermark'
| 'headerFooter'
| 'bates'
| 'crop'
| 'pageLabels'
| 'pageText'
| 'pageImage'
| 'pageObject'
| 'background'
| 'flatten'
| 'history';encryptPdf#
Value, from @birchui/pdf/engine.
function encryptPdf(data: Uint8Array | ArrayBuffer, options: EncryptOptions & { password?: string; }): Promise<PdfBytes>;InterleaveOptions#
Type.
interface InterleaveOptions {
reverseSecond?: boolean;
}loadPdfDocument#
Value, from @birchui/pdf/engine.
function loadPdfDocument(data: Uint8Array | ArrayBuffer, options?: OpenPdfOptions): Promise<PdfDocument>;MergeFileInput#
Type.
interface MergeFileInput {
data: Uint8Array | ArrayBuffer;
name?: string;
pages?: string | readonly number[];
password?: string;
}MergeFilesOptions#
Type.
interface MergeFilesOptions {
at?: number;
bookmarkPerFile?: boolean;
keepBookmarks?: boolean;
keepFormFields?: boolean;
signal?: AbortSignal;
onProgress?: (progress: MergeProgress) => void | Promise<void>;
}MergeFilesResult#
Type.
interface MergeFilesResult {
at: number;
pageCount: number;
documentIndexes: number[];
renamedFields: { from: string; to: string }[];
}MergeProgress#
Type.
interface MergeProgress {
done: number;
total: number;
name: string;
}openPdfDocument#
Value, from @birchui/pdf/engine.
function openPdfDocument(data: Uint8Array | ArrayBuffer, options?: OpenPdfOptions): PdfDocument;OpenPdfOptions#
Type.
interface OpenPdfOptions {
limits?: Partial<PdfLimits>;
fontFallback?: PdfFontFallback;
/**
* `false` makes `save()` reject with a `PdfMissingGlyphError` when text has no font. By default the file is
* saved and the result names the missing scripts in `missingGlyphs`.
*/
allowMissingGlyphs?: boolean;
/** Draws annotation text no font covers as an image. The viewer sets one that uses the fonts of the browser. */
textRasterizer?: PdfTextRasterizer;
author?: string;
createId?: () => string;
now?: () => Date;
annotationDefaults?: Partial<Record<AnnotationType, Partial<AnnotationDefaults>>>;
historyLimit?: number;
readAnnotations?: boolean;
annotationScope?: 'markup' | 'all';
password?: string;
fonts?: PdfFontSource[];
decodeImage?: ImageDecoder;
ignorePermissions?: boolean;
authorId?: string;
}PageDecoration#
Type.
interface PageDecoration {
kind: PageLayerKind;
pages: number[];
/** True when this library made the layer; `options` then holds what it was made with. */
isOwn: boolean;
options?: Record<string, unknown>;
}PageNumberOptions#
Type.
interface PageNumberOptions {
format?: string;
position?: PageNumberPosition;
startNumber?: number;
pages?: number[];
fontSize?: number;
color?: string;
margin?: number;
font?: StandardFont;
fonts?: FontRegistry;
}PageNumberPosition#
Type.
type PageNumberPosition =
'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';PageRedactionImage#
Type.
interface PageRedactionImage extends RedactionImageRequest {
pageIndex: number;
}PagesChangeReason#
Type.
type PagesChangeReason =
'move' | 'rotate' | 'delete' | 'insert' | 'merge' | 'history' | 'redaction' | 'crop' | 'content';PageSourceKind#
Type.
type PageSourceKind = 'original' | 'merged' | 'blank';PageTextOptions#
Type.
type PageTextOptions = Omit<StructuredTextOptions, 'exclude'>;PdfDocument#
Type.
interface PdfDocument {
readonly pageCount: number;
readonly isModified: boolean;
readonly isEncrypted: boolean;
readonly isLocked: boolean;
readonly hasSignatures: boolean;
readonly certification: PdfCertificationInfo | undefined;
readonly permissions: PdfPermissions;
readonly encryption: PdfEncryptionInfo | undefined;
isAllowed(permission: PdfPermissionName): boolean;
encrypt(options: EncryptOptions): void;
decrypt(): void;
mergeEncryptedDocument(data: Uint8Array | ArrayBuffer, password?: string, at?: number): Promise<number>;
on<K extends keyof PdfDocumentEvents & string>(event: K, listener: Listener<PdfDocumentEvents[K]>): () => void;
getPages(): PdfPageSummary[];
setAuthor(author: string): void;
getAnnotations(pageIndex?: number): PdfAnnotation[];
addAnnotation(input: AnnotationInput): PdfAnnotation;
addAnnotations(inputs: AnnotationInput[]): PdfAnnotation[];
updateAnnotation(id: string, patch: AnnotationPatch): PdfAnnotation | undefined;
removeAnnotation(id: string | string[]): PdfAnnotation[];
addReply(id: string, reply: string | { contents: string; author?: string; id?: string }): AnnotationReply | undefined;
updateReply(id: string, replyId: string, contents: string): AnnotationReply | undefined;
removeReply(id: string, replyId: string): boolean;
addTextMarkup(
type: TextMarkupType,
pageIndex: number,
quads: readonly PdfQuad[],
extra?: Partial<Omit<AnnotationInput, 'type' | 'pageIndex' | 'quadPoints'>>,
): PdfAnnotation | undefined;
uprightPlacement(pageIndex: number, rect: PdfRect): { rect: PdfRect; rotation: number | undefined };
getNamedDestinations(): NamedDestination[];
getAnnotationAttachment(id: string): AnnotationAttachmentFile | undefined;
exportAnnotationsFdf(options?: { fileName?: string; includeAppearances?: boolean }): PdfBytes;
importAnnotationsFdf(data: Uint8Array | ArrayBuffer, options?: { replace?: boolean }): { annotations: number };
applyRemoteChanges(changes: { upsert: PdfAnnotation[]; remove: string[] }): void;
subscribeAnnotationChanges(listener: (changes: AnnotationChangeSet) => void): () => void;
getFormFields(): PdfFormField[];
getFormField(name: string): PdfFormField | undefined;
getFormValues(): Record<string, FormValue>;
setFormValue(name: string, value: FormValue): string[];
setFormValues(values: Record<string, FormValue>): string[];
validateFormField(name: string, value?: FormValue): string | undefined;
validateFormFieldIssue(name: string, value?: FormValue): FieldIssue | undefined;
validateForm(): FormIssue[];
getFormState(): FormState;
describeFieldScripts(name: string): FieldScriptReport | undefined;
filterKeystroke(
name: string,
currentValue: string,
change: string,
selStart: number,
selEnd?: number,
): KeystrokeResult;
getFieldActions(name: string): FieldActionEntry[];
resetForm(names?: readonly string[], options?: { exclude?: boolean }): string[];
buildSubmitPayload(action: SubmitFormAction): Promise<FormSubmitPayload>;
submitForm(action: SubmitFormAction, fieldName?: string): Promise<FormSubmitPayload>;
exportFormFdf(fileName?: string): PdfBytes;
importFormFdf(data: Uint8Array | ArrayBuffer): FormImportResult;
exportFormXfdf(fileName?: string): string;
importFormXfdf(xml: string): FormImportResult;
exportFormJson(options?: FormJsonOptions): FormJson;
importFormJson(json: unknown): FormImportResult;
exportFormXml(): string;
importFormXml(xml: string): FormImportResult;
addFormField(input: FormFieldInput): PdfFormField;
/** Proposes fields for blank lines, empty boxes and tick squares of flat pages; nothing is changed. */
detectFormFields(pageIndexes?: readonly number[]): DetectedField[];
/** Adds the proposed fields (default: those of every page) as one undo step. */
addDetectedFields(fields?: readonly DetectedField[]): PdfFormField[];
updateFormField(name: string, patch: FormFieldPatch): PdfFormField | undefined;
updateFormFields(names: readonly string[], patch: FormFieldPatch): PdfFormField[];
removeFormField(name: string): boolean;
duplicateField(name: string, options?: DuplicateFieldOptions): PdfFormField | undefined;
alignFields(targets: readonly FormFieldTarget[], mode: FieldAlignment): PdfFormField[];
distributeFields(targets: readonly FormFieldTarget[], direction: 'horizontal' | 'vertical'): PdfFormField[];
sizeFields(targets: readonly FormFieldTarget[], mode: 'width' | 'height' | 'both'): PdfFormField[];
getCalculationOrder(): string[];
setCalculationOrder(names: readonly string[]): string[];
setFieldCalculation(name: string, calculation: SimpleCalculation | null): PdfFormField | undefined;
getSignatureFields(): SignatureFieldInfo[];
fillSignatureField(name: string, signature: FieldSignatureInput): PdfAnnotation;
getTabOrder(pageIndex: number): PageTabOrder;
setTabOrder(pageIndex: number, mode: TabOrderMode): PageTabOrder;
setFieldTabOrder(pageIndex: number, widgetIds: string[]): PageTabOrder;
getSignatures(): Promise<(SignatureInfo & { fieldName: string })[]>;
movePage(from: number, to: number): void;
movePages(indices: number[], target: number): void;
rotatePages(indices: number[], degrees?: number): void;
deletePages(indices: number[]): void;
insertBlankPage(at: number, size?: { width: number; height: number }): number;
mergeDocument(data: Uint8Array | ArrayBuffer, at?: number): number;
extractPages(indices: number[], options?: { deleteExtracted?: boolean }): Promise<PdfBytes>;
replacePages(indices: number[], source: Uint8Array | ArrayBuffer, sourceIndices?: readonly number[]): number;
interleaveDocument(data: Uint8Array | ArrayBuffer, options?: InterleaveOptions): number;
mergeFiles(inputs: readonly MergeFileInput[], options?: MergeFilesOptions): Promise<MergeFilesResult>;
findBlankPages(pages?: number[], options?: BlankScanOptions & { analyzeImages?: boolean }): number[];
deleteBlankPages(pages?: number[], options?: Bla
// continues in the sourcePdfDocumentEvents#
Type.
interface PdfDocumentEvents {
annotationAdd: { annotations: PdfAnnotation[]; source: ChangeSource };
annotationChange: { changes: { before: PdfAnnotation; after: PdfAnnotation }[]; source: ChangeSource };
annotationRemove: { annotations: PdfAnnotation[]; source: ChangeSource };
formFieldChange: { name: string; value: FormValue; previousValue: FormValue; source: ChangeSource };
formFieldsChange: { added: string[]; changed: string[]; removed: string[]; source: ChangeSource };
formSubmit: { action: SubmitFormAction; payload: FormSubmitPayload; fieldName?: string };
formReset: { names: string[]; changed: string[]; source: ChangeSource };
pagesChange: { pages: PdfPageSummary[]; reason: PagesChangeReason };
historyChange: { canUndo: boolean; canRedo: boolean; undoLabel?: string; redoLabel?: string };
documentChange: { reason: string };
fontMissing: MissingGlyphReport;
formFieldReject: { name: string; value: FormValue; issue: FieldIssue; source: ChangeSource };
}PdfEncryptionInfo#
Type.
interface PdfEncryptionInfo {
algorithm: EncryptionAlgorithm;
revision: number;
isOwner: boolean;
encryptsMetadata: boolean;
}PdfInputError#
Value, from @birchui/pdf and @birchui/pdf/engine.
class PdfInputError extends TypeError {
constructor( readonly path: string, message: string, );
}PdfPageSummary#
Type.
interface PdfPageSummary {
index: number;
width: number;
height: number;
rotation: number;
box: PdfRect;
kind: PageSourceKind;
sourceIndex: number;
documentIndex: number;
key: number;
}PdfPermissionError#
Value, from @birchui/pdf and @birchui/pdf/engine.
class PdfPermissionError extends Error {
constructor(readonly permission: PdfPermissionName);
}PdfPermissionName#
Type.
type PdfPermissionName = keyof PdfPermissions | 'changeSecurity';RecognizedPage#
Type.
interface RecognizedPage extends TextLayerResult {
pageIndex: number;
status: 'recognized' | 'has-text' | 'no-image' | 'no-words';
}RecognizeTextOptions#
Type.
interface RecognizeTextOptions {
recognizeText: RecognizeTextCallback;
pages?: number[];
includePagesWithText?: boolean;
renderPage?: (pageIndex: number) => RenderedPageImage | undefined | Promise<RenderedPageImage | undefined>;
}RedactionImageDecoder#
Type.
type RedactionImageDecoder = (image: PageRedactionImage) => DecodedRedactionImage | undefined;RedactionSearchOptions#
Type.
interface RedactionSearchOptions {
pages?: number[];
caseSensitive?: boolean;
wholeWord?: boolean;
overlayText?: string;
fillColor?: string;
}RenderedPageImage#
Type.
interface RenderedPageImage {
width: number;
height: number;
data: Uint8Array;
matrix: Matrix;
}ReplyInput#
Type.
type ReplyInput = string | (Partial<AnnotationReply> & { contents: string });ResizePagesOptions#
Type.
interface ResizePagesOptions {
width: number;
height: number;
anchor?: PageAnchor;
scaleContent: boolean;
fit?: 'fit' | 'fill';
margin?: number;
}SaveMode#
Type.
type SaveMode = 'auto' | 'incremental' | 'full';SaveOptions#
Type.
interface SaveOptions {
allowMissingGlyphs?: boolean;
objectStreams?: boolean;
mode?: SaveMode;
compress?: boolean;
flatten?: FlattenMode;
linearize?: boolean;
}SaveResult#
Type.
interface SaveResult {
bytes: PdfBytes;
mode: 'incremental' | 'full';
redactions: RedactionReport[];
/** Characters that were written without a glyph, and their scripts; absent when every character was drawn. */
missingGlyphs?: MissingGlyphReport;
}Annotations#
angleBetween#
Value, from @birchui/pdf and @birchui/pdf/engine.
function angleBetween(a: PdfPoint, vertex: PdfPoint, b: PdfPoint): number;AnnotationAttachment#
Type.
interface AnnotationAttachment {
fileName: string;
mimeType?: string;
description?: string;
size?: number;
data?: Uint8Array;
relationship?: AttachmentRelationship;
}AnnotationAttachmentFile#
Type.
interface AnnotationAttachmentFile {
fileName: string;
mimeType: string;
description?: string;
data: Uint8Array;
relationship?: AttachmentRelationship;
}annotationBounds#
Value, from @birchui/pdf and @birchui/pdf/engine.
function annotationBounds(annotation: Pick<PdfAnnotation, "rect" | "rotation">): PdfRect;AnnotationChangeSet#
Type.
interface AnnotationChangeSet {
added: PdfAnnotation[];
changed: { before: PdfAnnotation; after: PdfAnnotation }[];
removed: PdfAnnotation[];
source: ChangeSource;
}annotationCorners#
Value, from @birchui/pdf and @birchui/pdf/engine.
function annotationCorners(annotation: Pick<PdfAnnotation, "rect" | "rotation">): PdfPoint[];AnnotationDefaults#
Type.
interface AnnotationDefaults {
color: string;
opacity: number;
strokeWidth: number;
fillColor?: string;
fontSize?: number;
}annotationFlags#
Value, from @birchui/pdf and @birchui/pdf/engine.
function annotationFlags(annotation: Pick<PdfAnnotation, "isHidden" | "isLocked" | "isReadOnly" | "isContentsLocked" | "isNoView" | "isPrintable">, extra?: number): number;AnnotationFont#
Type.
type AnnotationFont = 'Helvetica' | 'Times' | 'Courier';AnnotationImage#
Type.
interface AnnotationImage {
data: Uint8Array;
mimeType: 'image/png' | 'image/jpeg';
width: number;
height: number;
}AnnotationInput#
Type.
type AnnotationInput = Partial<Omit<PdfAnnotation, 'type' | 'pageIndex'>> &
Pick<PdfAnnotation, 'type' | 'pageIndex'>;annotationInputFromPreset#
Value, from @birchui/pdf and @birchui/pdf/engine.
function annotationInputFromPreset(preset: AnnotationPreset, placement: Partial<Omit<AnnotationInput, "type">> & { pageIndex: number; }): AnnotationInput;AnnotationPatch#
Type.
type AnnotationPatch = Partial<Omit<PdfAnnotation, 'id'>>;AnnotationPermissionOptions#
Type.
interface AnnotationPermissionOptions {
isDocumentReadOnly?: boolean;
canAnnotate?: boolean;
}annotationPermissions#
Value, from @birchui/pdf and @birchui/pdf/engine.
function annotationPermissions(annotation: PdfAnnotation, user: AnnotationUser | string, options?: AnnotationPermissionOptions): AnnotationPermissions;AnnotationPermissions#
Type.
interface AnnotationPermissions {
canMove: boolean;
canResize: boolean;
canEditContents: boolean;
canEditStyle: boolean;
canDelete: boolean;
canReply: boolean;
canChangeStatus: boolean;
isOwner: boolean;
}AnnotationPreset#
Type.
interface AnnotationPreset extends AnnotationPresetStyle {
id: string;
name: string;
type: AnnotationType;
}annotationPresetsFromJson#
Value, from @birchui/pdf and @birchui/pdf/engine.
function annotationPresetsFromJson(value: unknown): AnnotationPreset[];AnnotationPresetsJson#
Type.
interface AnnotationPresetsJson {
format: 'birchui-pdf-annotation-presets';
version: 1;
presets: AnnotationPreset[];
}annotationPresetsToJson#
Value, from @birchui/pdf and @birchui/pdf/engine.
function annotationPresetsToJson(presets: readonly AnnotationPreset[]): AnnotationPresetsJson;AnnotationPresetStyle#
Type.
interface AnnotationPresetStyle {
color?: string;
fillColor?: string;
opacity?: number;
strokeWidth?: number;
borderStyle?: BorderStyle;
lineEndings?: [LineEnding, LineEnding];
fontSize?: number;
fontColor?: string;
fontFamily?: AnnotationFont;
textAlign?: RichTextAlign;
icon?: NoteIcon;
iconName?: string;
stamp?: string;
stampLabel?: string;
label?: string;
measureScale?: MeasureScale;
rotation?: number;
overlayText?: string;
text?: string;
contents?: string;
width?: number;
height?: number;
}AnnotationReply#
Type.
interface AnnotationReply {
id: string;
author: string;
contents: string;
createdAt: string;
modifiedAt: string;
}annotationRichDefaults#
Value, from @birchui/pdf and @birchui/pdf/engine.
function annotationRichDefaults(annotation: Pick<PdfAnnotation, "fontSize" | "fontColor" | "color" | "fontFamily" | "textAlign">): RichTextDefaults;AnnotationsFdfImport#
Type.
interface AnnotationsFdfImport {
annotations: AnnotationInput[];
fileName?: string;
}AnnotationsFdfOptions#
Type.
interface AnnotationsFdfOptions {
fileName?: string;
includeAppearances?: boolean;
fonts?: FontRegistry;
pageRotations?: readonly number[];
}annotationsFromJson#
Value, from @birchui/pdf and @birchui/pdf/engine.
function annotationsFromJson(value: unknown): AnnotationInput[];AnnotationsJson#
Type.
interface AnnotationsJson {
format: 'birchui-pdf-annotations';
version: 1;
annotations: (Omit<PdfAnnotation, 'image'> & {
image?: { data: string; mimeType: string; width: number; height: number };
})[];
}annotationsToFdf#
Value, from @birchui/pdf and @birchui/pdf/engine.
function annotationsToFdf(annotations: readonly PdfAnnotation[], options?: AnnotationsFdfOptions): Uint8Array;annotationsToJson#
Value, from @birchui/pdf and @birchui/pdf/engine.
function annotationsToJson(annotations: readonly PdfAnnotation[]): AnnotationsJson;annotationsToXfdf#
Value, from @birchui/pdf and @birchui/pdf/engine.
function annotationsToXfdf(annotations: readonly PdfAnnotation[], fields?: readonly PdfFormField[], fileName?: string): string;AnnotationSync#
Type.
interface AnnotationSync {
receive(operations: SyncOperation | SyncOperation[]): void;
merge(snapshot: SyncSnapshot): void;
snapshot(): SyncSnapshot;
refresh(): void;
destroy(): void;
}AnnotationSyncHost#
Type.
interface AnnotationSyncHost {
getAnnotations(): PdfAnnotation[];
applyRemoteChanges(changes: RemoteAnnotationChanges): void;
subscribeAnnotationChanges(listener: (changes: SyncAnnotationChanges) => void): () => void;
}AnnotationSyncOptions#
Type.
interface AnnotationSyncOptions {
actorId: string;
send: (operations: SyncOperation[]) => void;
author?: string;
onConflict?: (conflict: SyncConflict) => void;
snapshot?: SyncSnapshot;
pageIds?: () => readonly (string | undefined)[];
}AnnotationType#
Type.
type AnnotationType =
| TextMarkupType
| ShapeType
| MeasurementType
| 'note'
| 'caret'
| 'freeText'
| 'ink'
| 'stamp'
| 'image'
| 'signature'
| 'redaction'
| 'link'
| MediaAnnotationType;AnnotationUser#
Type.
interface AnnotationUser {
name: string;
id?: string;
isAdmin?: boolean;
}ArcGeometry#
Type.
interface ArcGeometry {
center: PdfPoint;
radius: number;
startAngle: number;
sweep: number;
length: number;
}arcPoints#
Value, from @birchui/pdf and @birchui/pdf/engine.
function arcPoints(points: readonly PdfPoint[], segments?: number): PdfPoint[];arcThrough#
Value, from @birchui/pdf and @birchui/pdf/engine.
function arcThrough(start: PdfPoint, through: PdfPoint, end: PdfPoint): ArcGeometry | undefined;BorderStyle#
Type.
type BorderStyle = 'solid' | 'dashed' | 'dotted' | 'cloudy';BuiltInStamp#
Type.
type BuiltInStamp =
'Approved' | 'Draft' | 'Confidential' | 'Final' | 'NotApproved' | 'ForComment' | 'Void' | 'Received';ChangeSource#
Type.
type ChangeSource = 'user' | 'api' | 'history' | 'import' | 'remote';circleThrough#
Value, from @birchui/pdf and @birchui/pdf/engine.
function circleThrough(a: PdfPoint, b: PdfPoint, c: PdfPoint): { center: PdfPoint; radius: number; } | undefined;compareSyncClocks#
Value, from @birchui/pdf and @birchui/pdf/engine.
function compareSyncClocks(a: SyncClock, b: SyncClock): number;createAnnotationSync#
Value, from @birchui/pdf and @birchui/pdf/engine.
function createAnnotationSync(host: AnnotationSyncHost, options: AnnotationSyncOptions): AnnotationSync;createFormSync#
Value, from @birchui/pdf and @birchui/pdf/engine.
function createFormSync(host: FormSyncHost, options: FormSyncOptions): FormSync;createPageSync#
Value, from @birchui/pdf and @birchui/pdf/engine.
function createPageSync(host: PageSyncHost, options: PageSyncOptions): PageSync;createPresenceTracker#
Value, from @birchui/pdf and @birchui/pdf/engine.
function createPresenceTracker(options?: { actorId?: string; timeout?: number; onChange?: (states: PresenceState[]) => void; now?: () => number; }): PresenceTracker;DEFAULT_STYLES#
Value, from @birchui/pdf and @birchui/pdf/engine.
const DEFAULT_STYLES: Record<AnnotationType, AnnotationDefaults>;describeLinkAction#
Value, from @birchui/pdf and @birchui/pdf/engine.
function describeLinkAction(action: LinkAction | undefined): string;FILE_ATTACHMENT_ICONS#
Value, from @birchui/pdf and @birchui/pdf/engine.
const FILE_ATTACHMENT_ICONS: readonly FileAttachmentIcon[];FileAttachmentIcon#
Type.
type FileAttachmentIcon = 'PushPin' | 'Paperclip' | 'Graph' | 'Tag';formatMeasurement#
Value, from @birchui/pdf and @birchui/pdf/engine.
function formatMeasurement(annotation: Measurable): string;FormSync#
Type.
interface FormSync {
receive(operations: FormSyncOperation | FormSyncOperation[]): void;
merge(snapshot: FormSyncSnapshot): void;
snapshot(): FormSyncSnapshot;
destroy(): void;
}FormSyncConflict#
Type.
interface FormSyncConflict {
field: string;
operation: FormSyncOperation;
winner: SyncClock;
}formSyncHost#
Value, from @birchui/pdf and @birchui/pdf/engine.
function formSyncHost(document: SyncableDocument): FormSyncHost;FormSyncHost#
Type.
interface FormSyncHost {
getFormValues(): Record<string, FormSyncValue>;
setFieldValues(values: Record<string, FormSyncValue>, source: 'remote'): unknown;
subscribeFormChanges(listener: (change?: { source?: string }) => void): () => void;
isCalculated?(field: string): boolean;
}FormSyncOperation#
Type.
interface FormSyncOperation {
id: string;
kind: 'set';
field: string;
value: FormSyncValue;
author: string;
clock: SyncClock;
}FormSyncOptions#
Type.
interface FormSyncOptions {
actorId: string;
send: (operations: FormSyncOperation[]) => void;
author?: string;
onConflict?: (conflict: FormSyncConflict) => void;
snapshot?: FormSyncSnapshot;
}FormSyncSnapshot#
Type.
interface FormSyncSnapshot {
version: 1;
counter: number;
fields: { [field: string]: { clock: SyncClock; value: FormSyncValue } };
}FormSyncValue#
Type.
type FormSyncValue = string | string[] | boolean | null;fromSyncJson#
Value, from @birchui/pdf and @birchui/pdf/engine.
function fromSyncJson(value: SyncJson): unknown;hitTestAnnotation#
Value, from @birchui/pdf and @birchui/pdf/engine.
function hitTestAnnotation(annotation: PdfAnnotation, point: PdfPoint, tolerance?: number): boolean;hitTestRotated#
Value, from @birchui/pdf and @birchui/pdf/engine.
function hitTestRotated(annotation: PdfAnnotation, p: PdfPoint, tolerance?: number): boolean;ImageFormatError#
Value, from @birchui/pdf and @birchui/pdf/engine.
class ImageFormatError extends Error {
constructor(message: string);
}isAnnotationOwner#
Value, from @birchui/pdf and @birchui/pdf/engine.
function isAnnotationOwner(annotation: Pick<PdfAnnotation, "author" | "customData">, user: AnnotationUser | string): boolean;isMediaType#
Value, from @birchui/pdf and @birchui/pdf/engine.
function isMediaType(type: AnnotationType): type is MediaAnnotationType;isReadOnlyType#
Value, from @birchui/pdf and @birchui/pdf/engine.
function isReadOnlyType(type: AnnotationType): boolean;isSafeLinkUri#
Value, from @birchui/pdf and @birchui/pdf/engine.
function isSafeLinkUri(uri: string | undefined | null): boolean;isUniformRichText#
Value, from @birchui/pdf and @birchui/pdf/engine.
function isUniformRichText(paragraphs: readonly RichTextParagraph[]): boolean;layoutRichText#
Value, from @birchui/pdf and @birchui/pdf/engine.
function layoutRichText(paragraphs: readonly RichTextParagraph[], maxWidth: number, defaults?: RichTextDefaults, registry?: FontRegistry): RichTextLine[];leaveMessage#
Value, from @birchui/pdf and @birchui/pdf/engine.
function leaveMessage(actorId: string, sentAt?: number): PresenceMessage;LineEnding#
Type.
type LineEnding = 'none' | 'openArrow' | 'closedArrow' | 'circle' | 'square' | 'diamond' | 'butt';LinkAction#
Type.
type LinkAction =
| { kind: 'uri'; uri: string }
| ({ kind: 'goto' } & LinkDestination)
| { kind: 'named'; name: string }
| { kind: 'other'; actionType: string; name?: string };LinkDestination#
Type.
interface LinkDestination {
pageIndex: number;
fit?: LinkFit;
left?: number;
top?: number;
right?: number;
bottom?: number;
zoom?: number;
}LinkFit#
Type.
type LinkFit = 'page' | 'width' | 'height' | 'box' | 'boxWidth' | 'boxHeight' | 'point' | 'rect';LinkHighlightMode#
Type.
type LinkHighlightMode = 'none' | 'invert' | 'outline' | 'push';linkUriScheme#
Value, from @birchui/pdf and @birchui/pdf/engine.
function linkUriScheme(uri: string): string | undefined;Measurable#
Type.
type Measurable = Pick<PdfAnnotation, 'type' | 'line' | 'vertices' | 'measureScale'> &
Partial<Pick<PdfAnnotation, 'label' | 'rect'>>;measureDetails#
Value, from @birchui/pdf and @birchui/pdf/engine.
function measureDetails(annotation: Measurable): MeasureDetails;MeasureDetails#
Type.
interface MeasureDetails {
type: PdfAnnotation['type'];
value: number;
unit: string;
text: string;
length?: number;
perimeter?: number;
area?: number;
radius?: number;
angle?: number;
count?: number;
}MeasurementType#
Type.
type MeasurementType = 'distance' | 'perimeter' | 'area' | 'count' | 'arc' | 'angle';MeasureScale#
Type.
interface MeasureScale {
pdfUnits: number;
realUnits: number;
unit: string;
precision?: number;
}measureValue#
Value, from @birchui/pdf and @birchui/pdf/engine.
function measureValue(annotation: Measurable): number;MediaAnnotationType#
Type.
type MediaAnnotationType = 'fileAttachment' | 'sound' | 'movie' | 'screen' | 'richMedia' | 'media3d';mergeLineRects#
Value, from @birchui/pdf and @birchui/pdf/engine.
function mergeLineRects(rects: readonly PdfRect[], gap?: number): PdfRect[];NamedDestination#
Type.
interface NamedDestination extends LinkDestination {
name: string;
}normalizeDegrees#
Value, from @birchui/pdf and @birchui/pdf/engine.
function normalizeDegrees(degrees: number): number;normalizeRichText#
Value, from @birchui/pdf and @birchui/pdf/engine.
function normalizeRichText(paragraphs: readonly RichTextParagraph[]): RichTextParagraph[];NoteIcon#
Type.
type NoteIcon = 'comment' | 'note' | 'key' | 'help' | 'paragraph' | 'insert';originalPageId#
Value, from @birchui/pdf and @birchui/pdf/engine.
function originalPageId(sourceIndex: number): string;PageSync#
Type.
interface PageSync {
receive(operations: PageSyncOperation | PageSyncOperation[]): void;
merge(snapshot: PageSyncSnapshot): void;
snapshot(): PageSyncSnapshot;
pageIds(): (string | undefined)[];
destroy(): void;
}PageSyncConflict#
Type.
interface PageSyncConflict {
pageId: string;
reason: 'older-write' | 'removed';
operation: PageSyncOperation;
winner: SyncClock;
}pageSyncHost#
Value, from @birchui/pdf and @birchui/pdf/engine.
function pageSyncHost(document: SyncableDocument): PageSyncHost;PageSyncHost#
Type.
interface PageSyncHost {
getPages(): PageSyncPage[];
movePages(indices: number[], target: number): void;
rotatePages(indices: number[], degrees: number): void;
deletePages(indices: number[]): void;
insertBlankPage(at: number, size?: PageSyncSize): number;
subscribePageChanges(listener: () => void): () => void;
}PageSyncOperation#
Type.
interface PageSyncOperation {
id: string;
kind: PageSyncOperationKind;
pageId: string;
position?: string;
rotation?: number;
size?: PageSyncSize;
author: string;
clock: SyncClock;
}PageSyncOperationKind#
Type.
type PageSyncOperationKind = 'insert' | 'move' | 'rotate' | 'delete';PageSyncOptions#
Type.
interface PageSyncOptions {
actorId: string;
send: (operations: PageSyncOperation[]) => void;
author?: string;
onConflict?: (conflict: PageSyncConflict) => void;
onApply?: () => void;
snapshot?: PageSyncSnapshot;
}PageSyncPage#
Type.
interface PageSyncPage {
key: number | string;
kind: string;
sourceIndex: number;
rotation: number;
width: number;
height: number;
}PageSyncSize#
Type.
interface PageSyncSize {
width: number;
height: number;
}PageSyncSnapshot#
Type.
interface PageSyncSnapshot {
version: 1;
counter: number;
pages: PageSyncSnapshotEntry[];
}PageSyncSnapshotEntry#
Type.
interface PageSyncSnapshotEntry {
id: string;
position?: { clock: SyncClock; value: string };
rotation?: { clock: SyncClock; value: number };
removed?: SyncClock;
size?: PageSyncSize;
}parseAnnotationsFdf#
Value, from @birchui/pdf and @birchui/pdf/engine.
function parseAnnotationsFdf(data: Uint8Array | ArrayBuffer, fallbackAuthor?: string): AnnotationsFdfImport;parseRichText#
Value, from @birchui/pdf and @birchui/pdf/engine.
function parseRichText(xhtml: string, defaults?: Partial<RichTextDefaults>): RichTextParagraph[] | undefined;parseXfdf#
Value, from @birchui/pdf and @birchui/pdf/engine.
function parseXfdf(xml: string): XfdfImport;PdfAnnotation#
Type.
interface PdfAnnotation {
id: string;
type: AnnotationType;
pageIndex: number;
rect: PdfRect;
color: string;
opacity: number;
strokeWidth: number;
author: string;
createdAt: string;
modifiedAt: string;
contents?: string;
replies?: AnnotationReply[];
status?: ReviewStatus;
statusAuthor?: string;
statusModifiedAt?: string;
replacedQuadPoints?: number[];
fillColor?: string;
dashed?: boolean;
borderStyle?: BorderStyle;
rotation?: number;
quadPoints?: number[];
inkList?: PdfPoint[][];
vertices?: PdfPoint[];
line?: [PdfPoint, PdfPoint];
lineEndings?: [LineEnding, LineEnding];
text?: string;
fontSize?: number;
fontColor?: string;
textAlign?: 'left' | 'center' | 'right';
fontFamily?: AnnotationFont;
calloutLine?: PdfPoint[];
groupId?: string;
icon?: NoteIcon;
stamp?: BuiltInStamp | string;
stampLabel?: string;
image?: AnnotationImage;
signatureKind?: 'drawn' | 'typed' | 'image';
measureScale?: MeasureScale;
overlayText?: string;
url?: string;
destinationPage?: number;
isLocked?: boolean;
isHidden?: boolean;
isReadOnly?: boolean;
isContentsLocked?: boolean;
isNoView?: boolean;
isPrintable?: boolean;
richText?: RichTextParagraph[];
action?: LinkAction;
highlightMode?: LinkHighlightMode;
label?: string;
iconName?: string;
attachment?: AnnotationAttachment;
customData?: Record<string, unknown>;
}PdfPoint#
Type.
interface PdfPoint {
x: number;
y: number;
}PdfRect#
Type.
type PdfRect = [x1: number, y1: number, x2: number, y2: number];PLACEHOLDER_PAGE_ID#
Value, from @birchui/pdf and @birchui/pdf/engine.
const PLACEHOLDER_PAGE_ID: "placeholder";plainToRichText#
Value, from @birchui/pdf and @birchui/pdf/engine.
function plainToRichText(text: string, style?: Omit<RichTextRun, "text">): RichTextParagraph[];polygonArea#
Value, from @birchui/pdf and @birchui/pdf/engine.
function polygonArea(points: readonly PdfPoint[]): number;polylineLength#
Value, from @birchui/pdf and @birchui/pdf/engine.
function polylineLength(points: readonly PdfPoint[], isClosed?: boolean): number;positionBetween#
Value, from @birchui/pdf and @birchui/pdf/engine.
function positionBetween(before: string | undefined, after: string | undefined, actor?: string): string;presenceMessage#
Value, from @birchui/pdf and @birchui/pdf/engine.
function presenceMessage(state: PresenceState, sentAt?: number): PresenceMessage;PresenceMessage#
Type.
type PresenceMessage =
{ type: 'presence'; state: PresenceState; sentAt: number } | { type: 'leave'; actorId: string; sentAt: number };PresenceState#
Type.
interface PresenceState {
actorId: string;
name: string;
color: string;
pageIndex?: number;
point?: PdfPoint;
selection?: string[];
viewPageIndex?: number;
}PresenceTracker#
Type.
interface PresenceTracker {
receive(message: PresenceMessage): void;
list(): PresenceState[];
get(actorId: string): PresenceState | undefined;
prune(now?: number): string[];
clear(): void;
}presetFromAnnotation#
Value, from @birchui/pdf and @birchui/pdf/engine.
function presetFromAnnotation(annotation: PdfAnnotation, identity: { id: string; name: string; }, options?: { keepText?: boolean; keepSize?: boolean; }): AnnotationPreset;presetStyle#
Value, from @birchui/pdf and @birchui/pdf/engine.
function presetStyle(preset: AnnotationPreset): AnnotationPresetStyle;quadPointsFromRects#
Value, from @birchui/pdf and @birchui/pdf/engine.
function quadPointsFromRects(rects: readonly PdfRect[]): number[];quadsFromQuadPoints#
Value, from @birchui/pdf and @birchui/pdf/engine.
function quadsFromQuadPoints(quadPoints: readonly number[]): [PdfPoint, PdfPoint, PdfPoint, PdfPoint][];readImageInfo#
Value, from @birchui/pdf and @birchui/pdf/engine.
function readImageInfo(bytes: Uint8Array): AnnotationImage;rectsFromQuadPoints#
Value, from @birchui/pdf and @birchui/pdf/engine.
function rectsFromQuadPoints(quadPoints: readonly number[]): PdfRect[];RemoteAnnotationChanges#
Type.
interface RemoteAnnotationChanges {
upsert: PdfAnnotation[];
remove: string[];
}resizeRotated#
Value, from @birchui/pdf and @birchui/pdf/engine.
function resizeRotated(annotation: Pick<PdfAnnotation, "rect" | "rotation">, handle: "n" | "s" | "e" | "w" | "ne" | "nw" | "se" | "sw", pointer: PdfPoint, minSize?: number): PdfRect;ReviewStatus#
Type.
type ReviewStatus = 'none' | 'accepted' | 'rejected' | 'cancelled' | 'completed';RICH_TEXT_DEFAULTS#
Value, from @birchui/pdf and @birchui/pdf/engine.
const RICH_TEXT_DEFAULTS: RichTextDefaults;RichTextAlign#
Type.
type RichTextAlign = 'left' | 'center' | 'right';RichTextDefaults#
Type.
interface RichTextDefaults {
fontSize: number;
color: string;
fontFamily: string;
align: RichTextAlign;
}richTextDefaultStyle#
Value, from @birchui/pdf and @birchui/pdf/engine.
function richTextDefaultStyle(defaults?: RichTextDefaults): string;RichTextLine#
Type.
interface RichTextLine {
pieces: { text: string; style: ResolvedStyle; width: number }[];
width: number;
fontSize: number;
align: RichTextAlign;
}RichTextParagraph#
Type.
interface RichTextParagraph {
runs: RichTextRun[];
align?: RichTextAlign;
}RichTextRun#
Type.
interface RichTextRun {
text: string;
bold?: boolean;
italic?: boolean;
underline?: boolean;
strikethrough?: boolean;
color?: string;
fontSize?: number;
fontFamily?: string;
}richTextToPlain#
Value, from @birchui/pdf and @birchui/pdf/engine.
function richTextToPlain(paragraphs: readonly RichTextParagraph[]): string;richTextToXhtml#
Value, from @birchui/pdf and @birchui/pdf/engine.
function richTextToXhtml(paragraphs: readonly RichTextParagraph[], defaults?: RichTextDefaults): string;rotateAnnotation#
Value, from @birchui/pdf and @birchui/pdf/engine.
function rotateAnnotation(annotation: PdfAnnotation, degrees: number): AnnotationPatch;rotatedBounds#
Value, from @birchui/pdf and @birchui/pdf/engine.
function rotatedBounds(rect: PdfRect, degrees: number): PdfRect;rotatedCorners#
Value, from @birchui/pdf and @birchui/pdf/engine.
function rotatedCorners(rect: PdfRect, degrees: number): [PdfPoint, PdfPoint, PdfPoint, PdfPoint];rotationFromPointer#
Value, from @birchui/pdf and @birchui/pdf/engine.
function rotationFromPointer(annotation: Pick<PdfAnnotation, "rect">, pointer: PdfPoint, snap?: number): number;rotationHandlePoint#
Value, from @birchui/pdf and @birchui/pdf/engine.
function rotationHandlePoint(annotation: Pick<PdfAnnotation, "rect" | "rotation">, offset?: number): PdfPoint;setAnnotationRotation#
Value, from @birchui/pdf and @birchui/pdf/engine.
function setAnnotationRotation(annotation: PdfAnnotation, degrees: number): AnnotationPatch;ShapeType#
Type.
type ShapeType = 'rectangle' | 'ellipse' | 'line' | 'arrow' | 'polygon' | 'polyline';simplifyPath#
Value, from @birchui/pdf and @birchui/pdf/engine.
function simplifyPath(points: readonly PdfPoint[], tolerance?: number): PdfPoint[];smoothStroke#
Value, from @birchui/pdf and @birchui/pdf/engine.
function smoothStroke(points: readonly PdfPoint[]): PdfPoint[];STAMP_COLORS#
Value, from @birchui/pdf and @birchui/pdf/engine.
const STAMP_COLORS: Record<string, string>;STAMP_LABELS#
Value, from @birchui/pdf and @birchui/pdf/engine.
const STAMP_LABELS: Record<string, string>;StandardFont#
Type.
type StandardFont =
| 'Helvetica'
| 'Helvetica-Bold'
| 'Helvetica-Oblique'
| 'Helvetica-BoldOblique'
| 'Times-Roman'
| 'Times-Bold'
| 'Times-Italic'
| 'Times-BoldItalic'
| 'Courier'
| 'Courier-Bold'
| 'Courier-Oblique'
| 'Courier-BoldOblique'
| 'Symbol'
| 'ZapfDingbats';SyncableDocument#
Type.
interface SyncableDocument {
on(event: DocumentSyncEvent, listener: (payload: object) => void): () => void;
getFormValues(): Record<string, FormSyncValue>;
setFormValues(values: Record<string, FormSyncValue>): unknown;
getFormField?(name: string): { calculation?: unknown; scripts?: { calculate?: string } } | undefined;
getPages(): PageSyncPage[];
movePages(indices: number[], target: number): void;
rotatePages(indices: number[], degrees?: number): void;
deletePages(indices: number[]): void;
insertBlankPage(at: number, size?: PageSyncSize): number;
}SyncAnnotationChanges#
Type.
interface SyncAnnotationChanges {
added: PdfAnnotation[];
changed: { before: PdfAnnotation; after: PdfAnnotation }[];
removed: PdfAnnotation[];
source: string;
}SyncClock#
Type.
interface SyncClock {
counter: number;
actor: string;
}SyncConflict#
Type.
interface SyncConflict {
annotationId: string;
reason: 'older-write' | 'removed';
keys: string[];
operation: SyncOperation;
winner: SyncClock;
}SyncJson#
Type.
type SyncJson = string | number | boolean | null | SyncJson[] | { [key: string]: SyncJson };SyncOperation#
Type.
interface SyncOperation {
id: string;
kind: SyncOperationKind;
annotationId: string;
payload: { [key: string]: SyncJson };
author: string;
clock: SyncClock;
}SyncOperationKind#
Type.
type SyncOperationKind = 'add' | 'update' | 'remove' | 'reply-add' | 'reply-update' | 'reply-remove';SyncSnapshot#
Type.
interface SyncSnapshot {
version: 1;
counter: number;
entries: SyncSnapshotEntry[];
forms?: FormSyncSnapshot;
pages?: PageSyncSnapshot;
}SyncSnapshotEntry#
Type.
interface SyncSnapshotEntry {
id: string;
added?: SyncClock;
removed?: SyncClock;
groups: { [group: string]: { clock: SyncClock; values: { [key: string]: SyncJson } } };
replies: {
[replyId: string]: {
clock: SyncClock;
added?: SyncClock;
removed?: SyncClock;
reply?: { [key: string]: SyncJson };
};
};
}TextMarkupType#
Type.
type TextMarkupType = 'highlight' | 'underline' | 'strikeout' | 'squiggly';toRotatedPoint#
Value, from @birchui/pdf and @birchui/pdf/engine.
function toRotatedPoint(annotation: Pick<PdfAnnotation, "rect" | "rotation">, p: PdfPoint): PdfPoint;toSyncJson#
Value, from @birchui/pdf and @birchui/pdf/engine.
function toSyncJson(value: unknown): SyncJson;toUnrotatedPoint#
Value, from @birchui/pdf and @birchui/pdf/engine.
function toUnrotatedPoint(annotation: Pick<PdfAnnotation, "rect" | "rotation">, p: PdfPoint): PdfPoint;unrotatedRectFromBounds#
Value, from @birchui/pdf and @birchui/pdf/engine.
function unrotatedRectFromBounds(bounds: PdfRect, degrees: number, aspect?: number): PdfRect | undefined;uprightPlacement#
Value, from @birchui/pdf and @birchui/pdf/engine.
function uprightPlacement(rect: PdfRect, pageRotation: number): { rect: PdfRect; rotation: number | undefined; };uprightRotation#
Value, from @birchui/pdf and @birchui/pdf/engine.
function uprightRotation(pageRotation: number): number;viewportTransform#
Value, from @birchui/pdf and @birchui/pdf/engine.
function viewportTransform(box: PdfRect, rotation: number, scale: number): Matrix;XfdfImport#
Type.
interface XfdfImport {
annotations: AnnotationInput[];
fields: Record<string, FormValue>;
}Forms#
BarcodeFieldInfo#
Type.
interface BarcodeFieldInfo {
symbology: 'pdf417' | 'qrCode' | 'dataMatrix' | 'unknown';
}checkFieldValue#
Value, from @birchui/pdf and @birchui/pdf/engine.
function checkFieldValue(field: ValidatedField, value: FormValue, resolve?: FieldValueResolver): FieldIssue | undefined;classifyScript#
Value, from @birchui/pdf and @birchui/pdf/engine.
function classifyScript(trigger: FieldScriptTrigger, source: string | undefined): FieldScriptInfo;describeScripts#
Value, from @birchui/pdf and @birchui/pdf/engine.
function describeScripts(field: Pick<PdfFormField, "format" | "calculation" | "range" | "scripts">): FieldScriptReport;DetectedField#
Type.
interface DetectedField {
type: 'text' | 'checkbox';
pageIndex: number;
rect: PdfRect;
name: string;
/** The text on the page the name was taken from. */
label?: string;
isMultiline?: boolean;
source: 'underline' | 'box' | 'square' | 'underscores';
}detectFields#
Value, from @birchui/pdf/engine.
function detectFields(shapes: readonly DetectionShape[], text: PageTextStructure, pageIndex: number, options?: DetectFieldsOptions): DetectedField[];DetectFieldsOptions#
Type.
interface DetectFieldsOptions {
/** Names that are taken already; detected names are made different from these and from each other. */
takenNames?: Iterable<string>;
/** Rectangles of fields the page has already; a candidate that overlaps one is left out. */
existing?: readonly PdfRect[];
}DetectionShape#
Type.
interface DetectionShape {
rect: PdfRect;
/** The painting operator of the path: `S`, `f`, `B` and their variants. */
operator: string;
}DuplicateFieldOptions#
Type.
interface DuplicateFieldOptions {
offset?: [number, number];
pageIndex?: number;
newName?: string;
}FieldAction#
Type.
type FieldAction =
| SubmitFormAction
| ResetFormAction
| { type: 'javaScript'; script: string }
| { type: 'named'; name: string }
| { type: 'goTo'; pageIndex?: number; destination?: string }
| { type: 'uri'; uri: string }
| { type: 'hide'; fields: string[]; isHidden: boolean }
| { type: 'other'; subtype: string };FieldActionEntry#
Type.
interface FieldActionEntry {
trigger: FieldActionTrigger;
widgetIndex?: number;
action: FieldAction;
}FieldActionTrigger#
Type.
type FieldActionTrigger =
| 'activate'
| 'mouseUp'
| 'mouseDown'
| 'mouseEnter'
| 'mouseExit'
| 'focus'
| 'blur'
| 'keystroke'
| 'format'
| 'validate'
| 'calculate';FieldAlignment#
Type.
type FieldAlignment = 'left' | 'right' | 'top' | 'bottom' | 'center' | 'middle';FieldCalculation#
Type.
interface FieldCalculation {
operation: 'SUM' | 'AVG' | 'PRD' | 'MIN' | 'MAX' | 'CUSTOM';
fields: string[];
expression?: string;
}FieldFormat#
Type.
type FieldFormat =
| {
kind: 'number';
decimals: number;
separatorStyle: number;
negativeStyle: number;
currency: string;
isCurrencyPrepended: boolean;
}
| { kind: 'percent'; decimals: number; separatorStyle: number }
| { kind: 'date'; pattern: string }
| { kind: 'time'; pattern: string }
| { kind: 'special'; mask: 'zip' | 'zip4' | 'phone' | 'ssn' }
| { kind: 'mask'; mask: string };FieldIssue#
Type.
interface FieldIssue {
code: FormIssueCode;
key: FormMessageKey;
params: FormMessageParams;
message: string;
}fieldKind#
Value, from @birchui/pdf and @birchui/pdf/engine.
function fieldKind(field: Pick<PdfFormField, "type" | "barcode">): PdfFieldType;FieldRange#
Type.
interface FieldRange {
min?: number;
max?: number;
}FieldScriptInfo#
Type.
interface FieldScriptInfo {
status: 'supported' | 'unsupported' | 'none';
kind: 'none' | 'builtin' | 'expression' | 'custom';
source: string;
}FieldScriptReport#
Type.
type FieldScriptReport = Record<FieldScriptTrigger, FieldScriptInfo>;FieldScripts#
Type.
interface FieldScripts {
format?: string;
keystroke?: string;
validate?: string;
calculate?: string;
}FieldScriptTrigger#
Type.
type FieldScriptTrigger = keyof FieldScripts;FieldSignatureInput#
Type.
type FieldSignatureInput =
| { kind: 'image'; image: AnnotationImage }
| { kind: 'drawn'; inkList: PdfPoint[][]; strokeWidth?: number; color?: string }
| { kind: 'typed'; text: string };filterFieldKeystroke#
Value, from @birchui/pdf and @birchui/pdf/engine.
function filterFieldKeystroke(field: KeystrokeField, currentValue: string, change: string, selStart: number, selEnd?: number): KeystrokeResult;FlattenMode#
Type.
type FlattenMode = 'forms' | 'annotations' | 'all';FORM_MESSAGES#
Value, from @birchui/pdf and @birchui/pdf/engine.
const FORM_MESSAGES: Record<FormMessageKey, string>;formatFieldValue#
Value, from @birchui/pdf and @birchui/pdf/engine.
function formatFieldValue(field: Pick<PdfFormField, "format" | "value"> & { scripts?: FieldScripts; }, value?: FormValue): string;formatFormMessage#
Value, from @birchui/pdf and @birchui/pdf/engine.
function formatFormMessage(key: FormMessageKey, params?: FormMessageParams, messages?: Partial<Record<FormMessageKey, string>>): string;FormFieldInput#
Type.
interface FormFieldInput {
name: string;
type: FormFieldType;
pageIndex: number;
rect: PdfRect;
value?: FormValue;
options?: (FormFieldOption | string)[];
tooltip?: string;
isReadOnly?: boolean;
isRequired?: boolean;
isMultiline?: boolean;
isPassword?: boolean;
isComb?: boolean;
maxLength?: number;
isMultiSelect?: boolean;
isEditable?: boolean;
alignment?: 'left' | 'center' | 'right';
fontSize?: number;
borderColor?: string | null;
backgroundColor?: string | null;
format?: FieldFormat;
calculation?: FieldCalculation;
range?: FieldRange;
radioValue?: string;
isNoExport?: boolean;
richText?: RichTextParagraph[];
}FormFieldOption#
Type.
interface FormFieldOption {
value: string;
label: string;
}FormFieldPatch#
Type.
type FormFieldPatch = Partial<Omit<FormFieldInput, 'name' | 'type'>> & { widgetIndex?: number };FormFieldTarget#
Type.
type FormFieldTarget = string | { name: string; widgetIndex?: number };FormFieldType#
Type.
type FormFieldType = 'text' | 'checkbox' | 'radio' | 'combo' | 'list' | 'signature' | 'button';FormFieldWidget#
Type.
interface FormFieldWidget {
id: string;
pageIndex: number;
rect: PdfRect;
onValue?: string;
exportValue?: string;
isHidden?: boolean;
tabIndex?: number;
rotation?: 90 | 180 | 270;
}FormImportRejection#
Type.
interface FormImportRejection {
name: string;
code: FormIssueCode | 'option' | 'type';
key: FormMessageKey;
params: FormMessageParams;
message: string;
}FormImportResult#
Type.
interface FormImportResult {
imported: number;
changed: string[];
unknown: string[];
rejected: FormImportRejection[];
}FormIssue#
Type.
interface FormIssue extends FieldIssue {
name: string;
pageIndex: number;
rect: PdfRect;
}FormIssueCode#
Type.
type FormIssueCode = 'required' | 'format' | 'range' | 'script' | 'maxLength' | 'pattern';FormJson#
Type.
type FormJson = { [name: string]: FormJsonValue };FormJsonOptions#
Type.
interface FormJsonOptions {
flat?: boolean;
}FormJsonValue#
Type.
type FormJsonValue = string | boolean | null | string[] | FormJson;FormMessageKey#
Type.
type FormMessageKey =
| 'required'
| 'maxLength'
| 'number'
| 'rangeMin'
| 'rangeMax'
| 'date'
| 'time'
| 'special'
| 'mask'
| 'script'
| 'option'
| 'readOnlyType';FormMessageParams#
Type.
type FormMessageParams = Record<string, string | number>;FormState#
Type.
interface FormState {
isDirty: boolean;
dirtyFields: string[];
isValid: boolean;
fieldCount: number;
filledCount: number;
requiredCount: number;
requiredFilledCount: number;
}FormSubmitPayload#
Type.
interface FormSubmitPayload {
url: string;
method: 'get' | 'post';
format: SubmitFormat;
body: PdfBytes | string;
contentType: string;
fieldNames: string[];
}FormValue#
Type.
type FormValue = string | string[] | boolean | null;KeystrokeResult#
Type.
interface KeystrokeResult {
isAccepted: boolean;
value: string;
selStart: number;
selEnd: number;
key?: FormMessageKey;
}PageTabOrder#
Type.
interface PageTabOrder {
pageIndex: number;
mode: TabOrderMode;
widgets: TabOrderEntry[];
}parseCalculateScript#
Value, from @birchui/pdf and @birchui/pdf/engine.
function parseCalculateScript(script: string | undefined): FieldCalculation | undefined;parseFormatScript#
Value, from @birchui/pdf and @birchui/pdf/engine.
function parseFormatScript(script: string | undefined): FieldFormat | undefined;parseValidateScript#
Value, from @birchui/pdf and @birchui/pdf/engine.
function parseValidateScript(script: string | undefined): FieldRange | undefined;PdfFieldType#
Type.
type PdfFieldType = FormFieldType | 'barcode';PdfFormField#
Type.
interface PdfFormField {
name: string;
type: FormFieldType;
value: FormValue;
defaultValue: FormValue;
widgets: FormFieldWidget[];
options?: FormFieldOption[];
tooltip?: string;
isReadOnly: boolean;
isRequired: boolean;
isMultiline?: boolean;
isPassword?: boolean;
isComb?: boolean;
maxLength?: number;
isMultiSelect?: boolean;
isEditable?: boolean;
alignment?: 'left' | 'center' | 'right';
fontSize?: number;
borderColor?: string | null;
backgroundColor?: string | null;
format?: FieldFormat;
calculation?: FieldCalculation;
range?: FieldRange;
signature?: SignatureInfo;
scripts?: FieldScripts;
isNoExport?: boolean;
isNoToggleToOff?: boolean;
isRadiosInUnison?: boolean;
isRichText?: boolean;
richText?: RichTextParagraph[];
actions?: FieldActionEntry[];
signatureLock?: SignatureFieldLock;
barcode?: BarcodeFieldInfo;
}RECOGNISED_FUNCTIONS#
Value, from @birchui/pdf and @birchui/pdf/engine.
const RECOGNISED_FUNCTIONS: readonly string[];ResetFormAction#
Type.
interface ResetFormAction {
type: 'resetForm';
fields: string[];
isExclude: boolean;
}SignatureFieldInfo#
Type.
interface SignatureFieldInfo {
name: string;
pageIndex: number;
rect: PdfRect;
isSigned: boolean;
isRequired: boolean;
isReadOnly: boolean;
lock?: SignatureFieldLock;
}SignatureFieldLock#
Type.
interface SignatureFieldLock {
action: 'all' | 'include' | 'exclude';
fields: string[];
}SignatureInfo#
Type.
interface SignatureInfo {
signerName?: string;
signedAt?: string;
reason?: string;
location?: string;
filter?: string;
subFilter?: string;
byteRange?: number[];
coversWholeFile: boolean;
hasLaterChanges: boolean;
integrity: 'unchecked' | 'intact' | 'modified' | 'unsupported';
}SimpleCalculation#
Type.
type SimpleCalculation =
{ op: 'sum' | 'product' | 'average' | 'min' | 'max'; fields: string[] } | { expression: string };SubmitFormAction#
Type.
interface SubmitFormAction {
type: 'submitForm';
url: string;
flags: number;
format: SubmitFormat;
method: 'get' | 'post';
fields: string[];
isExclude: boolean;
includeEmpty: boolean;
}SubmitFormat#
Type.
type SubmitFormat = 'fdf' | 'xfdf' | 'html' | 'pdf';TabOrderMode#
Type.
type TabOrderMode = 'row' | 'column' | 'structure' | 'manual' | 'unspecified';validateFieldValue#
Value, from @birchui/pdf and @birchui/pdf/engine.
function validateFieldValue(field: ValidatedField, value: FormValue, resolve?: FieldValueResolver): string | undefined;Text, geometry and redaction search#
PageGeometry#
Type.
interface PageGeometry {
points: PdfPoint[];
segments: PdfSegment[];
baselines: PdfSegment[];
textBoxes: PageTextBox[];
isTruncated: boolean;
}PageGeometryOptions#
Type.
interface PageGeometryOptions {
maxPoints?: number;
maxSegments?: number;
maxTextRuns?: number;
bounds?: PdfRect;
includeText?: boolean;
includePaths?: boolean;
includeImages?: boolean;
}PageTextBox#
Type.
interface PageTextBox {
rect: PdfRect;
quad: PdfQuad;
}PageTextDirection#
Type.
type PageTextDirection = 'ltr' | 'rtl' | 'ttb';PageTextItem#
Type.
interface PageTextItem {
text: string;
rect: PdfRect;
quad: PdfQuad;
baseline: [PdfPoint, PdfPoint];
fontName?: string;
fontSize: number;
isBold: boolean;
isItalic: boolean;
rotation: number;
direction: PageTextDirection;
lineIndex: number;
hasSpaceAfter: boolean;
charQuads?: PdfQuad[];
}PageTextLine#
Type.
interface PageTextLine {
text: string;
rect: PdfRect;
quad: PdfQuad;
baseline: [PdfPoint, PdfPoint];
fontSize: number;
rotation: number;
direction: PageTextDirection;
items: PageTextItem[];
}PageTextOrder#
Type.
type PageTextOrder = 'reading' | 'content';PageTextStructure#
Type.
interface PageTextStructure {
text: string;
lines: PageTextLine[];
items: PageTextItem[];
/** With `markedContent` and content order: lines and marked-content boundaries as they follow each other. */
sequence?: (PageTextLine | PageTextMark)[];
}PdfQuad#
Type.
type PdfQuad = [bottomLeft: PdfPoint, bottomRight: PdfPoint, topRight: PdfPoint, topLeft: PdfPoint];PdfSegment#
Type.
type PdfSegment = [x1: number, y1: number, x2: number, y2: number];quadPointsFromQuads#
Value, from @birchui/pdf and @birchui/pdf/engine.
function quadPointsFromQuads(quads: readonly PdfQuad[]): number[];REDACTION_PATTERN_NAMES#
Value, from @birchui/pdf and @birchui/pdf/engine.
const REDACTION_PATTERN_NAMES: readonly ("date" | "email" | "phone" | "ssn" | "creditCard" | "iban")[];REDACTION_PATTERNS#
Value, from @birchui/pdf and @birchui/pdf/engine.
const REDACTION_PATTERNS: { readonly email: RegExp; readonly phone: RegExp; readonly ssn: RegExp; readonly creditCard: RegExp; readonly iban: RegExp; readonly date: RegExp; };RedactionPattern#
Type.
type RedactionPattern = RedactionPatternName;RedactionPatternName#
Type.
type RedactionPatternName = keyof typeof REDACTION_PATTERNS;RedactionQuery#
Type.
type RedactionQuery =
| string
| RegExp
| { text: string; matchCase?: boolean; wholeWord?: boolean }
| { pattern: RegExp }
| { preset: RedactionPatternName };TextMatch#
Type.
interface TextMatch {
start: number;
end: number;
text: string;
rects: PdfRect[];
}Content editing#
AddImageOptions#
Type.
interface AddImageOptions {
data: Uint8Array;
rect: PdfRect;
opacity?: number;
rotation?: number;
}AddMarkOptions#
Type.
interface AddMarkOptions {
kind: PageMarkKind;
/** Centre of the mark. */
x: number;
y: number;
size?: number;
color?: string;
}AddTextOptions#
Type.
interface AddTextOptions {
text: string;
x: number;
y: number;
fontSize?: number;
color?: string;
opacity?: number;
font?: StandardFontName;
/** Name of a supplied font to use instead of a standard one. */
fontName?: string;
rotation?: number;
lineHeight?: number;
fonts?: FontRegistry;
}AddTextResult#
Type.
interface AddTextResult extends TextEditResult {
rect?: PdfRect;
}ContentEditFailure#
Type.
type ContentEditFailure =
| 'stale-hit'
| 'unsupported-font'
| 'missing-glyphs'
| 'empty-text'
| 'unsupported-image'
| 'not-invertible'
| 'unsupported-object';EditableTextMatch#
Type.
interface EditableTextMatch {
/** The block of text in reading order, then the position of the match in it. */
id: string;
text: string;
before: string;
after: string;
rect: PdfRect;
/** Whether replacing reflows a paragraph or rewrites one text run. */
scope: 'paragraph' | 'run';
start: number;
end: number;
}EncodedImageMimeType#
Type.
type EncodedImageMimeType = 'image/jpeg' | 'image/jp2' | 'image/x-jbig2' | 'image/g3fax';ExtractedImage#
Type.
interface ExtractedImage {
id: string;
index: number;
name: string;
isInline: boolean;
ref?: PdfRef;
rect: PdfRect;
quad: [PdfPoint, PdfPoint, PdfPoint, PdfPoint];
matrix: Matrix;
width: number;
height: number;
bitsPerComponent: number;
colorSpace?: string;
filters: string[];
format: PageImageFormat;
isMask: boolean;
hasMask: boolean;
status: ExtractedImageStatus;
data?: ExtractedImagePixels;
encoded?: ExtractedImageEncoding;
isRendered?: boolean;
message?: string;
}ExtractedImageEncoding#
Type.
interface ExtractedImageEncoding {
mimeType: EncodedImageMimeType;
filter: string;
bytes: Uint8Array;
decodeParms?: Record<string, number | boolean>;
jbig2Globals?: Uint8Array;
}ExtractedImagePixels#
Type.
interface ExtractedImagePixels {
width: number;
height: number;
rgba: Uint8Array;
}ExtractedImageStatus#
Type.
type ExtractedImageStatus = 'decoded' | 'encoded-only' | 'unsupported';FindTextOptions#
Type.
interface FindTextOptions {
matchCase?: boolean;
wholeWord?: boolean;
}ImageEditResult#
Type.
interface ImageEditResult {
ok: boolean;
reason?: ContentEditFailure;
message?: string;
name?: string;
ref?: PdfRef;
rect?: PdfRect;
image?: PageImage;
}ImageMove#
Type.
type ImageMove = { dx: number; dy: number } | { rect: PdfRect } | { matrix: Matrix };ObjectEditResult#
Type.
interface ObjectEditResult {
ok: boolean;
reason?: ContentEditFailure;
message?: string;
object?: PageObject;
}ObjectOrder#
Type.
type ObjectOrder = 'front' | 'forward' | 'backward' | 'back';OcrPageImage#
Type.
interface OcrPageImage {
pageIndex: number;
width: number;
height: number;
data: Uint8Array;
}OcrWord#
Type.
interface OcrWord {
text: string;
rect: [number, number, number, number];
}PageImage#
Type.
interface PageImage {
id: string;
index: number;
name: string;
ref?: PdfRef;
rect: PdfRect;
quad: [PdfPoint, PdfPoint, PdfPoint, PdfPoint];
matrix: Matrix;
width: number;
height: number;
filter?: string;
format: PageImageFormat;
bitsPerComponent: number;
colorSpace?: string;
isMask: boolean;
hasAlpha: boolean;
/** Constant opacity set next to the image, 1 when none. */
opacity: number;
/** The shown part in image space (0 to 1 from the lower left corner), when the image is cropped. */
crop?: [x0: number, y0: number, x1: number, y1: number];
/** Bounding box of the shown part on the page. */
visibleRect: PdfRect;
}PageImageFormat#
Type.
type PageImageFormat = 'raw' | 'jpeg' | 'jpeg2000' | 'jbig2' | 'ccitt' | 'unknown';PageMarkKind#
Type.
type PageMarkKind = 'tick' | 'cross' | 'dot' | 'circle';PageObject#
Type.
interface PageObject {
id: string;
kind: PageObjectKind;
/** Operation that paints the object, and the first operation that belongs to it. */
index: number;
firstIndex: number;
/** Position in paint order, 0 is painted first. */
order: number;
rect: PdfRect;
operator: string;
label: string;
matrix: Matrix;
hasClip?: boolean;
isInvisible?: boolean;
layer?: PageObjectLayer;
}PageObjectKind#
Type.
type PageObjectKind = 'text' | 'image' | 'path' | 'form' | 'shading' | 'inlineImage';PageObjectLayer#
Type.
type PageObjectLayer = 'watermark' | 'header' | 'footer' | 'background' | 'pageNumbers' | 'bates';ParagraphEditOptions#
Type.
interface ParagraphEditOptions {
fonts?: FontRegistry;
width?: number;
/** Move the text, images and shapes under the paragraph down when it needs more lines than before. */
pushBelow?: boolean;
}ParagraphEditResult#
Type.
interface ParagraphEditResult extends TextEditResult {
lines?: string[];
rect?: PdfRect;
overflow?: number;
/** How many objects under the paragraph were moved down to make room. */
pushed?: number;
}RecognizeTextCallback#
Type.
type RecognizeTextCallback = (image: OcrPageImage) => OcrWord[] | Promise<OcrWord[]>;ReplaceTextResult#
Type.
interface ReplaceTextResult {
replaced: number;
failed: { id: string; text: string; reason: ContentEditFailure; message: string }[];
}RestyleResult#
Type.
interface RestyleResult extends TextEditResult {
rect?: PdfRect;
isSynthetic?: boolean;
}StandardFontName#
Type.
type StandardFontName =
| 'Helvetica'
| 'Helvetica-Bold'
| 'Helvetica-Oblique'
| 'Helvetica-BoldOblique'
| 'Times-Roman'
| 'Times-Bold'
| 'Times-Italic'
| 'Times-BoldItalic'
| 'Courier'
| 'Courier-Bold'
| 'Courier-Oblique'
| 'Courier-BoldOblique';TextEditResult#
Type.
interface TextEditResult {
ok: boolean;
reason?: ContentEditFailure;
message?: string;
usedFont?: 'original' | 'embedded' | 'standard';
fontNames?: string[];
missing?: string;
widthChange?: number;
}TextLayerResult#
Type.
interface TextLayerResult {
words: number;
skippedWords: number;
}TextLayerRotation#
Type.
type TextLayerRotation = 0 | 90 | 180 | 270;TextLayerWord#
Type.
interface TextLayerWord {
text: string;
rect: PdfRect;
/**
* Direction of the baseline in page space, counter-clockwise in degrees. Left out, the word reads upright on
* the page as it is displayed, so it follows the rotation of the page.
*/
rotation?: TextLayerRotation;
}TextMove#
Type.
interface TextMove {
dx: number;
dy: number;
}TextMoveResult#
Type.
interface TextMoveResult extends TextEditResult {
run?: TextRun;
}TextParagraph#
Type.
interface TextParagraph {
index: number;
text: string;
lines: string[];
runs: TextRun[];
rect: PdfRect;
fontName: string;
baseFont?: string;
fontSize: number;
lineHeight: number;
/** How the lines sit in the block. A rewritten paragraph keeps it. */
alignment: ParagraphAlignment;
}TextRun#
Type.
interface TextRun {
index: number;
operator: string;
text: string;
rect: PdfRect;
fontName: string;
fontSize: number;
baseFont?: string;
origin: PdfPoint;
matrix: Matrix;
advance: number;
/** Drawn with the invisible render mode, as a text layer over a scan is. */
isInvisible?: boolean;
}TextStyle#
Type.
interface TextStyle {
/** A standard font, or the name of a supplied font. */
font?: string;
fontSize?: number;
color?: string;
isBold?: boolean;
isItalic?: boolean;
}Redaction#
DecodedRedactionImage#
Type.
interface DecodedRedactionImage {
width: number;
height: number;
rgba: Uint8Array | Uint8ClampedArray;
}RedactionArea#
Type.
interface RedactionArea {
rect: PdfRect;
fillColor?: string;
overlayText?: string;
}RedactionImageInfo#
Type.
interface RedactionImageInfo {
data: Uint8Array;
filter: string;
width: number;
height: number;
bitsPerComponent: number;
colorSpace?: string;
isMask: boolean;
decode?: number[];
decodeParms?: Record<string, number | boolean>;
jbig2Globals?: Uint8Array;
}RedactionImageOutcome#
Type.
interface RedactionImageOutcome {
name: string;
action: 'modified' | 'removed';
filter?: string;
decodedBy?: 'package' | 'callback';
reason?: RedactionImageRemovalReason;
message?: string;
}RedactionImageRemovalReason#
Type.
type RedactionImageRemovalReason = 'covered' | 'undecodable' | 'mask-undecodable' | 'inline-image';RedactionImageRequest#
Type.
interface RedactionImageRequest extends RedactionImageInfo {
ref: PdfRef;
name: string;
role: 'image' | 'softMask' | 'mask';
rect: PdfRect;
matrix: Matrix;
}RedactionReport#
Type.
interface RedactionReport {
glyphsRemoved: number;
removedText: string;
imagesRemoved: number;
imagesModified: number;
pathsRemoved: number;
formsRewritten: number;
images: RedactionImageOutcome[];
}Signatures#
addDocumentTimestamp#
Value, from @birchui/pdf/engine.
function addDocumentTimestamp(data: Uint8Array | ArrayBuffer, options: AddDocumentTimestampOptions): Promise<PdfBytes>;AddDocumentTimestampOptions#
Type.
interface AddDocumentTimestampOptions {
timestamp: TimestampCallback;
fieldName?: string;
placeholderSize?: number;
password?: string;
}addValidationData#
Value, from @birchui/pdf/engine.
function addValidationData(data: Uint8Array | ArrayBuffer, options?: AddValidationDataOptions): Promise<PdfBytes>;AddValidationDataOptions#
Type.
interface AddValidationDataOptions {
certificates?: (Uint8Array | string)[];
ocsps?: Uint8Array[];
crls?: Uint8Array[];
fetch?: ValidationDataCallback;
password?: string;
now?: Date;
}certificateToDer#
Value, from @birchui/pdf/engine.
function certificateToDer(input: Uint8Array | string): Uint8Array;ChainProblem#
Type.
interface ChainProblem {
code: ChainProblemCode;
/** Position in the chain of the certificate the problem is about; 0 is the signer. */
index: number;
subject: string;
message: string;
}ChainProblemCode#
Type.
type ChainProblemCode =
'ca-not-valid-at-signing' | 'not-a-ca' | 'key-usage' | 'path-length' | 'name-constraints';ChainStatus#
Type.
type ChainStatus = 'trusted' | 'untrusted' | 'self-signed' | 'incomplete';checkChainConstraints#
Value, from @birchui/pdf/engine.
function checkChainConstraints(chain: readonly ParsedCertificate[], at: Date): ChainProblem[];CheckResult#
Type.
type CheckResult = 'valid' | 'invalid' | 'unsupported';derToPem#
Value, from @birchui/pdf/engine.
function derToPem(der: Uint8Array, label: string): string;GeneralName#
Type.
interface GeneralName {
kind: 'email' | 'dns' | 'directory' | 'uri' | 'other';
value: string;
}HashName#
Type.
type HashName = 'SHA-1' | 'SHA-256' | 'SHA-384' | 'SHA-512';importPkcs12PrivateKey#
Value, from @birchui/pdf/engine.
function importPkcs12PrivateKey(contents: Pkcs12Contents, hash?: "SHA-256" | "SHA-384" | "SHA-512"): Promise<CryptoKey>;isTrustListExpired#
Value, from @birchui/pdf and @birchui/pdf/engine.
function isTrustListExpired(list: PdfTrustList, now?: Date): boolean;KeyUsage#
Type.
type KeyUsage =
| 'digitalSignature'
| 'nonRepudiation'
| 'keyEncipherment'
| 'dataEncipherment'
| 'keyAgreement'
| 'keyCertSign'
| 'cRLSign'
| 'encipherOnly'
| 'decipherOnly';loadTrustList#
Value, from @birchui/pdf and @birchui/pdf/engine.
function loadTrustList(input: PdfTrustListInput | string): PdfTrustList;NameConstraints#
Type.
interface NameConstraints {
permitted: GeneralName[];
excluded: GeneralName[];
}PadesLevel#
Type.
type PadesLevel = 'B-B' | 'B-T' | 'B-LT' | 'B-LTA' | 'not-pades';parsePkcs12#
Value, from @birchui/pdf/engine.
function parsePkcs12(data: Uint8Array | ArrayBuffer, password?: string): Promise<Pkcs12Contents>;PdfCertificateInfo#
Type.
interface PdfCertificateInfo {
subject: PdfDistinguishedName;
issuer: PdfDistinguishedName;
serialNumber: string;
notBefore: string;
notAfter: string;
publicKeyAlgorithm: 'RSA' | 'EC' | 'unknown';
publicKeyBits?: number;
curve?: 'P-256' | 'P-384' | 'P-521';
isCertificateAuthority: boolean;
isSelfIssued: boolean;
der: Uint8Array;
revocation?: RevocationStatus;
revocationDetails?: PdfRevocationDetails;
}PdfCertificationInfo#
Type.
interface PdfCertificationInfo {
level: 1 | 2 | 3;
permission: PdfCertificationPermission;
}PdfCertificationPermission#
Type.
type PdfCertificationPermission = 'no-changes' | 'form-filling' | 'annotations-and-forms';PdfDistinguishedName#
Type.
interface PdfDistinguishedName {
text: string;
commonName?: string;
organization?: string;
organizationalUnit?: string;
country?: string;
email?: string;
}PdfFieldLock#
Type.
type PdfFieldLock = 'all' | { include: string[] } | { exclude: string[] };PdfModificationReport#
Type.
interface PdfModificationReport {
status: 'none' | 'allowed' | 'disallowed' | 'unknown';
changes: PdfRevisionChange[];
warnings?: PdfModificationWarning[];
}PdfModificationWarning#
Type.
interface PdfModificationWarning {
code: 'annotation-covers-content';
objectNumber: number;
pageIndex: number;
coveredRatio: number;
}PdfRevisionChange#
Type.
interface PdfRevisionChange {
objectNumber: number;
change: 'added' | 'changed' | 'removed';
kind: RevisionChangeKind;
ownerObjectNumber?: number;
pageIndex?: number;
coversContent?: boolean;
coveredRatio?: number;
}PdfRevocationDetails#
Type.
interface PdfRevocationDetails {
status: RevocationStatus;
source?: 'ocsp' | 'crl' | 'callback';
revokedAt?: string;
reason?: string;
thisUpdate?: string;
nextUpdate?: string;
}PdfSignatureChain#
Type.
interface PdfSignatureChain {
status: ChainStatus | 'unknown';
certificates: PdfCertificateInfo[];
/** Constraint violations of the chain: key usage, CA flag, path length, name constraints, validity of issuers. */
problems: ChainProblem[];
}PdfSignatureSubFilter#
Type.
type PdfSignatureSubFilter = 'adbe.pkcs7.detached' | 'ETSI.CAdES.detached';PdfSignatureSummary#
Type.
type PdfSignatureSummary =
'trusted' | 'valid-untrusted' | 'changed-after-signing' | 'revoked' | 'invalid' | 'unsupported';PdfSignatureTimestamp#
Type.
interface PdfSignatureTimestamp {
time?: string;
isValid: boolean;
authority?: string;
policy?: string;
serialNumber?: string;
error?: string;
chain?: PdfSignatureChain;
revocation?: RevocationStatus;
}PdfSignatureVerification#
Type.
interface PdfSignatureVerification {
fieldName: string;
type: 'signature' | 'certification' | 'timestamp';
subFilter?: string;
signerName?: string;
reason?: string;
location?: string;
contactInfo?: string;
signedAt?: string;
signedAtSource?: 'timestamp' | 'signedAttribute' | 'dictionary';
byteRange: number[];
coversWholeFile: boolean;
laterChanges: 'none' | 'signatures-only' | 'allowed' | 'disallowed' | 'unknown';
integrity: 'intact' | 'modified' | 'unsupported';
signature: CheckResult;
signingCertificate: SigningCertificateCheck;
digestAlgorithm?: HashName;
signatureAlgorithm?: string;
certificate?: PdfCertificateInfo;
chain: PdfSignatureChain;
isCertificateValidAtSigning?: boolean;
isCertificateValidNow?: boolean;
revocation: RevocationStatus;
certificationLevel?: 1 | 2 | 3;
certification?: PdfCertificationPermission;
padesLevel?: PadesLevel;
modification: PdfModificationReport;
timestamp?: PdfSignatureTimestamp;
isValid: boolean;
isTrusted: boolean;
summary: PdfSignatureSummary;
/** Names of the trust lists that were not used because they are past their expiry date. */
expiredTrustLists?: string[];
warnings: PdfSignatureWarning[];
error?: string;
}PdfSignatureWarning#
Type.
interface PdfSignatureWarning {
code: 'annotation-covers-content';
message: string;
pageIndex: number;
objectNumber: number;
coveredRatio: number;
}PdfTrustList#
Type.
interface PdfTrustList {
name: string;
expires: Date;
issued?: Date;
/** DER bytes of the certificates that could be read. */
certificates: Uint8Array[];
entries: PdfCertificateInfo[];
/** Certificates of the input that are not readable X.509 certificates. */
rejected: number;
}PdfTrustListInput#
Type.
interface PdfTrustListInput {
name: string;
/** ISO 8601 date or `Date`. After it the list is not used. */
expires: string | Date;
issued?: string | Date;
/** PEM text (one or several certificates) or DER bytes. */
certificates: (string | Uint8Array)[];
}pemBlocks#
Value, from @birchui/pdf/engine.
function pemBlocks(pem: string, label: string): Uint8Array[];pemToDer#
Value, from @birchui/pdf/engine.
function pemToDer(pem: string, label?: string): Uint8Array;Pkcs12Contents#
Type.
interface Pkcs12Contents {
privateKey: Uint8Array;
privateKeyPem: string;
certificate: Uint8Array;
chain: Uint8Array[];
friendlyName?: string;
}Pkcs12Error#
Value, from @birchui/pdf/engine.
class Pkcs12Error extends Error {
constructor( readonly reason: Pkcs12ErrorReason, message: string, );
}Pkcs12ErrorReason#
Type.
type Pkcs12ErrorReason = 'password-incorrect' | 'unsupported' | 'malformed';RevisionChangeKind#
Type.
type RevisionChangeKind =
'form' | 'annotation' | 'signature' | 'timestamp' | 'dss' | 'appearance' | 'metadata' | 'other';RevocationAnswer#
Type.
interface RevocationAnswer {
status: 'good' | 'revoked' | 'unknown';
revokedAt?: Date | string;
reason?: string;
}RevocationCallback#
Type.
type RevocationCallback = (
certificate: PdfCertificateInfo,
issuer: PdfCertificateInfo,
) => RevocationAnswer | Promise<RevocationAnswer>;RevocationStatus#
Type.
type RevocationStatus = 'good' | 'revoked' | 'unknown' | 'not-checked';SignatureAppearanceOptions#
Type.
interface SignatureAppearanceOptions {
text?: string[];
image?: Uint8Array;
showDate?: boolean;
showReason?: boolean;
showLocation?: boolean;
fontSize?: number;
textColor?: [number, number, number];
borderColor?: [number, number, number] | null;
borderWidth?: number;
backgroundColor?: [number, number, number] | null;
}SignatureFieldPlacement#
Type.
interface SignatureFieldPlacement {
name?: string;
pageIndex: number;
rect: [number, number, number, number];
}SignDigestCallback#
Type.
type SignDigestCallback = (digest: PdfBytes, info: SignDigestInfo) => Promise<Uint8Array> | Uint8Array;SignDigestInfo#
Type.
interface SignDigestInfo {
algorithm: 'RSASSA-PKCS1-v1_5' | 'ECDSA';
hash: HashName;
curve?: 'P-256' | 'P-384' | 'P-521';
signedAttributes: Uint8Array;
}signPdf#
Value, from @birchui/pdf/engine.
function signPdf(data: Uint8Array | ArrayBuffer, input: SignPdfOptions): Promise<PdfBytes>;SignPdfOptions#
Type.
interface SignPdfOptions {
certificate?: Uint8Array | string;
certificateChain?: (Uint8Array | string)[];
privateKey?: string | CryptoKey;
signDigest?: SignDigestCallback;
pkcs12?: Uint8Array | ArrayBuffer;
pkcs12Password?: string;
timestamp?: TimestampCallback;
reason?: string;
location?: string;
contactInfo?: string;
name?: string;
field?: string | SignatureFieldPlacement;
appearance?: SignatureAppearanceOptions | false;
certificationLevel?: 1 | 2 | 3;
certify?: PdfCertificationPermission;
subFilter?: PdfSignatureSubFilter;
signedAt?: Date;
placeholderSize?: number;
password?: string;
lockFields?: PdfFieldLock;
}TimestampCallback#
Type.
type TimestampCallback = (data: Uint8Array, info: TimestampRequestInfo) => Promise<Uint8Array> | Uint8Array;TimestampRequestInfo#
Type.
interface TimestampRequestInfo {
hash: 'SHA-256';
digest: Uint8Array;
}ValidationDataCallback#
Type.
type ValidationDataCallback = (
request: ValidationDataRequest,
) => ValidationDataResponse | undefined | Promise<ValidationDataResponse | undefined>;ValidationDataRequest#
Type.
interface ValidationDataRequest {
certificate: PdfCertificateInfo;
issuer: PdfCertificateInfo;
ocspUrls: string[];
crlUrls: string[];
}ValidationDataResponse#
Type.
interface ValidationDataResponse {
ocsp?: Uint8Array;
crl?: Uint8Array;
}verifyPdfSignatures#
Value, from @birchui/pdf/engine.
function verifyPdfSignatures(data: Uint8Array | ArrayBuffer, options?: VerifySignaturesOptions): Promise<PdfSignatureVerification[]>;VerifySignaturesOptions#
Type.
interface VerifySignaturesOptions {
trustedRoots?: (Uint8Array | string)[];
/** Trust lists from `loadTrustList`. A list past its expiry date is not used and is named in the result. */
trustLists?: PdfTrustList[];
now?: Date;
password?: string;
ocsps?: Uint8Array[];
crls?: Uint8Array[];
checkRevocation?: RevocationCallback;
requireRevocation?: boolean;
limits?: Partial<PdfLimits>;
}Encryption and permissions#
EncryptionAlgorithm#
Type.
type EncryptionAlgorithm = 'rc4-40' | 'rc4-128' | 'aes-128' | 'aes-256';EncryptOptions#
Type.
interface EncryptOptions {
userPassword?: string;
ownerPassword?: string;
permissions?: Partial<PdfPermissions>;
algorithm?: EncryptionAlgorithm;
encryptMetadata?: boolean;
}PdfCryptoUnavailableError#
Value, from @birchui/pdf and @birchui/pdf/engine.
class PdfCryptoUnavailableError extends Error {
constructor();
}PdfPasswordError#
Value, from @birchui/pdf and @birchui/pdf/engine.
class PdfPasswordError extends Error {
constructor(readonly reason: 'password-required' | 'password-incorrect' | 'unsupported');
}PdfPermissions#
Type.
interface PdfPermissions {
print: boolean;
printHighQuality: boolean;
modify: boolean;
copy: boolean;
annotate: boolean;
fillForms: boolean;
extractForAccessibility: boolean;
assemble: boolean;
}permissionsFromFlags#
Value, from @birchui/pdf and @birchui/pdf/engine.
function permissionsFromFlags(flags: number): PdfPermissions;permissionsToFlags#
Value, from @birchui/pdf and @birchui/pdf/engine.
function permissionsToFlags(permissions?: Partial<PdfPermissions>): number;Compare#
buildCompareReport#
Value, from @birchui/pdf and @birchui/pdf/engine.
function buildCompareReport(comparison: PdfComparison, options?: CompareReportOptions): string;ComparableDocument#
Type.
interface ComparableDocument {
readonly pageCount: number;
getPageText(pageIndex: number): ComparablePageText;
}ComparablePageText#
Type.
interface ComparablePageText {
text: string;
boxes: (PdfRect | undefined)[];
}CompareInput#
Type.
type CompareInput = Uint8Array | ArrayBuffer | ComparableDocument;comparePageTexts#
Value, from @birchui/pdf/engine.
function comparePageTexts(textsA: readonly ComparablePageText[], textsB: readonly ComparablePageText[], options?: ComparePdfOptions): PdfComparison;comparePdf#
Value, from @birchui/pdf/engine.
function comparePdf(a: CompareInput, b: CompareInput, options?: ComparePdfOptions): PdfComparison;comparePdfAsync#
Value, from @birchui/pdf/engine.
function comparePdfAsync(a: CompareInput, b: CompareInput, options?: ComparePdfAsyncOptions): Promise<PdfComparison>;ComparePdfAsyncOptions#
Type.
interface ComparePdfAsyncOptions extends ComparePdfOptions {
password?: string;
otherPassword?: string;
}ComparePdfOptions#
Type.
interface ComparePdfOptions {
ignoreCase?: boolean;
ignoreWhitespace?: boolean;
annotations?: boolean;
minMoveWords?: number;
pageSimilarityThreshold?: number;
colors?: { inserted?: string; deleted?: string; moved?: string };
author?: string;
}CompareReportFormat#
Type.
type CompareReportFormat = 'html' | 'csv' | 'json';CompareReportLabels#
Type.
interface CompareReportLabels {
title: string;
first: string;
second: string;
page: string;
change: string;
text: string;
inserted: string;
deleted: string;
moved: string;
none: string;
pages: string;
words: string;
}CompareReportOptions#
Type.
interface CompareReportOptions {
format?: CompareReportFormat;
fileNameA?: string;
fileNameB?: string;
date?: Date | string;
labels?: Partial<CompareReportLabels>;
}comparisonAnnotations#
Value, from @birchui/pdf/engine.
function comparisonAnnotations(changes: readonly PdfTextChange[], options?: Pick<ComparePdfOptions, "colors" | "author">): { a: AnnotationInput[]; b: AnnotationInput[]; };diffPixels#
Value, from @birchui/pdf.
function diffPixels(a: PixelBuffer, b: PixelBuffer, options?: PixelDiffOptions): PixelDiffResult;PageComparisonStatus#
Type.
type PageComparisonStatus = 'unchanged' | 'changed' | 'added' | 'removed' | 'moved';PdfComparison#
Type.
interface PdfComparison {
pages: PdfPageComparison[];
changes: PdfTextChange[];
summary: PdfComparisonSummary;
annotations?: { a: AnnotationInput[]; b: AnnotationInput[] };
}PdfComparisonSummary#
Type.
interface PdfComparisonSummary {
pageCountA: number;
pageCountB: number;
pagesUnchanged: number;
pagesChanged: number;
pagesAdded: number;
pagesRemoved: number;
pagesMoved: number;
insertions: number;
deletions: number;
moves: number;
wordsInserted: number;
wordsDeleted: number;
wordsMoved: number;
isIdentical: boolean;
}PdfPageComparison#
Type.
interface PdfPageComparison {
status: PageComparisonStatus;
pageIndexA?: number;
pageIndexB?: number;
similarity: number;
changes: PdfTextChange[];
}PdfTextChange#
Type.
interface PdfTextChange {
type: TextChangeType;
text: string;
pageIndexA?: number;
pageIndexB?: number;
rects: PdfRect[];
fromRects?: PdfRect[];
wordCount: number;
}PixelBuffer#
Type.
interface PixelBuffer {
data: Uint8Array | Uint8ClampedArray;
width: number;
height: number;
}PixelDiffOptions#
Type.
interface PixelDiffOptions {
tolerance?: number;
color?: readonly [number, number, number];
padding?: readonly [number, number, number, number];
cellSize?: number;
mergeDistance?: number;
minRegionPixels?: number;
maxRegions?: number;
}PixelDiffRegion#
Type.
interface PixelDiffRegion {
x: number;
y: number;
width: number;
height: number;
changedPixels: number;
}PixelDiffResult#
Type.
interface PixelDiffResult {
width: number;
height: number;
mask: Uint8ClampedArray<ArrayBuffer>;
changedPixels: number;
changedRatio: number;
regions: PixelDiffRegion[];
}TextChangeType#
Type.
type TextChangeType = 'inserted' | 'deleted' | 'moved';Page and document tools#
AccessibilityCode#
Type.
type AccessibilityCode =
| 'no-title'
| 'title-not-shown'
| 'no-language'
| 'not-tagged'
| 'figure-without-alt'
| 'untagged-content'
| 'reading-order'
| 'page-without-text'
| 'field-without-tooltip'
| 'tab-order'
| 'no-bookmarks';AccessibilityIssue#
Type.
interface AccessibilityIssue {
code: AccessibilityCode;
severity: 'error' | 'warning';
message: string;
pageIndex?: number;
/** For `figure-without-alt`: the id to pass to `setAlternateText`. */
figureId?: string;
}AccessibilityReport#
Type.
interface AccessibilityReport {
isTagged: boolean;
title?: string;
language?: string;
figures: PdfFigure[];
issues: AccessibilityIssue[];
/** True when no issue of severity `error` was found. It is a pre-flight check, not a statement of conformance. */
passes: boolean;
}analyzeLayout#
Value, from @birchui/pdf/engine.
function analyzeLayout(source: OfficeExportSource, options?: OfficeExportOptions): OfficeBlock[];ArchiveFinding#
Type.
interface ArchiveFinding {
rule: ArchiveRule;
severity: ArchiveSeverity;
message: string;
pageIndex?: number;
}ArchiveFontUsage#
Type.
interface ArchiveFontUsage {
name: string;
isEmbedded: boolean;
pages: number[];
}ArchiveReport#
Type.
interface ArchiveReport {
isLikelyConformant: boolean;
declared?: { part: number; conformance?: string };
findings: ArchiveFinding[];
fonts: ArchiveFontUsage[];
}ArchiveRule#
Type.
type ArchiveRule =
| 'encryption'
| 'fonts'
| 'metadata'
| 'output-intent'
| 'javascript'
| 'launch-action'
| 'embedded-files'
| 'transparency'
| 'lzw'
| 'file-id';ArchiveSeverity#
Type.
type ArchiveSeverity = 'error' | 'warning' | 'info';AttachmentInput#
Type.
type AttachmentInput = FileSpecInput;BackgroundOptions#
Type.
interface BackgroundOptions {
color?: string;
image?: Uint8Array;
opacity?: number;
}BatesOptions#
Type.
interface BatesOptions {
prefix?: string;
suffix?: string;
start?: number;
digits?: number;
position?: StampPosition;
fontSize?: number;
color?: string;
font?: StandardFont;
margin?: number;
fonts?: FontRegistry;
}BlankScanOptions#
Type.
interface BlankScanOptions {
/** Lightness from 0 to 255 at or above which a pixel counts as paper. */
whiteLevel?: number;
/** Share of pixels that may be darker than paper, for dust and scanner noise. */
tolerance?: number;
/** Share of each edge that is left out, where scanners leave shadows. */
border?: number;
}blocksText#
Value, from @birchui/pdf/engine.
function blocksText(blocks: readonly OfficeBlock[]): string;blocksToDocx#
Value, from @birchui/pdf/engine.
function blocksToDocx(blocks: readonly OfficeBlock[], options?: { title?: string; }): PdfBytes;bookletOrder#
Value, from @birchui/pdf/engine.
function bookletOrder(pageCount: number, isRightToLeft?: boolean): number[][];buildSrgbProfile#
Value, from @birchui/pdf/engine.
function buildSrgbProfile(): Uint8Array;canonicalFontName#
Value, from @birchui/pdf/engine.
function canonicalFontName(baseFont: string): string;checkArchiveReadiness#
Value, from @birchui/pdf/engine.
function checkArchiveReadiness(input: Uint8Array | ArrayBuffer | ArchiveSource): ArchiveReport;convertToPdfA#
Value, from @birchui/pdf/engine.
function convertToPdfA(data: Uint8Array | ArrayBuffer, options?: PdfAConversionOptions): Promise<PdfAConversionResult>;createZip#
Value, from @birchui/pdf/engine.
function createZip(entries: readonly ZipEntry[]): PdfBytes;CropPagesOptions#
Type.
interface CropPagesOptions {
removeContent?: boolean;
}DownsampleReport#
Type.
interface DownsampleReport {
imagesDownsampled: number;
imagesKept: number;
}embedMissingFonts#
Value, from @birchui/pdf/engine.
function embedMissingFonts(editor: PdfEditor, fonts?: Readonly<Record<string, Uint8Array>>): PdfAFontReplacement[];formatBatesNumber#
Value, from @birchui/pdf and @birchui/pdf/engine.
function formatBatesNumber(index: number, options?: BatesOptions): string;HeaderFooterOptions#
Type.
interface HeaderFooterOptions {
header?: HeaderFooterSlots;
footer?: HeaderFooterSlots;
margin?: number | PageMargins;
fontSize?: number;
color?: string;
font?: StandardFont;
startNumber?: number;
totalPages?: number;
range?: { from?: number; to?: number };
date?: Date | string;
fileName?: string;
fonts?: FontRegistry;
/** How the stamped text is marked in the page content; `header` and `footer` by default. */
layerKind?: 'header' | 'footer' | 'pageNumbers';
}HeaderFooterSlots#
Type.
interface HeaderFooterSlots {
left?: string;
center?: string;
right?: string;
}ImagePageInput#
Type.
interface ImagePageInput {
data: Uint8Array;
dpi?: number;
}ImagePageSize#
Type.
type ImagePageSize = 'image' | 'a4' | 'letter' | { width: number; height: number };imagesToPdf#
Value, from @birchui/pdf/engine.
function imagesToPdf(images: readonly (Uint8Array | ImagePageInput)[], options?: ImagesToPdfOptions): Promise<PdfBytes>;ImagesToPdfOptions#
Type.
interface ImagesToPdfOptions {
pageSize?: ImagePageSize;
margin?: number;
fit?: 'contain' | 'cover' | 'none';
dpi?: number;
metadata?: { title?: string; author?: string; subject?: string; keywords?: string; creator?: string };
decodeImage?: ImageDecoder;
}ImposeOptions#
Type.
interface ImposeOptions {
layout: 'n-up' | 'booklet';
columns?: number;
rows?: number;
sheetSize?: { width: number; height: number };
margin?: number;
gutter?: number;
rightToLeft?: boolean;
password?: string;
}imposePdf#
Value, from @birchui/pdf/engine.
function imposePdf(data: Uint8Array | ArrayBuffer, options: ImposeOptions): Promise<PdfBytes>;LinearizeOptions#
Type.
interface LinearizeOptions {
recompress?: boolean;
}linearizePdf#
Value, from @birchui/pdf/engine.
function linearizePdf(data: Uint8Array | ArrayBuffer, options?: LinearizeOptions): Promise<PdfBytes>;mergePdfs#
Value, from @birchui/pdf/engine.
function mergePdfs(inputs: readonly MergeFileInput[], options?: MergePdfsOptions): Promise<PdfBytes>;MergePdfsOptions#
Type.
interface MergePdfsOptions extends Omit<MergeFilesOptions, 'at'> {
decodeImage?: ImageDecoder;
}OfficeBlock#
Type.
type OfficeBlock =
| { kind: 'heading'; level: 1 | 2 | 3; runs: OfficeRun[]; pageIndex: number }
| { kind: 'paragraph'; runs: OfficeRun[]; pageIndex: number }
| { kind: 'list'; isOrdered: boolean; marker: string; runs: OfficeRun[]; pageIndex: number }
| { kind: 'table'; rows: string[][]; pageIndex: number };OfficeExportOptions#
Type.
interface OfficeExportOptions {
/** Pages to export, zero-based. Default: every page. */
pages?: readonly number[];
title?: string;
}OfficeExportSource#
Type.
interface OfficeExportSource {
readonly pageCount: number;
getStructuredText(pageIndex: number): PageTextStructure;
}OfficeRun#
Type.
interface OfficeRun {
text: string;
isBold?: boolean;
isItalic?: boolean;
}OptimizeImageOptions#
Type.
interface OptimizeImageOptions {
maxDpi: number;
jpegQuality?: number;
}OptimizeOptions#
Type.
interface OptimizeOptions {
/** False serialises every object anew, so the output has one spelling of stream and object syntax. */
keepVerbatim?: boolean;
objectStreams?: boolean;
dedupe?: boolean;
removeUnused?: boolean;
recompress?: boolean;
transform?: ObjectTransform;
images?: OptimizeImageOptions;
fonts?: boolean;
}optimizePdf#
Value, from @birchui/pdf/engine.
function optimizePdf(data: Uint8Array | ArrayBuffer, options?: OptimizeOptions): Promise<OptimizeResult>;OptimizeReport#
Type.
interface OptimizeReport extends Partial<DownsampleReport>, Partial<FontSubsetReport> {
before: number;
after: number;
objectsBefore: number;
objectsAfter: number;
duplicatesMerged: number;
}OptimizeResult#
Type.
interface OptimizeResult {
bytes: PdfBytes;
report: OptimizeReport;
}OutlineItem#
Type.
interface OutlineItem {
title: string;
pageIndex?: number;
left?: number;
top?: number;
zoom?: number;
uri?: string;
isOpen?: boolean;
color?: string;
isBold?: boolean;
isItalic?: boolean;
children?: OutlineItem[];
}PageAnchor#
Type.
type PageAnchor =
| 'center'
| 'top-left'
| 'top-center'
| 'top-right'
| 'center-left'
| 'center-right'
| 'bottom-left'
| 'bottom-center'
| 'bottom-right';PageBoxes#
Type.
interface PageBoxes {
media: PdfRect;
crop: PdfRect;
bleed: PdfRect;
trim: PdfRect;
art: PdfRect;
}PageBoxesPatch#
Type.
type PageBoxesPatch = { media?: PdfRect } & Partial<Record<Exclude<PageBoxKey, 'media'>, PdfRect | null>>;PageBoxKey#
Type.
type PageBoxKey = keyof PageBoxes;PageLabelRange#
Type.
interface PageLabelRange {
startPage: number;
style: PageLabelStyle;
prefix?: string;
start?: number;
}PageLabelStyle#
Type.
type PageLabelStyle = 'decimal' | 'roman-upper' | 'roman-lower' | 'alpha-upper' | 'alpha-lower' | 'none';PageLayerKind#
Type.
type PageLayerKind = 'watermark' | 'header' | 'footer' | 'background' | 'pageNumbers' | 'bates';PageMargins#
Type.
interface PageMargins {
top?: number;
bottom?: number;
left?: number;
right?: number;
}PageSelector#
Type.
type PageSelector = 'all' | 'odd' | 'even' | string;parsePageRanges#
Value, from @birchui/pdf/engine.
function parsePageRanges(text: string, pageCount: number): [number, number][];PdfAConversionOptions#
Type.
interface PdfAConversionOptions {
keepAttachments?: boolean;
fonts?: Readonly<Record<string, Uint8Array>>;
}PdfAConversionResult#
Type.
interface PdfAConversionResult {
bytes: PdfBytes;
isConformant: boolean;
removed: string[];
remaining: ArchiveFinding[];
fonts: PdfAFontReplacement[];
validation: PdfAValidation;
}PdfAFontReplacement#
Type.
interface PdfAFontReplacement {
name: string;
replacement: string;
glyphs: number;
mismatchedWidths: number;
}PdfARule#
Type.
type PdfARule =
| 'header'
| 'encryption'
| 'file-id'
| 'stream'
| 'output-intent'
| 'device-colour'
| 'transparency'
| 'image'
| 'content'
| 'xobject'
| 'fonts'
| 'annotations'
| 'actions'
| 'metadata'
| 'forms'
| 'embedded-files';PdfAttachment#
Type.
interface PdfAttachment extends FileSpecInfo {
source: 'document' | 'annotation';
pageIndex?: number;
}PdfAValidation#
Type.
interface PdfAValidation {
profile: 'PDF/A-2b';
validator: 'built-in';
isValid: boolean;
violations: PdfAViolation[];
rulesChecked: PdfARule[];
}PdfAViolation#
Type.
interface PdfAViolation {
rule: PdfARule;
clause: string;
severity: 'error' | 'warning';
message: string;
pageIndex?: number;
object?: number;
}PdfCollection#
Type.
interface PdfCollection {
view: PdfCollectionView;
initialDocument?: string;
fields: PdfCollectionField[];
sort?: PdfCollectionSort[];
items: PdfCollectionItem[];
}PdfCollectionField#
Type.
interface PdfCollectionField {
key: string;
name: string;
type: PdfCollectionFieldType;
order: number;
isVisible: boolean;
}PdfCollectionFieldType#
Type.
type PdfCollectionFieldType =
'text' | 'date' | 'number' | 'fileName' | 'description' | 'modified' | 'created' | 'size' | 'compressedSize';PdfCollectionItem#
Type.
interface PdfCollectionItem extends PdfAttachment {
values: Record<string, PdfCollectionValue>;
}PdfCollectionSort#
Type.
interface PdfCollectionSort {
key: string;
isAscending: boolean;
}PdfCollectionValue#
Type.
type PdfCollectionValue = string | number | Date;PdfCollectionView#
Type.
type PdfCollectionView = 'details' | 'tile' | 'hidden';PdfFigure#
Type.
interface PdfFigure {
/** Stable while the structure tree is not rewritten: the object number of the structure element. */
id: string;
pageIndex?: number;
alternateText?: string;
actualText?: string;
rect?: PdfRect;
}PdfInitialPageLayout#
Type.
type PdfInitialPageLayout =
'single' | 'continuous' | 'two-column' | 'two-column-cover' | 'two-page' | 'two-page-cover';PdfInitialPageMode#
Type.
type PdfInitialPageMode = 'none' | 'outlines' | 'thumbnails' | 'fullscreen' | 'layers' | 'attachments';PdfInitialView#
Type.
interface PdfInitialView {
pageMode?: PdfInitialPageMode;
pageLayout?: PdfInitialPageLayout;
/** Page shown when the document opens, from 0. */
openPage?: number;
/** Zoom when the document opens: a factor (1 is 100%) or a fit mode. */
zoom?: number | 'fit-page' | 'fit-width';
/** Show the document title instead of the file name in the window title. */
displayDocTitle?: boolean;
}PdfMetadata#
Type.
interface PdfMetadata {
title?: string;
author?: string;
subject?: string;
keywords?: string;
creator?: string;
producer?: string;
created?: Date;
modified?: Date;
trapped?: boolean;
custom: Record<string, string>;
xmp?: string;
}PdfMetadataPatch#
Type.
interface PdfMetadataPatch {
title?: string | null;
author?: string | null;
subject?: string | null;
keywords?: string | null;
creator?: string | null;
producer?: string | null;
created?: Date | null;
modified?: Date | null;
trapped?: boolean | null;
custom?: Record<string, string | null>;
}SanitizeOptions#
Type.
interface SanitizeOptions {
/** Document information, XMP packets and private application data. */
metadata?: boolean;
/** Layers that are switched off, together with the page content that belongs to them. */
hiddenLayers?: boolean;
/** Embedded files and file attachment annotations. */
attachments?: boolean;
/** JavaScript, open actions and additional actions. */
scripts?: boolean;
/** Every annotation except links and form fields. */
comments?: boolean;
}sanitizePdf#
Value, from @birchui/pdf/engine.
function sanitizePdf(data: Uint8Array | ArrayBuffer, options?: SanitizeOptions): Promise<SanitizeResult>;SanitizeReport#
Type.
interface SanitizeReport {
metadata: number;
hiddenLayers: number;
attachments: number;
scripts: number;
comments: number;
before: number;
after: number;
}SanitizeResult#
Type.
interface SanitizeResult {
bytes: PdfBytes;
report: SanitizeReport;
}selectPages#
Value, from @birchui/pdf/engine.
function selectPages(pageCount: number, selector: PageSelector): number[];SplitNaming#
Type.
interface SplitNaming {
baseName?: string;
}SplitOptions#
Type.
type SplitOptions =
| { ranges: string | readonly (readonly [number, number])[] }
| { every: number }
| { byBookmark: { level?: number } }
| { maxBytes: number }
| { byBlankPages: true };SplitPart#
Type.
interface SplitPart {
bytes: PdfBytes;
pageIndexes: number[];
name: string;
title?: string;
}splitPdf#
Value, from @birchui/pdf/engine.
function splitPdf(data: Uint8Array | ArrayBuffer, options: SplitOptions, naming?: SplitNaming): Promise<SplitPart[]>;StampImageOptions#
Type.
interface StampImageOptions {
data: Uint8Array;
rect?: PdfRect;
position?: StampPosition;
width?: number;
height?: number;
opacity?: number;
rotation?: number;
layer?: 'over' | 'under';
margin?: number;
}StampPosition#
Type.
type StampPosition = PageAnchor | { x: number; y: number };StampTextOptions#
Type.
interface StampTextOptions {
text: string;
position?: StampPosition;
fontSize?: number;
color?: string;
opacity?: number;
rotation?: number;
font?: StandardFont;
layer?: 'over' | 'under';
margin?: number;
fonts?: FontRegistry;
}tablesToXlsx#
Value, from @birchui/pdf/engine.
function tablesToXlsx(tables: readonly (readonly string[][])[]): PdfBytes;validatePdfA#
Value, from @birchui/pdf/engine.
function validatePdfA(input: Uint8Array | ArrayBuffer | PdfFile): PdfAValidation;ZipEntry#
Type.
interface ZipEntry {
name: string;
bytes: Uint8Array;
modified?: Date;
}zipSplitParts#
Value, from @birchui/pdf/engine.
function zipSplitParts(parts: readonly SplitPart[]): PdfBytes;Email messages#
convertMailFile#
Value, from @birchui/pdf/engine.
function convertMailFile(bytes: Uint8Array, hint?: MailFileHint, options?: MailToPdfOptions): Promise<MailConversion>;DecodedImage#
Type.
interface DecodedImage {
width: number;
height: number;
data: Uint8Array | Uint8ClampedArray;
}decodeImageFile#
Value, from @birchui/pdf and @birchui/pdf/engine.
function decodeImageFile(bytes: Uint8Array, options?: PrepareImageOptions): Promise<DecodedImage>;decompressRtf#
Value, from @birchui/pdf/engine.
function decompressRtf(data: Uint8Array, options?: DecompressRtfOptions): Uint8Array;DecompressRtfOptions#
Type.
interface DecompressRtfOptions {
verifyCrc?: boolean;
}detectImageFormat#
Value, from @birchui/pdf and @birchui/pdf/engine.
function detectImageFormat(bytes: Uint8Array): ImageFileFormat | undefined;detectMailFormat#
Value, from @birchui/pdf/engine.
function detectMailFormat(bytes: Uint8Array, hint?: MailFileHint): MailFormat | undefined;ImageDecoder#
Type.
type ImageDecoder = (
bytes: Uint8Array,
mimeType: string,
) => DecodedImage | undefined | Promise<DecodedImage | undefined>;ImageDecoderRequiredError#
Value, from @birchui/pdf and @birchui/pdf/engine.
class ImageDecoderRequiredError extends ImageFormatError {
constructor(readonly mimeType: string);
}ImageFileFormat#
Type.
type ImageFileFormat = 'png' | 'jpeg' | 'gif' | 'bmp' | 'tiff' | 'webp' | 'svg';imageMimeType#
Value, from @birchui/pdf and @birchui/pdf/engine.
function imageMimeType(format: ImageFileFormat): string;MailAddress#
Type.
interface MailAddress {
name: string;
address: string;
}MailAttachment#
Type.
interface MailAttachment {
fileName: string;
mimeType: string;
data: Uint8Array;
contentId?: string;
isInline: boolean;
embeddedMessage?: MailMessage;
}MailConversion#
Type.
interface MailConversion extends MailPdfResult {
format: MailFormat;
message: MailMessage;
}MailFileHint#
Type.
interface MailFileHint {
fileName?: string;
mimeType?: string;
}MailFormat#
Type.
type MailFormat = 'msg' | 'eml';MailFormatError#
Value, from @birchui/pdf/engine.
class MailFormatError extends Error {
constructor(message: string);
}MailHeader#
Type.
interface MailHeader {
name: string;
value: string;
}MailMessage#
Type.
interface MailMessage {
format: MailFormat;
subject: string;
from?: MailAddress;
to: MailAddress[];
cc: MailAddress[];
bcc: MailAddress[];
sentAt?: Date;
text: string;
html: string;
headers: MailHeader[];
attachments: MailAttachment[];
}MailOriginalFile#
Type.
interface MailOriginalFile {
data: Uint8Array;
fileName?: string;
}MailPageSize#
Type.
type MailPageSize = 'a4' | 'letter' | { width: number; height: number };MailPdfLabels#
Type.
interface MailPdfLabels {
subject: string;
from: string;
to: string;
cc: string;
bcc: string;
sent: string;
attachments: string;
noSubject: string;
image: string;
}MailPdfResult#
Type.
interface MailPdfResult {
bytes: PdfBytes;
pageCount: number;
substitutedCharacters: number;
attachmentNames: string[];
warnings: MailPdfWarning[];
}MailPdfWarning#
Type.
interface MailPdfWarning {
code: MailPdfWarningCode;
message: string;
count: number;
}MailPdfWarningCode#
Type.
type MailPdfWarningCode =
| 'substituted-characters'
| 'remote-image'
| 'missing-image'
| 'unsupported-image'
| 'unsafe-link'
| 'embedded-message-converted';mailToPdf#
Value, from @birchui/pdf/engine.
function mailToPdf(message: MailMessage, options?: MailToPdfOptions): Promise<MailPdfResult>;MailToPdfOptions#
Type.
interface MailToPdfOptions {
pageSize?: MailPageSize;
margin?: number | PageMargins;
fontSize?: number;
fonts?: FontRegistry | readonly PdfFontSource[];
fontFallback?: PdfFontFallback;
allowMissingGlyphs?: boolean;
includeAttachments?: boolean;
attachOriginal?: Uint8Array | MailOriginalFile;
preferPlainText?: boolean;
labels?: Partial<MailPdfLabels>;
formatDate?: (date: Date) => string;
}parseEml#
Value, from @birchui/pdf/engine.
function parseEml(bytes: Uint8Array | ArrayBuffer): MailMessage;parseMail#
Value, from @birchui/pdf/engine.
function parseMail(bytes: Uint8Array, hint?: MailFileHint): MailMessage;parseMsg#
Value, from @birchui/pdf/engine.
function parseMsg(bytes: Uint8Array | ArrayBuffer): MailMessage;prepareImage#
Value, from @birchui/pdf and @birchui/pdf/engine.
function prepareImage(bytes: Uint8Array, options?: PrepareImageOptions): Promise<AnnotationImage>;PrepareImageOptions#
Type.
interface PrepareImageOptions {
decodeImage?: ImageDecoder;
mimeType?: string;
}rtfToHtml#
Value, from @birchui/pdf/engine.
function rtfToHtml(rtf: Uint8Array | string): string;rtfToText#
Value, from @birchui/pdf/engine.
function rtfToText(rtf: Uint8Array | string): string;Fonts#
createFontRegistry#
Value, from @birchui/pdf and @birchui/pdf/engine.
function createFontRegistry(fonts?: readonly PdfFontSource[]): FontRegistry;EmbeddedText#
Type.
interface EmbeddedText {
ref: PdfRef;
fontName: string;
encoded: Uint8Array;
width: number;
ascent: number;
descent: number;
isRtl: boolean;
placements?: (GlyphPlacement | undefined)[];
}FontFormatError#
Value, from @birchui/pdf and @birchui/pdf/engine.
class FontFormatError extends Error {
constructor(message: string);
}FontRegistry#
Type.
interface FontRegistry {
readonly isEmpty: boolean;
readonly fontNames: readonly string[];
add(source: PdfFontSource): boolean;
hasGlyph(code: number): boolean;
covers(text: string): boolean;
needsEmbedding(text: string): boolean;
embed(editor: PdfEditor | FontSink, text: string, preferredName?: string): EmbeddedText[];
measure(text: string, preferredName?: string): number;
}MissingGlyphReport#
Type.
interface MissingGlyphReport {
characters: string;
scripts: TextScript[];
}PdfFontFallback#
Type.
type PdfFontFallback = (
script: TextScript,
characters: string,
) => Uint8Array | PdfFontSource | undefined | Promise<Uint8Array | PdfFontSource | undefined>;PdfFontSource#
Type.
interface PdfFontSource {
name: string;
data: Uint8Array;
}PdfMissingGlyphError#
Value, from @birchui/pdf and @birchui/pdf/engine.
class PdfMissingGlyphError extends Error {
readonly characters: string;
readonly scripts: TextScript[];
constructor(report: MissingGlyphReport);
}PdfTextRasterizer#
Type.
interface PdfTextRasterizer {
/** Advance width of the text in points. */
measure(text: string, style: RasterTextStyle): number;
rasterize(text: string, style: RasterTextStyle): RasterizedText | undefined;
}RasterizedText#
Type.
interface RasterizedText {
/** Bitmap size in pixels. */
width: number;
height: number;
/** One byte of ink coverage per pixel, rows from the top. */
coverage: Uint8Array;
/** Pixels per point. */
scale: number;
/** Pixels from the left edge of the bitmap to the text origin. */
originX: number;
/** Pixels from the top edge of the bitmap to the baseline. */
baseline: number;
}RasterTextStyle#
Type.
interface RasterTextStyle {
fontSize: number;
}Files and errors#
ATTACHMENT_RELATIONSHIPS#
Value, from @birchui/pdf and @birchui/pdf/engine.
const ATTACHMENT_RELATIONSHIPS: readonly AttachmentRelationship[];AttachmentRelationship#
Type.
type AttachmentRelationship =
'Source' | 'Data' | 'Alternative' | 'Supplement' | 'EncryptedPayload' | 'FormData' | 'Schema' | 'Unspecified';decodeJpeg#
Value, from @birchui/pdf and @birchui/pdf/engine.
function decodeJpeg(bytes: Uint8Array, options?: JpegDecodeOptions): JpegImage;getDefaultPdfLimits#
Value, from @birchui/pdf and @birchui/pdf/engine.
function getDefaultPdfLimits(): PdfLimits;InflateError#
Value, from @birchui/pdf and @birchui/pdf/engine.
class InflateError extends Error {
constructor(message: string);
}JpegDecodeOptions#
Type.
interface JpegDecodeOptions {
colorTransform?: boolean;
maxPixels?: number;
}JpegError#
Value, from @birchui/pdf and @birchui/pdf/engine.
class JpegError extends Error {
constructor(message: string);
}JpegImage#
Type.
interface JpegImage {
width: number;
height: number;
components: 1 | 3 | 4;
data: Uint8Array;
isProgressive: boolean;
hasAdobeMarker: boolean;
colorTransform: boolean;
planes: JpegPlane[];
}mimeTypeForFileName#
Value, from @birchui/pdf and @birchui/pdf/engine.
function mimeTypeForFileName(fileName: string): string;PdfBytes#
Type.
type PdfBytes = Uint8Array<ArrayBuffer>;PdfLimitError#
Value, from @birchui/pdf and @birchui/pdf/engine.
class PdfLimitError extends Error {
constructor( readonly limit: PdfLimitName, readonly allowed: number, message: string, );
}PdfLimitName#
Type.
type PdfLimitName = keyof PdfLimits;PdfLimits#
Type.
interface PdfLimits {
maxStreamBytes: number;
maxExpansionRatio: number;
maxTotalDecodedBytes: number;
maxFilterChain: number;
maxImagePixels: number;
maxNestingDepth: number;
maxTreeDepth: number;
maxGraphicsStateDepth: number;
maxContentOperations: number;
maxPageContentBytes: number;
}pdfStyles#
Value, from @birchui/pdf.
const pdfStyles: "\n.lq-pdf {\n --lq-pdf-font-family: var(--lq-font-family, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif);\n --lq-pdf-font-size: var(--lq-font-size, 13px);\n --lq-pdf-fg: var(--lq-fg, #1f2328);\n --lq-pdf-bg: var(--lq-bg, #ffffff);\n --lq-pdf-muted: var(--lq-muted-fg, #59...;PdfSyntaxError#
Value, from @birchui/pdf and @birchui/pdf/engine.
class PdfSyntaxError extends Error {
constructor( message: string, readonly offset: number, );
}PdfWriteError#
Value, from @birchui/pdf and @birchui/pdf/engine.
class PdfWriteError extends Error {
constructor(message: string);
}setDefaultPdfLimits#
Value, from @birchui/pdf and @birchui/pdf/engine.
function setDefaultPdfLimits(limits?: Partial<PdfLimits>): PdfLimits;toPdfBytes#
Value, from @birchui/pdf and @birchui/pdf/engine.
function toPdfBytes(bytes: Uint8Array): PdfBytes;UnsupportedFilterError#
Value, from @birchui/pdf and @birchui/pdf/engine.
class UnsupportedFilterError extends Error {
constructor(readonly filter: string);
}