Represents a page in a PDF document with various properties and methods.

interface PdfPage {
    AddPage: (() => PdfPage);
    AppendPdfFile: ((file: FileInstance) => boolean);
    ArtBox: Rectangle;
    BleedBox: Rectangle;
    Clear: (() => void);
    CropBox: Rectangle;
    DeletePage: ((index: number) => boolean);
    DeletePages: ((index: number, count: number) => boolean);
    Draw: ((page: PdfPage, x: number, y: number, width: number, height: number, angle: number, layerObject?: PdfLayer) => void);
    DrawDynamicTemplate: ((templateXml: string) => boolean);
    ExtractPages: ((target: FileInstance, pages: number[]) => boolean);
    ExtractText: ((asFormatted: boolean) => string);
    GetImageAt: ((index: number) => PdfImage);
    GetImageCount: (() => number);
    GetPage: ((index: number) => PdfPage);
    Height: number;
    InsertPage: ((index: number) => PdfPage);
    MediaBox: Rectangle;
    MovePage: ((srcIndex: number, destIndex: number) => boolean);
    OptimizePage: ((maxImageDimension: number, jpegQuality: number, optimizeImagesWithMasksByRecompressing: boolean) => void);
    PageCount: number;
    Rotation: number;
    SaveAsImage: ((target: FileInstance, width: number, type: string, bgColor?: string) => boolean);
    SaveAsPdf: ((target: FileInstance) => boolean);
    SwapPages: ((firstIndex: number, secondIndex: number) => boolean);
    TrimBox: Rectangle;
    Width: number;
}

Properties

AddPage: (() => PdfPage)

Adds a new page to the end of the PDF document. Returns a PdfPage object representing the new page.

AppendPdfFile: ((file: FileInstance) => boolean)

Appends another PDF file to the current document.

Type declaration

    • (file): boolean
    • Parameters

      • file: FileInstance

        The file instance of the PDF to append. Returns true if append was successful, false otherwise.

      Returns boolean

ArtBox: Rectangle

Gets or sets the art box of the page.

BleedBox: Rectangle

Gets or sets the bleed box of the page.

Clear: (() => void)

Clears the content of the PDF document.

CropBox: Rectangle

Gets or sets the crop box of the page.

DeletePage: ((index: number) => boolean)

Deletes the page at the specified index.

Type declaration

    • (index): boolean
    • Parameters

      • index: number

        The index of the page to delete. Returns true if the page was deleted successfully, false otherwise.

      Returns boolean

DeletePages: ((index: number, count: number) => boolean)

Deletes a range of pages starting from the specified index.

Type declaration

    • (index, count): boolean
    • Parameters

      • index: number

        The starting index of the pages to delete.

      • count: number

        The number of pages to delete. Returns true if the pages were deleted successfully, false otherwise.

      Returns boolean

Draw: ((page: PdfPage, x: number, y: number, width: number, height: number, angle: number, layerObject?: PdfLayer) => void)

Draws another PDF page onto this page.

Type declaration

    • (page, x, y, width, height, angle, layerObject?): void
    • Parameters

      • page: PdfPage

        The PdfPage object representing the page to draw.

      • x: number

        The x-coordinate for the drawing position.

      • y: number

        The y-coordinate for the drawing position.

      • width: number

        The width for the drawing.

      • height: number

        The height for the drawing.

      • angle: number

        The rotation angle for the drawing.

      • OptionallayerObject: PdfLayer

        The layer on which to draw the page (optional).

      Returns void

DrawDynamicTemplate: ((templateXml: string) => boolean)

Draws a dynamic template on the page.

Type declaration

    • (templateXml): boolean
    • Parameters

      • templateXml: string

        The XML string representing the dynamic template. Returns true if the drawing was successful, false otherwise.

      Returns boolean

ExtractPages: ((target: FileInstance, pages: number[]) => boolean)

Extracts specified pages from the PDF document and saves them to a new file.

Type declaration

    • (target, pages): boolean
    • Parameters

      • target: FileInstance

        The file instance to save the extracted pages.

      • pages: number[]

        An array or list specifying the indices of pages to extract. Returns true if extraction and save were successful, false otherwise.

      Returns boolean

ExtractText: ((asFormatted: boolean) => string)

Extracts the text content from the page.

Type declaration

    • (asFormatted): string
    • Parameters

      • asFormatted: boolean

        Whether to extract the text with formatting. Returns the extracted text.

      Returns string

GetImageAt: ((index: number) => PdfImage)

Retrieves the image object at the specified index.

Type declaration

    • (index): PdfImage
    • Parameters

      • index: number

        The index of the image to retrieve. Returns the PdfImageObject at the specified index, or null if index is out of range.

      Returns PdfImage

GetImageCount: (() => number)

Gets the number of images on the page.

GetPage: ((index: number) => PdfPage)

Gets the page at the specified index.

Type declaration

    • (index): PdfPage
    • Parameters

      • index: number

        The index of the page to retrieve. Returns a PdfPage object representing the page.

      Returns PdfPage

Height: number

Gets or sets the height of the page.

InsertPage: ((index: number) => PdfPage)

Inserts a new page at the specified index.

Type declaration

    • (index): PdfPage
    • Parameters

      • index: number

        The index at which to insert the new page. Returns a PdfPage object representing the new page.

      Returns PdfPage

MediaBox: Rectangle

Gets or sets the media box of the page.

MovePage: ((srcIndex: number, destIndex: number) => boolean)

Moves a page from one index to another.

Type declaration

    • (srcIndex, destIndex): boolean
    • Parameters

      • srcIndex: number

        The index of the page to move.

      • destIndex: number

        The index to move the page to. Returns true if the page was moved successfully, false otherwise.

      Returns boolean

OptimizePage: ((maxImageDimension: number, jpegQuality: number, optimizeImagesWithMasksByRecompressing: boolean) => void)

Optimizes the page by reducing the size of images.

Type declaration

    • (maxImageDimension, jpegQuality, optimizeImagesWithMasksByRecompressing): void
    • Parameters

      • maxImageDimension: number

        The maximum dimension for images.

      • jpegQuality: number

        The quality of JPEG images.

      • optimizeImagesWithMasksByRecompressing: boolean

        Whether to optimize images with masks by recompressing them.

      Returns void

PageCount: number

The number of pages in the PDF document.

Rotation: number

Gets or sets the rotation of the page. The rotation is specified in degrees (0, 90, 180, 270).

SaveAsImage: ((target: FileInstance, width: number, type: string, bgColor?: string) => boolean)

Saves the page as an image file.

Type declaration

    • (target, width, type, bgColor?): boolean
    • Parameters

      • target: FileInstance

        The file instance to save the page as an image.

      • width: number

        The width of the image.

      • type: string

        The type of the image (e.g., "Jpeg", "Png", "Tiff").

      • OptionalbgColor: string

        The background color for the image. Returns true if the save was successful, false otherwise.

      Returns boolean

SaveAsPdf: ((target: FileInstance) => boolean)

Saves the page as a PDF file.

Type declaration

    • (target): boolean
    • Parameters

      • target: FileInstance

        The file instance to save the page as a PDF. Returns true if the save was successful, false otherwise.

      Returns boolean

SwapPages: ((firstIndex: number, secondIndex: number) => boolean)

Swaps the positions of two pages.

Type declaration

    • (firstIndex, secondIndex): boolean
    • Parameters

      • firstIndex: number

        The index of the first page.

      • secondIndex: number

        The index of the second page. Returns true if the pages were swapped successfully, false otherwise.

      Returns boolean

TrimBox: Rectangle

Gets or sets the trim box of the page.

Width: number

Gets or sets the width of the page.