import * as ds from "../Types"; import { ObjectBase } from "../ObjectBase"; import { type DrawingContext } from "../DrawingContext"; import { type Image } from "../Image"; import { type PdfContext } from "./PdfContext"; import { type PdfDocument } from "./PdfDocument"; import { type SvgDocument } from "../SvgDocument"; import { type AnnotationCollection } from "./Annotations/AnnotationCollection"; import { type Font } from "../Font"; import type { DeleteTextMode } from "../Enums"; /** * Represents a page in a {@link PdfDocument}. **/ export declare class PdfPage extends ObjectBase { /** * Gets the list of annotations associated with the {@link PdfPage}. */ get annotations(): AnnotationCollection; /** * Gets the owner {@link PdfDocument} or null, if the {@link PdfPage} is orphan. **/ get document(): PdfDocument | null; /** * Gets a {@link PdfContext} for the current page. **/ get context(): PdfContext; /** * Gets the index of the {@link PdfPage} in the owner {@link PdfPageCollection}, or -1. **/ get index(): number; /** * The width of the {@link PdfPage}, in points. **/ get width(): number; /** * The height of the {@link PdfPage}, in points. **/ get height(): number; /** * Gets or sets the bounds of the {@link PdfPage} in points. */ get mediaBox(): ds.Rect; /** * Gets or sets the bounds of the {@link PdfPage} in points. */ set mediaBox(value: ds.Rect); /** * Gets or sets a rectangle, in points, defining the visible region of default user space. * When the {@link PdfPage} is displayed or printed, its contents are to be clipped (cropped) to this * rectangle and then imposed on the output medium in some implementation-defined manner. * Default value is {@link PdfPage@mediaBox}. */ get cropBox(): ds.Rect | null; /** * Gets or sets a rectangle, in points, defining the visible region of default user space. * When the {@link PdfPage} is displayed or printed, its contents are to be clipped (cropped) to this * rectangle and then imposed on the output medium in some implementation-defined manner. * Default value is {@link PdfPage@mediaBox}. */ set cropBox(value: ds.Rect | null); /** * Gets or sets the number of degrees by which the {@link PdfPage} should be rotated clockwise when displayed or printed. * The value is a multiple of 90. **/ get rotation(): number; /** * Gets or sets the number of degrees by which the {@link PdfPage} should be rotated clockwise when displayed or printed. * The value is a multiple of 90. **/ set rotation(degrees: number); /** * Gets or sets the {@link PdfPage}'s display duration (also called its advance timing): the maximum length of time, in seconds, * that the page shall be displayed during presentations before the viewer application shall automatically * advance to the next page. The value of null means that the viewer shall not advance automatically. **/ get transitionDuration(): number | null; /** * Gets or sets the {@link PdfPage}'s display duration (also called its advance timing): the maximum length of time, in seconds, * that the page shall be displayed during presentations before the viewer application shall automatically * advance to the next page. The value of null means that the viewer shall not advance automatically. **/ set transitionDuration(value: number | null); /** * Retrieves all text on the {@link PdfPage}. */ getText(): string; /** * Draws the {@link PdfPage} on the given context into the specified rectangle. * @param context The target drawing context. * @param x The X coordinate of the destination rectangle. * @param y The Y coordinate of the destination rectangle. * @param width The width of the destination rectangle. * @param height The height of the destination rectangle. * @param options The options for the drawing the {@link PdfPage}. * * @example * const page = doc.pages.getAt(0); * const svgCtx = new SvgContext(300, 500); * page.draw(svgCtx, 0, 0, 300, 500, { * viewStateMode: ViewStateMode.Print * }); * const svgDoc = svgCtx.toSvgDocument(); **/ draw(context: DrawingContext, x: number, y: number, width: number, height: number, options?: ds.DrawPdfPageOptions): void; /** * Draws the {@link PdfPage} on the given context into the specified rectangle. * @param context The target drawing context. * @param bounds The destination rectangle. * @param options The options for the drawing the {@link PdfPage}. **/ draw(context: DrawingContext, bounds: ds.Bounds, options?: ds.DrawPdfPageOptions): void; /** * Saves the {@link PdfPage} to a byte array in PNG format. * @param options The options for page export. * @returns The resulting binary data in PNG format. * * @example * const doc = PdfDocument.load(data); * const page = doc.pages.getAt(0); * const imageBytes = page.saveAsPng({ backColor: "GhostWhite" }); **/ saveAsPng(options?: ds.SaveAsImageOptions): Uint8Array; /** * For internal use only. * Saves the page to a byte array in PNG format, compares result with a gage, * returns null if the generated image same as the gage, or the generated image otherwise. * @ignore */ saveAsPngAndCompareWithGage(gage: Uint8Array, options?: ds.SaveAsImageOptions): Uint8Array | null; /** * Saves the {@link PdfPage} to an Image in PNG format. * @param options The options for page export. * @returns The resulting Image object. **/ saveAsPngImage(options?: ds.SaveAsImageOptions): Image; /** * Saves the {@link PdfPage} to a byte array in SVG format. * @param options The options for page export. * @returns The resulting data in UTF-8 encoded SVG format. **/ saveAsSvg(options?: ds.SaveAsImageOptions): Uint8Array; /** * Saves the {@link PdfPage} to a byte array in SVG.GZ format. * @param options The options for page export. * @returns The resulting binary data in SVG.GZ format. **/ saveAsSvgGz(options?: ds.SaveAsImageOptions): Uint8Array; /** * Saves the {@link PdfPage} as an SvgDocument. * @param options The options for page export. * @returns The resulting SvgDocument object. **/ saveAsSvgDocument(options?: ds.SaveAsImageOptions): SvgDocument; /** * Replaces a specified text on the {@link PdfPage}. * * Note that the results may be affected by the current value of the {@link PdfDocument#recognitionAlgorithm} property. * * @param findTextParams - The text to search for. * @param newText - The replacement text. * @param font - The font to use on 'newText', if null the current font will be used. * @param fontSize - The font size to use on 'newText', if null the current font size will be used. */ replaceText(findTextParams: ds.FindTextParams, newText: string, font?: Font | null, fontSize?: number | null): void; /** * Replaces a specified text on the {@link PdfPage}. * * Note that the results may be affected by the current value of the {@link PdfDocument#recognitionAlgorithm} property. * * @param textMapFragment - The text range. * @param newText - The replacement text. * @param font - The font to use on 'newText', if null the current font will be used. * @param fontSize - The font size to use on 'newText', if null the current font size will be used. */ replaceText(textMapFragment: ds.TextMapFragment, newText: string, font?: Font | null, fontSize?: number | null): void; /** * Deletes a specified text from the {@link PdfPage}. * @param findTextParams - The text to search for. * @param deleteTextMode - The text delete mode. */ deleteText(findTextParams: ds.FindTextParams, deleteTextMode: DeleteTextMode): void; /** * Deletes the specified text range from the {@link PdfPage}. * @param textMapFragment - The text range. * @param deleteTextMode - The text delete mode. */ deleteText(textMapFragment: ds.TextMapFragment, deleteTextMode: DeleteTextMode): void; /** * Gets the size of the {@link PdfPage} on a device with specified horizontal and vertical resolutions. * @param deviceDpiX - The horizontal device resolution. * @param deviceDpiY - The vertical device resolution. */ getRenderSize(deviceDpiX?: number, deviceDpiY?: number): ds.Size; /** * Converts specified visual coordinates (usually in the coordinate system with the origin * in the top left corner of the {@link PdfPage} and the Y axis going down, see 'fromBottomLeft') * to coordinates that take into account {@link PdfPage#rotation}, {@link PdfPage#cropBox} * and {@link PdfPage#mediaBox} (if 'CropBox' is not specified) values. * This method should be used when positioning annotations or destinations on a page. * Do not use this method when drawing on 'context'. * * @param value - The {@link Quadrilateral} to adjust. * @param fromBottomLeft - If true, the source coordinates' origin is in the bottom left corner of the page with Y axis going up (by default it is in the top left corner with Y axis going down). * @param deviceDpiX - The horizontal device resolution. * @param deviceDpiY - The vertical device resolution. * @returns */ adjustQuadrilateral(value: ds.Quadrilateral, fromBottomLeft?: boolean, deviceDpiX?: number, deviceDpiY?: number): ds.Quadrilateral; /** * Converts specified visual coordinates (usually in the coordinate system with the origin * in the top left corner of the {@link PdfPage} and the Y axis going down, see 'fromBottomLeft') * to coordinates that take into account {@link PdfPage#rotation}, {@link PdfPage#cropBox} * and {@link PdfPage#mediaBox} (if 'CropBox' is not specified) values. * This method should be used when positioning annotations or destinations on a page. * Do not use this method when drawing on 'context'. * * @param value - The {@link Rect} to adjust. * @param fromBottomLeft - If true, the source coordinates' origin is in the bottom left corner of the page with Y axis going up (by default it is in the top left corner with Y axis going down). * @param deviceDpiX - The horizontal device resolution. * @param deviceDpiY - The vertical device resolution. * @returns */ adjustRect(value: ds.Rect, fromBottomLeft?: boolean, deviceDpiX?: number, deviceDpiY?: number): ds.Rect; /** * Converts specified visual coordinates (usually in the coordinate system with the origin * in the top left corner of the {@link PdfPage} and the Y axis going down, see 'fromBottomLeft') * to coordinates that take into account {@link PdfPage#rotation}, {@link PdfPage#cropBox} * and {@link PdfPage#mediaBox} (if 'CropBox' is not specified) values. * This method should be used when positioning annotations or destinations on a page. * Do not use this method when drawing on 'context'. * * @param value - The {@link Point} to adjust. * @param fromBottomLeft - If true, the source coordinates' origin is in the bottom left corner of the page with Y axis going up (by default it is in the top left corner with Y axis going down). * @param deviceDpiX - The horizontal device resolution. * @param deviceDpiY - The vertical device resolution. * @returns */ adjustPoint(value: ds.Point, fromBottomLeft?: boolean, deviceDpiX?: number, deviceDpiY?: number): ds.Point; }