import type { Component, ComponentInternalInstance, ComputedRef, VNode } from "vue"; import { AnnotationFlag, AnnotationType, EventAnnotation, EventCore } from "./enumerators"; export type LocaleKey = "en_US" | "zh_CN" | "it_IT" | "pt_PT" | "th_TH" | string; export type Localization = { searchButtonTooltip: string; searchInputPlaceholder: string; searchInputTooltip: string; searchPrevTooltip: string; searchNextTooltip: string; searchCloseButtonTooltip: string; searchMatchCaseLabel: string; searchMatchCaseTooltip: string; searchWholeWordsLabel: string; searchWholeWordsTooltip: string; previousPageTooltip: string; currentPageTooltip: string; nextPageTooltip: string; zoomOutTooltip: string; zoomInTooltip: string; zoomSelectTooltip: string; zoomActualSize: string; zoomPageFit: string; zoomPageWidth: string; themeEnableDarkTooltip: string; themeEnableLightTooltip: string; openLocalFileLabel: string; openLocalFileTooltip: string; downloadFileLabel: string; downloadFileTooltip: string; commentPanelTooltip: string; commentPanelLabel: string; commentPageSuffix: string; commentPagePrefix: string; commentLabel: string; commentHideTooltip: string; printLabel: string; printTooltip: string; printLoadingMessage: string; printCancelLabel: string; fullScreenLabel: string; fullScreenTooltip: string; moreOptionTooltip: string; firstPageLabel: string; firstPageTooltip: string; lastPageLabel: string; lastPageTooltip: string; rotateClockwiseLabel: string; rotateClockwiseTooltip: string; rotateCounterclockwiseLabel: string; rotateCounterclockwiseTooltip: string; textSelectionLabel: string; textSelectionTooltip: string; handToolLabel: string; handToolTooltip: string; pageScrollingLabel: string; pageScrollingTooltip: string; verticalScrollingLabel: string; verticalScrollingTooltip: string; horizontalLabel: string; horizontalTooltip: string; wrappedScrollingLabel: string; wrappedScrollingTooltip: string; singlePageLabel: string; singlePageTooltip: string; dualPageLabel: string; dualPageTooltip: string; dualPageWithCoverLabel: string; dualPageWithCoverTooltip: string; documentPropertiesLabel: string; documentPropertiesTooltip: string; propertiesFilenameLabel: string; propertiesFileSizeLabel: string; propertiesTitleLabel: string; propertiesAuthorLabel: string; propertiesSubjectLabel: string; propertiesKeywordLabel: string; propertiesCreatorLabel: string; propertiesCreateOnLabel: string; propertiesModifiedOnLabel: string; propertiesPDFProducerLabel: string; propertiesPDFVersionLabel: string; propertiesPageCountLabel: string; thumbnailTooltip: string; passwordModalTitle: string; passwordModalMessage: string; passwordPlaceholder: string; passwordConfirmLabel: string; passwordError: string; dragDropFileMessage: string; annotationLabel: string; annotationToggleShowTooltip: string; annotationToggleHideTooltip: string; annotationTextSelectionLabel: string; annotationTextSelectionTooltip: string; annotationHighlightLabel: string; annotationHighlightTooltip: string; annotationHighlightColorTooltip: string; annotationHighlightColorPickerLabel: string; annotationHighlightDeleteTooltip: string; annotationUnderlineLabel: string; annotationUnderlineTooltip: string; annotationUnderlineColorTooltip: string; annotationUnderlineColorPickerLabel: string; annotationUnderlineDeleteTooltip: string; annotationStrikethroughLabel: string; annotationStrikethroughTooltip: string; annotationStrikethroughColorTooltip: string; annotationStrikethroughColorPickerLabel: string; annotationStrikethroughDeleteTooltip: string; annotationFreeTextLabel: string; annotationFreeTextTooltip: string; annotationFreeTextDeleteTooltip: string; annotationFreeTextTextStyleLabel: string; annotationFreeTextTextStyleTooltip: string; annotationFreeTextFontColorLabel: string; annotationFreeTextTextSizeTooltip: string; annotationFreeTextTextSizeLabel: string; annotationFreeTextTextSizePlaceholder: string; annotationSignatureLabel: string; annotationSignatureTooltip: string; annotationSignatureAddLabel: string; annotationSignatureAddTooltip: string; annotationCommentLabel: string; annotationCommentTooltip: string; annotationImageLabel: string; annotationImageTooltip: string; annotationImageUnsupportedFileMessage: string; annotationImageUnsupportedFileSizeMessage: string; annotationImageDeleteTooltip: string; }; export type ToolbarDirection = "top" | "left" | "right"; export interface PluginItem { id: string; component: Component; toolbarDirection: ToolbarDirection; } export interface PluginContext { componentInstance: ComponentInternalInstance | null; toolbar: { addItem: (item: PluginItem) => void; }; shared: { localization: ComputedRef; ui: { AppButton?: Component; AppTooltip?: Component; AppPopover?: Component; AppColorPicker?: Component; AppSignatures?: Component; }; pdf?: { document: ComputedRef; getOriginalBytes: () => Promise; }; }; } export interface Plugin { name: string; setup: (ctx: PluginContext) => void; } export interface LabelValuePair { label: string; value: string; } export type AnnotationColors = LabelValuePair[] | string[]; export type AnnotationColorsLength = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12; export type AnnotationTextSelectionColors = (AnnotationColors & { length: AnnotationColorsLength; }) | null; export type AnnotationHighlightColors = AnnotationTextSelectionColors; export type AnnotationStrikethroughColors = AnnotationTextSelectionColors; export type AnnotationUnderlineColors = AnnotationTextSelectionColors; export type AnnotationFreeTextFontColors = AnnotationTextSelectionColors; export interface AnnotationToolOption { icon?: Component | VNode | string; component?: Component; } export interface HighlightToolOption extends AnnotationToolOption { colors?: AnnotationHighlightColors; } export interface StrikethroughToolOption extends AnnotationToolOption { colors?: AnnotationStrikethroughColors; } export interface UnderlineToolOption extends AnnotationToolOption { colors?: AnnotationUnderlineColors; } export interface TextSelectionOption extends AnnotationToolOption { highlight?: HighlightToolOption | boolean; strikethrough?: StrikethroughToolOption | boolean; underline?: UnderlineToolOption | boolean; } export interface FreeTextOption extends AnnotationToolOption { fontColors?: AnnotationFreeTextFontColors; fontSizes?: number[]; } /** * Image option for image annotation * @param maxSize - The maximum size of the image in bytes or a string with a unit (e.g. "1MB", "1000000", "1000000B"). Default is 1MB. * @param types - The types of the image (default: [ImageType.APNG, ImageType.AVIF, ImageType.BMP, ImageType.GIF, ImageType.ICON, ImageType.JPEG, ImageType.PNG, ImageType.SVG, ImageType.WEBP]) */ export interface ImageOption extends AnnotationToolOption { maxSize?: number | string; types?: ImageType[]; } export declare enum ImageType { APNG = "image/apng", AVIF = "image/avif", BMP = "image/bmp", GIF = "image/gif", JPEG = "image/jpeg", PNG = "image/png", SVG = "image/svg+xml", WEBP = "image/webp", ICON = "image/x-icon" } export declare enum ErrorCode { UnsupportedFileType = "unsupported-file-type", FileSizeExceeded = "file-size-exceeded" } export type VPVEvent = EventAnnotation | EventCore; export interface AnnotationAttachment { content: Uint8Array; filename: string; } export interface AnnotationBorderStyle { dashArray: number[]; horizontalCornerRadius: number; style: number; verticalCornerRadius: number; width: number; rawWidth: number; } export interface AnnotationStringObj { dir: string; str: string; } export type OutlineName = { name: string; }; export type OutlineRef = { gen: number; num: number; }; export type OutlineDestinations = [ (OutlineRef | number), OutlineName, ...any[] ]; export type LinkAction = "FirstPage" | "LastPage" | "NextPage" | "PrevPage" | "GoBack" | "GoForward"; export interface Annotation { id: string | null; annotationType: AnnotationType; rotation: number; rect: number[]; parentRect?: number[]; fieldType?: string; annotationFlags?: AnnotationFlag; borderStyle?: AnnotationBorderStyle; color?: Uint8ClampedArray | null; creationDate?: string | Date | null; backgroundColor?: Uint8ClampedArray | null; borderColor?: Uint8ClampedArray | null; contentsObj?: AnnotationStringObj; hasOwnCanvas?: boolean; hasAppearance?: boolean; modificationDate?: string | Date | null; quadPoints?: Float32Array; subtype?: string; noRotate?: boolean; noHTML?: boolean; isEditable?: boolean; structParent?: number; titleObj?: AnnotationStringObj; opacity?: number; file?: AnnotationAttachment; inReplyTo?: string; value?: string; dest?: OutlineDestinations; url?: string; unsafeUrl?: string; action?: LinkAction; newWindow?: boolean; pageIndex?: number; deleted?: boolean; noView?: boolean; noPrint?: boolean; fontSize?: number; contents?: string; imageDataUrl?: string; } export type AnnotationCallback = (data: T) => void; export interface AnnotationEventCallback { onAnnotationCreated?: AnnotationCallback; onAnnotationUpdated?: AnnotationCallback; onAnnotationDeleted?: AnnotationCallback; } /** * Deleted annotation data for removal from PDF * Contains full annotation data for position-based matching fallback * (PDF annotations may not have /NM field) */ export interface DeletedAnnotationData { id: string; pageIndex: number; annotationType: number; rect?: number[]; quadPoints?: number[]; } export interface XfdfSkippedEntry { elementName: string; page: number; reason: string; } export interface XfdfImportResult { annotations: Annotation[]; skipped: XfdfSkippedEntry[]; errors: string[]; } export interface AnnotationPluginApi { exportToPdf: (annotations: Annotation[], deletedAnnotations?: DeletedAnnotationData[] | string[]) => Promise; exportToXfdf: (annotations: Annotation[], pdfFilename?: string) => string; importFromXfdf: (xfdfString: string, pageCount: number) => XfdfImportResult; } /** * Programmatic API for text selection annotation tools (highlight, underline, strikethrough). * Exposed on the VPdfViewer instance as `textSelectionControl`. * Undefined when the annotation plugin is not loaded. */ export interface AnnotationTextSelectionControl { /** Whether the highlight tool is currently active */ readonly isHighlightActive: boolean; /** Whether the underline tool is currently active */ readonly isUnderlineActive: boolean; /** Whether the strikethrough tool is currently active */ readonly isStrikethroughActive: boolean; /** Current highlight color as CSS hex string, or null if not set */ readonly highlightColor: string | null; /** Current underline color as CSS hex string, or null if not set */ readonly underlineColor: string | null; /** Current strikethrough color as CSS hex string, or null if not set */ readonly strikethroughColor: string | null; /** Toggle highlight tool. Activating deactivates other text selection tools. */ toggleHighlight(): void; /** Toggle underline tool. Activating deactivates other text selection tools. */ toggleUnderline(): void; /** Toggle strikethrough tool. Activating deactivates other text selection tools. */ toggleStrikethrough(): void; /** Deactivate all text selection tools. */ deactivateAll(): void; /** Set highlight color. Takes effect on the next annotation created. */ setHighlightColor(color: string): void; /** Set underline color. Takes effect on the next annotation created. */ setUnderlineColor(color: string): void; /** Set strikethrough color. Takes effect on the next annotation created. */ setStrikethroughColor(color: string): void; /** Set the highlight color palette shown in the popover. Accepts LabelValuePair[] or string[] (1–12 colors). */ setHighlightColorPalette(colors: AnnotationHighlightColors): void; /** Set the underline color palette shown in the popover. Accepts LabelValuePair[] or string[] (1–12 colors). */ setUnderlineColorPalette(colors: AnnotationUnderlineColors): void; /** Set the strikethrough color palette shown in the popover. Accepts LabelValuePair[] or string[] (1–12 colors). */ setStrikethroughColorPalette(colors: AnnotationStrikethroughColors): void; } /** * Programmatic API for the free text annotation tool. * Exposed on the VPdfViewer instance as `freeTextControl`. * Undefined when the annotation plugin is not loaded. */ export interface AnnotationFreeTextControl { /** Whether the free text annotation tool is currently active */ readonly isActive: boolean; /** Current default font color for new free text annotations (CSS hex string, e.g. '#000000'), or null if not set */ readonly fontColor: string | null; /** Current default font size for new free text annotations (in points), or null if not set */ readonly fontSize: number | null; /** Activate the free text tool. Deactivates all text-selection annotation tools. */ activate(): void; /** Deactivate the free text tool. No-op if already inactive. */ deactivate(): void; /** Set the default font color for new annotations (CSS hex string). Takes effect on the next annotation created. */ setFontColor(color: string): void; /** Set the default font size for new annotations (in points). Takes effect on the next annotation created. */ setFontSize(size: number): void; }