import { ObjectManager } from "../../ObjectManager"; import { AnnotationBase, type AnnotationBaseProperties } from "./AnnotationBase"; import { type DefaultAppearance, type DefaultAppearanceProperties } from "./DefaultAppearance"; import type { Point } from "../../Types"; import type { BorderProperties } from "./Border"; import { Border } from "./Border"; import type { Color } from "../../Types"; import { ObjectBase } from "../../ObjectBase"; import { CaptionImageRelation } from "../../Enums"; import { ImageScaleMode } from "../../Enums"; import { CheckStyle } from "../../Enums"; import { VariableTextJustification } from "../../Enums"; import { HighlightingMode } from "../../Enums"; import type { PdfImageHandler } from "../PdfImageHandler"; import { ActionBase, type ActionProperties } from "../Action"; /** * Represents image alignment within a rectangle in a PDF. */ export type ImageScaleProperties = { /** * The scaling mode. * Not specified means "Always". */ mode?: ImageScaleMode; /** * Indicating whether an image should be scaled proportionally. * Note specified means true. */ proportional?: boolean; /** * Gets or sets the position of an image. * The two numbers between 0.0 and 1.0 indicate the fraction of leftover space to allocate at the left and bottom of an image. * A value of (0.0, 0.0) positions the image at the bottom-left corner of the button rectangle. * A value of (0.5, 0.5) centers it within the rectangle. * This value is used only if the image is scaled proportionally. * * Not specified means { 0.5, 0.5 } */ position?: Point; /** * Gets or sets a value indicating whether a button's appearance should be scaled to fit fully * within the bounds of the annotation without taking into consideration the line width of the border. * * Not specified means false. */ ignoreBorder?: boolean; }; /** * Defines properties of a {@link ButtonAppearance} object. */ export type ButtonAppearanceProperties = { /** * The button's caption. */ caption?: string; /** * The button's caption used when the mouse button is pressed within its active area. */ downCaption?: string; /** * The button's caption used when the user rolls the cursor into its active area without pressing the mouse button. */ rolloverCaption?: string; /** * The button's image. * * You can use {@link PdfImageHandler} to assign an image to this property, for example: * @example * const img = await Image.load(IMAGE_BYTES); * btn.buttonAppearance.image = doc.imageHandlers.GetImageHandler(img); */ image?: PdfImageHandler; /** * Indicating how to position the button's caption relative to image. */ captionImageRelation?: CaptionImageRelation; /** * The image scaling, it can be specified as an {@link ImageScaleProperties} object or one of predefined values: * "scale", "stretch". */ imageScale?: ImageScaleProperties | "scale" | "stretch"; }; /** * Defines properties of a {@link WidgetAnnotation}. */ export type WidgetProperties = AnnotationBaseProperties & { /** * The apperance that specifies the visual properties (font, font size etc.) used to format * the content of the annotation. * The apperance can be specified as {@link DefaultAppearanceProperties} with set of properties like font, fontSize, foreColor or * as a string as it will be stored in a PDF stream: "/DF0 10 Tf 0 0 0 rg". */ defaultAppearance?: DefaultAppearanceProperties | string; /** * The {@link ButtonAppearanceProperties} object that specifies the look of the widget * if it is linked with a push button field. */ buttonAppearance?: ButtonAppearanceProperties; /** * The style of check mark that is used if a {@link WidgetAnnotation} * is linked with a {@link CheckBoxField} or a {@link RadioButtonField}. * * Note that this property works over the 'buttonAppearance.Caption' property, * for example if 'checkStyle' is "Cross", * then 'buttonAppearance.caption' will be "8". * * If the value of this property is null, it indicates that ButtonAppearance.Caption * contains an unknown value. */ checkStyle?: CheckStyle; /** * The justification to be used in displaying the annotation's text. * Note that if this property is not specified (the value is null) then {@link Field#justification} is used. * See PDF specification for details. */ justification?: VariableTextJustification; /** * The name of the annotation. * If {@link WidgetAnnotation} is used with {@link RadioButtonField} then * 'name' is used as a value. */ name?: string; /** * The annotation's highlighting mode. */ highlighting?: HighlightingMode; /** * The {@link BorderProperties} object defining annotation's border. */ border?: BorderProperties; /** * The angle, in degrees, by which the widget annotation * is rotated counterclockwise relative to the page. * The value must be a multiple of 90. */ rotationAngle?: number; /** * The annotation's background color. */ backColor?: Color; /** * An action to be performed when the annotation is activated. */ activate?: ActionBase | ActionProperties; /** * An action to be performed when the mouse enters the field's active area. */ mouseEnter?: ActionBase | ActionProperties; /** * An action to be performed when the cursor exits the field's active area. */ mouseLeave?: ActionBase | ActionProperties; /** * An action to be performed when the mouse button is pressed inside the field's active area. */ mouseDown?: ActionBase | ActionProperties; /** * An action to be performed when the mouse button is released inside the field's active area. */ mouseUp?: ActionBase | ActionProperties; /** * An action to be performed when the annotation receives the input focus. */ enter?: ActionBase | ActionProperties; /** * An action to be performed when the annotation loses the input focus. */ leave?: ActionBase | ActionProperties; /** * An action to be performed when the page containing the annotation is opened * (for example, when the user navigates to it from the next or previous page or by means of a link annotation * or outline item). */ annotationPageOpened?: ActionBase | ActionProperties; /** * An action to be performed when the page containing the annotation is closed * (for example, when the user navigates to the next or previous page, or follows a link annotation or outline item). */ annotationPageClosed?: ActionBase | ActionProperties; /** * An action to be performed when the page containing the annotation becomes visible in * the viewer application's user interface. */ annotationPageShow?: ActionBase | ActionProperties; /** * An action to be performed when the page containing the annotation is no longer visible in * the viewer application's user interface. */ annotationPageHide?: ActionBase | ActionProperties; }; /** * Defines properties of a {@link WidgetAnnotation}. */ export type WidgetAnnotationProperties = WidgetProperties & { type: "widget"; }; /** * Represents the appearance of a {@link WidgetAnnotation} when it is linked with a push button or a signature field. **/ export declare class ButtonAppearance extends ObjectBase { /** * Gets or sets the button's caption. */ get caption(): string | null; /** * Gets or sets the button's caption. */ set caption(value: string | null); /** * Gets or sets the button's caption * used when the mouse button is pressed within its active area. */ get downCaption(): string | null; /** * Gets or sets the button's caption * used when the mouse button is pressed within its active area. */ set downCaption(value: string | null); /** * Gets the button's caption * used when the user rolls the cursor into its active area without pressing the mouse button. */ get rolloverCaption(): string | null; /** * Sets the button's caption * used when the user rolls the cursor into its active area without pressing the mouse button. */ set rolloverCaption(value: string | null); /** * Gets the button's image as {@link PdfImageHandler} object. * * You can use {@link PdfImageHandler#image} property to get actual image. */ get image(): PdfImageHandler | null; /** * Sets the button's image. * * You can use {@link PdfImageHandler} to assign an image to this property, for example: * @example * const img = await Image.load(IMAGE_BYTES); * btn.buttonAppearance.image = doc.imageHandlers.GetImageHandler(img); */ set image(value: PdfImageHandler | null); /** * Gets or sets a value indicating how to position the button's caption relative to image. */ get captionImageRelation(): CaptionImageRelation; /** * Gets or sets a value indicating how to position the button's caption relative to image. */ set captionImageRelation(value: CaptionImageRelation); /** * Gets or sets the {@link ImageScaleProperties} object defining attributes of image scaling. */ get imageScale(): ImageScaleProperties; /** * Gets or sets the {@link ImageScaleProperties} object defining attributes of image scaling. */ set imageScale(value: ImageScaleProperties); } /** * Represents a widget annotation used in interactive forms to represent the appearance of fields and * to manage user interactions. */ export declare class WidgetAnnotation extends AnnotationBase { /** * Creates a new {@link WidgetAnnotation}. * * @param om - {@link ObjectManager} that controls the lifetime of the {@link WidgetAnnotation}. */ constructor(om: ObjectManager); /** * Creates a new {@link WidgetAnnotation}. */ constructor(); /** * Gets the {@link DefaultAppearance} object that specifies * the visual properties (font, font size etc.) used to format the content of this annotation. */ get defaultAppearance(): DefaultAppearance; /** * Gets the {@link ButtonAppearance} object that specifies the look of the widget * if it is linked with a push button field. */ get buttonAppearance(): ButtonAppearance; /** * Gets or sets the style of check mark that is used if this {@link WidgetAnnotation} * is linked with a {@link CheckBoxField} or a {@link RadioButtonField}. * * Note that this property works over the 'buttonAppearance.Caption' property, * for example if 'checkStyle' is "Cross", * then 'buttonAppearance.Caption' will be "8". * * If the value of this property is null, it indicates that ButtonAppearance.Caption * contains an unknown value. */ get checkStyle(): CheckStyle | null; /** * Gets or sets the style of check mark that is used if this {@link WidgetAnnotation} * is linked with a {@link CheckBoxField} or a {@link RadioButtonField}. * * Note that this property works over the 'buttonAppearance.Caption' property, * for example if 'checkStyle' is "Cross", * then 'buttonAppearance.Caption' will be "8". * * If the value of this property is null, it indicates that ButtonAppearance.Caption * contains an unknown value. */ set checkStyle(value: CheckStyle); /** * Gets or sets the justification to be used in displaying the annotation's text. * Note that if this property is not specified (the value is null) then {@link Field#justification} is used. * See PDF specification for details. */ get justification(): VariableTextJustification | null; /** * Gets or sets the justification to be used in displaying the annotation's text. * Note that if this property is not specified (the value is null) then {@link Field#justification} is used. * See PDF specification for details. */ set justification(value: VariableTextJustification | null); /** * Gets or sets the name of the annotation. * If {@link WidgetAnnotation} is used with {@link RadioButtonField} then * {@link name} is used as a value. */ get name(): string | null; /** * Gets or sets the name of the annotation. * If {@link WidgetAnnotation} is used with {@link RadioButtonField} then * {@link name} is used as a value. */ set name(value: string | null); /** * Gets or sets the annotation's highlighting mode. */ get highlighting(): HighlightingMode; /** * Gets or sets the annotation's highlighting mode. */ set highlighting(value: HighlightingMode); /** * Gets or sets the annotation border. */ get border(): Border; /** * Gets or sets the annotation border. */ set border(value: Border | BorderProperties | null); /** * Gets or sets the angle, in degrees, by which the widget annotation * is rotated counterclockwise relative to the page. * The value must be a multiple of 90. */ get rotationAngle(): number; /** * Gets or sets the angle, in degrees, by which the widget annotation * is rotated counterclockwise relative to the page. * The value must be a multiple of 90. */ set rotationAngle(value: number); /** * Gets or sets the annotation's background color. */ get backColor(): Color; /** * Gets or sets the annotation's background color. */ set backColor(value: Color); /** * Gets or sets an action to be performed when the annotation is activated. */ get activate(): ActionBase | null; /** * Gets or sets an action to be performed when the annotation is activated. */ set activate(value: ActionBase | ActionProperties | null); /** * Gets or sets an action to be performed when the mouse enters the field's active area. */ get mouseEnter(): ActionBase | null; /** * Gets or sets an action to be performed when the mouse enters the field's active area. */ set mouseEnter(value: ActionBase | ActionProperties | null); /** * Gets or sets an action to be performed when the cursor exits the field's active area. */ get mouseLeave(): ActionBase | null; /** * Gets or sets an action to be performed when the cursor exits the field's active area. */ set mouseLeave(value: ActionBase | ActionProperties | null); /** * Gets or sets an action to be performed when the mouse button is pressed inside the field's active area. */ get mouseDown(): ActionBase | null; /** * Gets or sets an action to be performed when the mouse button is pressed inside the field's active area. */ set mouseDown(value: ActionBase | ActionProperties | null); /** * Gets or sets an action to be performed when the mouse button is released inside the field's active area. */ get mouseUp(): ActionBase | null; /** * Gets or sets an action to be performed when the mouse button is released inside the field's active area. */ set mouseUp(value: ActionBase | ActionProperties | null); /** * Gets or sets an action to be performed when the annotation receives the input focus. */ get enter(): ActionBase | null; /** * Gets or sets an action to be performed when the annotation receives the input focus. */ set enter(value: ActionBase | ActionProperties | null); /** * Gets or sets an action to be performed when the annotation loses the input focus. */ get leave(): ActionBase | null; /** * Gets or sets an action to be performed when the annotation loses the input focus. */ set leave(value: ActionBase | ActionProperties | null); /** * Gets or sets an action to be performed when the page containing the annotation is opened * (for example, when the user navigates to it from the next or previous page or by means of a link annotation * or outline item). */ get annotationPageOpened(): ActionBase | null; /** * Gets or sets an action to be performed when the page containing the annotation is opened * (for example, when the user navigates to it from the next or previous page or by means of a link annotation * or outline item). */ set annotationPageOpened(value: ActionBase | ActionProperties | null); /** * Gets or sets an action to be performed when the page containing the annotation is closed * (for example, when the user navigates to the next or previous page, or follows a link annotation or outline item). */ get annotationPageClosed(): ActionBase | null; /** * Gets or sets an action to be performed when the page containing the annotation is closed * (for example, when the user navigates to the next or previous page, or follows a link annotation or outline item). */ set annotationPageClosed(value: ActionBase | ActionProperties | null); /** * Gets or sets an action to be performed when the page containing the annotation becomes visible in * the viewer application's user interface. */ get annotationPageShow(): ActionBase | null; /** * Gets or sets an action to be performed when the page containing the annotation becomes visible in * the viewer application's user interface. */ set annotationPageShow(value: ActionBase | ActionProperties | null); /** * Gets or sets an action to be performed when the page containing the annotation is no longer visible in * the viewer application's user interface. */ get annotationPageHide(): ActionBase | null; /** * Gets or sets an action to be performed when the page containing the annotation is no longer visible in * the viewer application's user interface. */ set annotationPageHide(value: ActionBase | ActionProperties | null); }