@syncfusion/ej2-pdf
Version:
Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.
1,174 lines (1,173 loc) • 41.2 kB
TypeScript
import { _PdfCrossReference } from './pdf-cross-reference';
import { _PdfDictionary, _PdfReference, _PdfName } from './pdf-primitives';
import { PdfAnnotationCollection } from './annotations/annotation-collection';
import { PdfGraphics, PdfGraphicsState } from './graphics/pdf-graphics';
import { _PdfContentStream } from './base-stream';
import { PdfRotationAngle, PdfDestinationMode, PdfFormFieldsTabOrder, PdfPageOrientation } from './enumerator';
import { PdfDocument, PdfPageSettings } from './pdf-document';
import { PdfTemplate } from './graphics/pdf-template';
import { PdfLayoutResult, _PdfLayoutParameters } from './graphics/pdf-layouter';
import { Point, Size, Rectangle } from './pdf-type';
import { PdfTextElement } from './pdf-type';
/**
* Represents a page loaded from the PDF document.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access first page
* let page: PdfPage = document.getPage(0);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
export declare class PdfPage {
/**
* Crossreference context for the page.
*
* @private
*/
_crossReference: _PdfCrossReference;
/**
* Zero based index of this page in the document.
*
* @private
*/
_pageIndex: number;
/**
* Underlying page dictionary.
*
* @private
*/
_pageDictionary: _PdfDictionary;
/**
* Indirect reference to this page object.
*
* @private
*/
_ref: _PdfReference;
/**
* Lazyparsed annotations collection.
*
* @private
*/
_annotations: PdfAnnotationCollection;
/**
* Indicates whether annotations have been parsed.
*
* @private
*/
_isAnnotationParsed: boolean;
/**
* Cached page size.
*
* @private
*/
_size: Size;
/**
* MediaBox array cache.
*
* @private
*/
_mBox: number[];
/**
* CropBox array cache.
*
* @private
*/
_cBox: number[];
/**
* Cached page orientation.
*
* @private
*/
_orientation: PdfPageOrientation;
/**
* Cached origin coordinates.
*
* @private
*/
_o: number[];
/**
* Graphics context for drawing on the page.
*
* @private
*/
_g: PdfGraphics;
/**
* Graphics state handle used for restore.
*
* @private
*/
_graphicsState: PdfGraphicsState;
/**
* Ordered list of content streams/references.
*
* @private
*/
_contents: Array<_PdfReference>;
/**
* Cached rotation angle.
*
* @private
*/
_rotation: PdfRotationAngle;
/**
* Initializes graphics again on next access when true.
*
* @private
*/
_needInitializeGraphics: boolean;
/**
* Indicates if the resources entry is an indirect reference.
*
* @private
*/
_hasResourceReference: boolean;
/**
* Resolved resources dictionary for the page.
*
* @private
*/
_resourceObject: _PdfDictionary;
/**
* Current tab order setting for form fields.
*
* @private
*/
_tabOrder: PdfFormFieldsTabOrder;
/**
* Page settings used for layout operations.
*
* @private
*/
_pageSettings: PdfPageSettings;
/**
* Indicates whether this page is newly created.
*
* @private
*/
_isNew: boolean;
/**
* Indicates whether this page is a duplicate of another.
*
* @private
*/
_isDuplicate: boolean;
/**
* Indicates whether the current operation pertains to a line annotation.
*
* @private
*/
_isLineAnnotation: boolean;
/**
* Indicates whether the page content was accessed before template rendering started.
*
* @private
*/
_accessedBeforeTemplate: boolean;
/**
* Indicates whether all templates have been rendered for the document or section.
*
* @private
*/
_templatesRendered: boolean;
/**
* Represents a loaded page of the PDF document.
*
* @private
* @param {_PdfCrossReference} crossReference Cross reference object.
* @param {number} pageIndex page index.
* @param {_PdfDictionary} dictionary page Dictionary.
* @param {_PdfReference} reference page reference.
*/
constructor(crossReference: _PdfCrossReference, pageIndex: number, dictionary: _PdfDictionary, reference: _PdfReference);
/**
* Gets the collection of the page's annotations (Read only).
*
* @returns {PdfAnnotationCollection} Annotation collection.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access first page
* let page: PdfPage = document.getPage(0);
* // Gets the annotation collection
* let annotations: PdfAnnotationCollection = page.annotations;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
readonly annotations: PdfAnnotationCollection;
/**
* Gets the size of the page (Read only).
*
* @returns {Size} The size of the PDF page.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access first page
* let page: PdfPage = document.getPage(0);
* // Gets the width and height of the PDF page as number array
* let size: Size = page.size;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
readonly size: Size;
/**
* Gets the rotation angle of the page (Read only).
*
* @returns {PdfRotationAngle} Page rotation angle.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access first page
* let page: PdfPage = document.getPage(0);
* // Gets the rotation angle of the page
* let rotation: PdfRotationAngle = page.rotation;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the rotation angle of the PDF page
*
* @param {PdfRotationAngle} value rotation angle.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access first page
* let page: PdfPage = document.getPage(0);
* // Sets the rotation angle of the PDF page
* page.rotate = PdfRotationAngle.angle90;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
rotation: PdfRotationAngle;
/**
* Gets the tab order of a PDF form field.
*
* @returns {PdfFormFieldsTabOrder} tab order.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access first page
* let page: PdfPage = document.getPage(0);
* // Gets the tab order of a PDF form field.
* let tabOrder: PdfFormFieldsTabOrder = page.tabOrder;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the tab order of a PDF form field.
*
* @param {PdfFormFieldsTabOrder} value tab order.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access first page
* let page: PdfPage = document.getPage(0);
* // Sets the tab order of a PDF form field.
* page.tabOrder = PdfFormFieldsTabOrder.row;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
tabOrder: PdfFormFieldsTabOrder;
/**
* Gets the bounds that define the area intended for display or printing in the PDF viewer application (Read only).
*
* @returns {number[]} Page size as number array.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access first page
* let page: PdfPage = document.getPage(0);
* // Gets the cropBox of the PDF page as number array
* let cropBox: number[] = page.cropBox;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
readonly cropBox: number[];
/**
* Gets the size that specify the width and height of the page (Read only).
*
* @returns {number[]} Page size as number array.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access first page
* let page: PdfPage = document.getPage(0);
* // Gets the mediaBox of the PDF page as number array
* let mediaBox: number[] = page.mediaBox;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
readonly mediaBox: number[];
/**
* Gets the orientation of the page (Read only).
*
* @returns {PdfPageOrientation} Page orientation.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access first page
* let page: PdfPage = document.getPage(0);
* // Gets the orientation of the PDF page
* let orientation: number[] = page.orientation;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
readonly orientation: PdfPageOrientation;
/**
* Gets the origin coordinates derived from the MediaBox.
*
* @returns {number[]} Origin as a two-element array [x, y].
*/
readonly _origin: number[];
/**
* Gets the graphics of the page (Read only).
*
* @returns {PdfGraphics} Page graphics.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access first page
* let page: PdfPage = document.getPage(0);
* // Gets the graphics of the PDF page
* let graphics: PdfGraphics = page.graphics;
* //Create a new pen.
* let pen: PdfPen = new PdfPen({r: 0, g: 0, b: 0}, 1);
* //Draw line on the page graphics.
* graphics.drawLine(pen, {x: 10, y: 10}, {x: 100, y: 100});
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
readonly graphics: PdfGraphics;
/**
* Draws a text element on the page at a given location.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access the first page of the document
* let page: PdfPage = document.getPage(0);
* // Create a text element
* let element: PdfTextElement = {
* text: 'Hello world drawn using a point location.',
* font: document.embedFont(PdfFontFamily.helvetica, 12, PdfFontStyle.regular),
* brush: new PdfBrush({ r: 0, g: 0, b: 0 })
* };
* // Draw the text element using a specific point
* const result = page.drawTextElement(element, { x: 50, y: 100 });
* // Save the PDF document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {PdfTextElement} element The text element to draw.
* @param {Point} location The location where the text element should be drawn.
* @returns {PdfLayoutResult} The layout result for the drawn text element.
*/
drawTextElement(element: PdfTextElement, location: Point): PdfLayoutResult;
/**
* Draws a text element inside a rectangle on the page.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access the first page of the document
* let page: PdfPage = document.getPage(0);
* // Create a text element
* let element: PdfTextElement = {
* text: 'Hello world drawn inside rectangle bounds.',
* font: document.embedFont(PdfFontFamily.helvetica, 12, PdfFontStyle.regular),
* brush: new PdfBrush({ r: 0, g: 0, b: 0 })
* };
* // Define the rectangle bounds
* let rect: Rectangle = { x: 10, y: 20, width: 200, height: 50 };
* // Draw the text element inside rectangle bounds
* const result = page.drawTextElement(element, rect);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {PdfTextElement} element The text element to draw.
* @param {Rectangle} bounds The bounds within which the text element should be drawn.
* @returns {PdfLayoutResult} The layout result for the drawn text element.
*/
drawTextElement(element: PdfTextElement, bounds: Rectangle): PdfLayoutResult;
/**
* Adds a widget annotation reference to the page's Annots array.
*
* @private
* @param {_PdfReference} reference Widget annotation reference to add.
* @returns {void} nothing.
*/
_addWidget(reference: _PdfReference): void;
/**
* Resolves an inheritable page property from the page tree.
*
* @private
* @param {string} key The dictionary key to fetch.
* @param {boolean} [getArray=false] Whether to return an array value as-is.
* @returns {any} Resolved value or merged dictionary.
*/
_getProperty(key: string, getArray?: boolean): any;
/**
* Initializes content streams and graphics for drawing operations.
*
* @private
* @returns {void} nothing.
*/
_parseGraphics(): void;
/**
* Loads the page's Contents entry into the internal reference list.
*
* @private
* @returns {void} nothing.
*/
_loadContents(): void;
/**
* Creates the graphics context and applies initial transforms and rotation.
*
* @private
* @param {_PdfContentStream} stream Target content stream to draw into.
* @returns {void} nothing.
*/
_initializeGraphics(stream: _PdfContentStream): void;
/**
* Computes the effective drawable content bounds of the page by excluding
* both page margins and the space reserved for document templates on all sides.
*
* @private
* @param {PdfPageSettings} pageSettings - The page settings that define the page size and margins.
* @param {boolean} [includeMargins] - Specifies whether the calculation should use the full page size
* (including margins) or the already adjusted content size.
* @returns {number[]} An array representing the computed bounds in the format:
* [x, y, width, height], where:
* - x: left offset including margin and left template space
* - y: top offset including margin and top template space
* - width: usable width after excluding left and right template spaces
* - height: usable height after excluding top and bottom template spaces.
*/
_getActualBounds(pageSettings: PdfPageSettings, includeMargins?: boolean): number[];
/**
* Calculates the effective template bounds of the page by excluding space
* reserved for other document templates on each side.
*
* @private
* @param {PdfPageSettings} pageSettings - The page settings that determine the actual page size.
* @param {boolean} [includeMargins] - Specifies whether page margins should be included in the reserved space calculation.
* @returns {number[]} An array representing the effective bounds in the format: * [x, y, width, height], where:
* - x: left offset
* - y: top offset
* - width: available width after excluding left and right reserved space
* - height: available height after excluding top and bottom reserved space
*/
_getActualTemplateBounds(pageSettings: PdfPageSettings, includeMargins?: boolean): number[];
/**
* Calculates the space reserved by document templates on all four edges.
*
* @private
* @param {boolean} includeMargins - Indicates whether page margins should be
* included along with template space in the calculation.
* @returns {number[]} An array representing the reserved space in the order: [top, right, bottom, left], in page units.
*/
_getTemplateReservedSpace(includeMargins?: boolean): number[];
/**
* Fetches or creates the resources dictionary for the page.
*
* @private
* @returns {_PdfDictionary} Resources dictionary.
*/
_fetchResources(): _PdfDictionary;
/**
* Returns the CropBox or MediaBox of the page, preferring CropBox when available.
*
* @private
* @returns {number[]} The selected box array.
*/
_getCropOrMediaBox(): number[];
/**
* Finalizes the graphics state and marks that graphics need reinitialization on next access.
*
* @private
* @returns {void}
*/
_beginSave(): void;
/**
* Releases page resources and cached values.
*
* @private
* @returns {void}
*/
_destroy(): void;
/**
* Resolves the current tab order from the page dictionary.
*
* @private
* @returns {PdfFormFieldsTabOrder} The resolved tab order.
*/
_obtainTabOrder(): PdfFormFieldsTabOrder;
/**
* Removes the specified annotation reference from the page's Annots array.
*
* @private
* @param {_PdfReference} reference Annotation reference to remove.
* @returns {void} nothing.
*/
_removeAnnotation(reference: _PdfReference): void;
/**
* Gets the page's combined content as a reusable template.
*
* @returns {PdfTemplate} Generated template containing the page content.
*/
readonly _contentTemplate: PdfTemplate;
_combineIntoSingleArray(arrays: Uint8Array[]): Uint8Array;
/**
* Concatenates multiple byte arrays into a single array.
*
* @private
* @returns {Uint8Array} Combined array.
*/
_combineContent(): Uint8Array;
/**
* Lays out and renders text within layout bounds, supporting column flow and pagination.
*
* @private
* @param {_PdfLayoutParameters} params Layout parameters defining page context, bounds, and layout behavior.
* @param {PdfTextElement} element Text element containing content, font, brush, and formatting information.
* @returns {PdfLayoutResult} The layout result containing the final page, bounds, and any remaining text.
*/
_layoutTextElement(params: _PdfLayoutParameters, element: PdfTextElement): PdfLayoutResult;
/**
* Parses a PDF box array and updates _PdfReference entries to numeric values.
*
* @param {any[]} boxValues - Array containing box coordinates.
* @param {string} key - Contains box name.
* @returns {number[]} Parsed box values as a number array.
*/
private _parseBoxValues;
/**
* Lays out and renders text within the specified bounds on a page, supporting multi-column flow and FitElement behavior, and returns layout details including remaining text.
*
* @private
* @param {string} text The input text content to be processed and rendered.
* @param {PdfPage} page The target page on which the text is laid out and drawn.
* @param {number[]} bounds The layout bounds as [x, y, width, height].
* @param {_PdfLayoutParameters} params Layout parameters providing page context and formatting options.
* @param {PdfTextElement} element The text element containing font, brush, and formatting settings.
* @returns {PdfLayoutResult} The result containing the rendered bounds, last line info, and any remaining text.
*/
private _layoutOnPage;
_getSectionIndex(): number;
}
/**
* `PdfDestination` class represents the PDF destination.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the annotation at index 0
* let annotation: PdfDocumentLinkAnnotation = document.getPage(0).annotations.at(0) as PdfDocumentLinkAnnotation;
* // Initializes a new instance of the `PdfDestination` class.
* let destination: PdfDestination = new PdfDestination();
* // Sets the zoom factor.
* destination.zoom = 20;
* // Sets the page where the destination is situated.
* destination.page = page;
* // Sets the mode of the destination.
* destination.mode = PdfDestinationMode.fitToPage;
* // Sets the location of the destination.
* destination.location = {x: 20, y: 20};
* // Sets the bounds of the destination.
* destination.destinationBounds = {x: 20, y: 20, width: 100, height: 50};
* // Sets destination to document link annotation.
* annotation.destination = destination;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
export declare class PdfDestination {
/**
* @private
*/
_page: PdfPage;
/**
* @private
*/
_location: Point;
/**
* @private
*/
_destinationMode: PdfDestinationMode;
/**
* @private
*/
_zoom: number;
/**
* @private
*/
_isValid: boolean;
/**
* @private
*/
_index: number;
/**
* @private
*/
_destinationBounds: Rectangle;
/**
* @private
*/
_array: Array<any>;
/**
* @private
*/
_parent: any;
/**
* @private
*/
_isBookmark: boolean;
/**
* Initializes a new instance of the `PdfDestination` class.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the annotation at index 0
* let annotation: PdfDocumentLinkAnnotation = document.getPage(0).annotations.at(0) as PdfDocumentLinkAnnotation;
* // Initializes a new instance of the `PdfDestination` class.
* let destination: PdfDestination = new PdfDestination();
* // Sets the zoom factor.
* destination.zoom = 20;
* // Sets the page where the destination is situated.
* destination.page = page;
* // Sets the mode of the destination.
* destination.mode = PdfDestinationMode.fitToPage;
* // Sets the location of the destination.
* destination.location = {x: 20, y: 20};
* // Sets the bounds of the destination.
* destination.destinationBounds = {x: 20, y: 20, width: 100, height: 50};
* // Sets destination to document link annotation.
* annotation.destination = destination;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
constructor();
/**
* Initializes a new instance of the `PdfDestination` class.
*
* @param {PdfPage} page PdfPage.
*/
constructor(page: PdfPage);
/**
* Initializes a new instance of the `PdfDestination` class.
*
* @param {PdfPage} page PdfPage.
* @param {Point} location Location.
*/
constructor(page: PdfPage, location: Point);
/**
* Initializes a new instance of the `PdfDestination` class.
*
* @param {PdfPage} page PdfPage.
* @param {Rectangle} bounds Bounds.
*/
constructor(page: PdfPage, bounds: Rectangle);
/**
* Initializes a new instance of the `PdfDestination` class.
*
* @param {PdfPage} page PdfPage.
* @param {Point} location Location.
* @param {object} options Destination options.
* @param {number} [options.zoom] The zoom level for the destination.
* @param {PdfDestinationMode} [options.mode] The destination display mode.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Get the first page
* let page: PdfPage = document.getPage(0) as PdfPage;
* // Create new document link annotation
* const docLink = new PdfDocumentLinkAnnotation(
* { x: 80, y: 100, width: 120, height: 18 },
* new PdfDestination(
* page: document.getPage(0),
* location: { x: 10, y: 20 }, {zoom: 5,
* mode: PdfDestinationMode.fitToPage
* }),
* { color: { r: 0, g: 128, b: 0 }, opacity: 1 }
* );
* // Add annotation to the page
* page.addAnnotation(docLink);
* // Destroy the document
* document.destroy();
* ```
*/
constructor(page: PdfPage, location: Point, options: {
zoom?: number;
mode?: PdfDestinationMode;
});
/**
* Initializes a new instance of the `PdfDestination` class.
*
* @param {PdfPage} page PdfPage.
* @param {Rectangle} bounds Bounds.
* @param {object} options Destination options.
* @param {number} [options.zoom] The zoom level for the destination.
* @param {PdfDestinationMode} [options.mode] The destination display mode.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Get the first page
* let page: PdfPage = document.getPage(0) as PdfPage;
* // Create new document link annotation
* const docLink = new PdfDocumentLinkAnnotation(
* { x: 80, y: 100, width: 120, height: 18 },
* new PdfDestination(
* page: document.getPage(0),
* bounds: { x: 10, y: 20, width: 100, height: 200 }, {zoom: 5,
* mode: PdfDestinationMode.fitToPage
* }),
* { color: { r: 0, g: 128, b: 0 }, opacity: 1 }
* );
* // Add annotation to the page
* page.addAnnotation(docLink);
* // Destroy the document
* document.destroy();
* ```
*/
constructor(page: PdfPage, bounds: Rectangle, options: {
zoom?: number;
mode?: PdfDestinationMode;
});
/**
* Gets the zoom factor.
*
* @returns {number} zoom.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* //Access the annotation at index 0
* let annot: PdfDocumentLinkAnnotation = page.annotations.at(0) as PdfDocumentLinkAnnotation;
* // Gets the zoom factor of the destination.
* let zoom: number = annot.destination.zoom;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the zoom factor.
*
* @param {number} value zoom.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the annotation at index 0
* let annotation: PdfDocumentLinkAnnotation = document.getPage(0).annotations.at(0) as PdfDocumentLinkAnnotation;
* // Initializes a new instance of the `PdfDestination` class.
* let destination: PdfDestination = new PdfDestination();
* // Sets the zoom factor.
* destination.zoom = 20;
* // Sets the page where the destination is situated.
* destination.page = page;
* // Sets the mode of the destination.
* destination.mode = PdfDestinationMode.fitToPage;
* // Sets the location of the destination.
* destination.location = {x: 20, y: 20};
* // Sets the bounds of the destination.
* destination.destinationBounds = {x: 20, y: 20, width: 100, height: 50};
* // Sets destination to document link annotation.
* annotation.destination = destination;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
zoom: number;
/**
* Gets the page where the destination is situated.
*
* @returns {PdfPage} page.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* //Access the annotation at index 0
* let annot: PdfDocumentLinkAnnotation = document.getPage(0).annotations.at(0) as PdfDocumentLinkAnnotation;
* // Gets the page of the destination.
* let page: PdfPage = annot.destination.page;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the page where the destination is situated.
*
* @param {PdfPage} value page.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the annotation at index 0
* let annotation: PdfDocumentLinkAnnotation = document.getPage(0).annotations.at(0) as PdfDocumentLinkAnnotation;
* // Initializes a new instance of the `PdfDestination` class.
* let destination: PdfDestination = new PdfDestination();
* // Sets the zoom factor.
* destination.zoom = 20;
* // Sets the page where the destination is situated.
* destination.page = page;
* // Sets the mode of the destination.
* destination.mode = PdfDestinationMode.fitToPage;
* // Sets the location of the destination.
* destination.location = {x: 20, y: 20};
* // Sets the bounds of the destination.
* destination.destinationBounds = {x: 20, y: 20, width: 100, height: 50};
* // Sets destination to document link annotation.
* annotation.destination = destination;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
page: PdfPage;
/**
* Gets the page index of bookmark destination (Read only).
*
* @returns {number} index.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* //Access the annotation at index 0
* let annot: PdfDocumentLinkAnnotation = document.getPage(0).annotations.at(0) as PdfDocumentLinkAnnotation;
* // Gets the page index of the destination.
* let pageIndex: number = annot.destination.pageIndex;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
readonly pageIndex: number;
/**
* Gets the mode of the destination.
*
* @returns {PdfDestinationMode} page.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* //Access the annotation at index 0
* let annot: PdfDocumentLinkAnnotation = document.getPage(0).annotations.at(0) as PdfDocumentLinkAnnotation;
* // Gets the mode of the destination.
* let mode: PdfDestinationMode = annot.destination.mode;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the mode of the destination.
*
* @param {PdfDestinationMode} value page.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the annotation at index 0
* let annotation: PdfDocumentLinkAnnotation = document.getPage(0).annotations.at(0) as PdfDocumentLinkAnnotation;
* // Initializes a new instance of the `PdfDestination` class.
* let destination: PdfDestination = new PdfDestination();
* // Sets the zoom factor.
* destination.zoom = 20;
* // Sets the page where the destination is situated.
* destination.page = page;
* // Sets the mode of the destination.
* destination.mode = PdfDestinationMode.fitToPage;
* // Sets the location of the destination.
* destination.location = {x: 20, y: 20};
* // Sets the bounds of the destination.
* destination.destinationBounds = {x: 20, y: 20, width: 100, height: 50};
* // Sets destination to document link annotation.
* annotation.destination = destination;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
mode: PdfDestinationMode;
/**
* Gets the location of the destination.
*
* @returns {Point} page.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the annotation at index 0
* let annot: PdfDocumentLinkAnnotation = document.getPage(0).annotations.at(0) as PdfDocumentLinkAnnotation;
* // Gets the location of the destination.
* let location: Point = annot.destination.location;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the location of the destination.
*
* @param {Point} value page.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the annotation at index 0
* let annotation: PdfDocumentLinkAnnotation = document.getPage(0).annotations.at(0) as PdfDocumentLinkAnnotation;
* // Initializes a new instance of the `PdfDestination` class.
* let destination: PdfDestination = new PdfDestination();
* // Sets the zoom factor.
* destination.zoom = 20;
* // Sets the page where the destination is situated.
* destination.page = page;
* // Sets the mode of the destination.
* destination.mode = PdfDestinationMode.fitToPage;
* // Sets the location of the destination.
* destination.location = {x: 20, y: 20};
* // Sets the bounds of the destination.
* destination.destinationBounds = {x: 20, y: 20, width: 100, height: 50};
* // Sets destination to document link annotation.
* annotation.destination = destination;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
location: Point;
/**
* Gets the bounds of the destination.
*
* @returns {Rectangle} bounds.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the annotation at index 0
* let annot: PdfDocumentLinkAnnotation = document.getPage(0).annotations.at(0) as PdfDocumentLinkAnnotation;
* // Gets the bounds of the destination.
* let destinationBounds: Rectangle = annot.destination.destinationBounds;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the bounds of the destination.
*
* @param {Rectangle} value bounds.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the annotation at index 0
* let annotation: PdfDocumentLinkAnnotation = document.getPage(0).annotations.at(0) as PdfDocumentLinkAnnotation;
* // Initializes a new instance of the `PdfDestination` class.
* let destination: PdfDestination = new PdfDestination();
* // Sets the zoom factor.
* destination.zoom = 20;
* // Sets the page where the destination is situated.
* destination.page = page;
* // Sets the mode of the destination.
* destination.mode = PdfDestinationMode.fitToPage;
* // Sets the location of the destination.
* destination.location = {x: 20, y: 20};
* // Sets the bounds of the destination.
* destination.destinationBounds = {x: 20, y: 20, width: 100, height: 50};
* // Sets destination to document link annotation.
* annotation.destination = destination;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
destinationBounds: Rectangle;
/**
* Gets a value indicating whether this instance is valid (Read only).
*
* @returns {boolean} value indicating whether this instance is valid.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the annotation at index 0
* let annot: PdfDocumentLinkAnnotation = document.getPage(0).annotations.at(0) as PdfDocumentLinkAnnotation;
* // Gets a value indicating whether this instance is valid.
* let isValid: boolean = annot.destination.isValid;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
readonly isValid: boolean;
/**
* Sets the internal validation flag for the destination.
*
* @private
* @param {boolean} value True to mark as valid; otherwise false.
* @returns {void} nothing.
*/
_setValidation(value: boolean): void;
/**
* Builds the internal PDF array representation and updates the parent dictionary.
*
* @private
* @returns {void}
*/
_initializePrimitive(): void;
}
/**
* Provides utilities to resolve and parse destination arrays from dictionaries and Names trees.
*
* @private
*/
export declare class _PdfDestinationHelper {
/**
* Source dictionary that contains the destination entry.
*
* @private
*/
_dictionary: _PdfDictionary;
/**
* Key to look up ('Dest' or 'D').
*
* @private
*/
_key: string;
constructor(dictionary: _PdfDictionary, value: string);
/**
* Obtains the `PdfDestination` from the source dictionary or Names tree.
*
* @private
* @returns {PdfDestination} Resolved destination instance, if any.
*/
_obtainDestination(): PdfDestination;
/**
* Looks up a destination array by name from the document.
*
* @private
* @param {_PdfName | string} name Named destination identifier.
* @param {PdfDocument} document Document to search.
* @returns {any[]} The resolved destination array if found.
*/
_getDestination(name: _PdfName | string, document: PdfDocument): any[];
/**
* Resolves a named destination from the Names tree or Dests dictionary.
*
* @private
* @param {PdfDocument} document Source document.
* @param {_PdfName | string} result Name key to resolve.
* @returns {any[]} Destination array or undefined.
*/
_getNamedDestination(document: PdfDocument, result: _PdfName | string): any[];
/**
* Extracts a destination array from a referenced dictionary or array.
*
* @private
* @param {any} ref Reference or array pointing to a destination.
* @param {PdfDocument} document Document to use for dereferencing.
* @returns {any[]} The destination array if available.
*/
_extractDestination(ref: any, document: PdfDocument): any[];
/**
* Traverses the Names tree to find a named object reference.
*
* @private
* @param {_PdfDictionary} kids Current node in the Names tree.
* @param {string} name Name to locate.
* @returns {_PdfReference} Reference to the matching named object.
*/
_getNamedObjectFromTree(kids: _PdfDictionary, name: string): _PdfReference;
/**
* Performs a binary search in a Names array for the given name.
*
* @private
* @param {_PdfDictionary} current Dictionary containing a 'Names' array.
* @param {string} target Name to search for.
* @returns {_PdfReference} Reference associated with the found name.
*/
_findName(current: _PdfDictionary, target: string): _PdfReference;
/**
* Selects the child dictionary whose Limits bracket the specified name.
*
* @private
* @param {_PdfDictionary} kids Parent dictionary with Kids array.
* @param {string} name Name to bracket.
* @returns {_PdfDictionary} The child dictionary likely containing the name.
*/
_getProperKid(kids: _PdfDictionary, name: string): _PdfDictionary;
/**
* Checks whether the given name falls within the Limits of the node.
*
* @private
* @param {_PdfDictionary} kid Node to test.
* @param {string} result Name to compare.
* @returns {boolean} True if within limits; otherwise false.
*/
_checkLimits(kid: _PdfDictionary, result: string): boolean;
/**
* Compares two strings using byte-wise comparison.
*
* @private
* @param {string} limits First string to compare.
* @param {string} result Second string to compare.
* @returns {number} Negative if limits < result, positive if limits > result, zero if equal.
*/
_stringCompare(limits: string, result: string): number;
}