DsPdfJS API - v9.1.0
    Preparing search index...

    Class PdfPage

    Represents a page in a PdfDocument.

    Hierarchy (View Summary)

    Index

    Accessors

    • get cropBox(): Rect | null

      Gets or sets a rectangle, in points, defining the visible region of default user space. When the 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 @mediaBox.

      Returns Rect | null

    • set cropBox(value: Rect | null): void

      Gets or sets a rectangle, in points, defining the visible region of default user space. When the 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 @mediaBox.

      Parameters

      Returns void

    • get height(): number

      The height of the PdfPage, in points.

      Returns number

    • get id(): number

      Gets the reference to the object.

      Returns number

    • get mediaBox(): Rect

      Gets or sets the bounds of the PdfPage in points.

      Returns Rect

    • set mediaBox(value: Rect): void

      Gets or sets the bounds of the PdfPage in points.

      Parameters

      Returns void

    • get rotation(): number

      Gets or sets the number of degrees by which the PdfPage should be rotated clockwise when displayed or printed. The value is a multiple of 90.

      Returns number

    • set rotation(degrees: number): void

      Gets or sets the number of degrees by which the PdfPage should be rotated clockwise when displayed or printed. The value is a multiple of 90.

      Parameters

      • degrees: number

      Returns void

    • get transitionDuration(): number | null

      Gets or sets the 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.

      Returns number | null

    • set transitionDuration(value: number | null): void

      Gets or sets the 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.

      Parameters

      • value: number | null

      Returns void

    • get width(): number

      The width of the PdfPage, in points.

      Returns number

    Methods

    • Converts specified visual coordinates (usually in the coordinate system with the origin in the top left corner of the PdfPage and the Y axis going down, see 'fromBottomLeft') to coordinates that take into account PdfPage#rotation, PdfPage#cropBox and 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'.

      Parameters

      • value: Point

        The Point to adjust.

      • fromBottomLeft: boolean = false

        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).

      • deviceDpiX: number = 72

        The horizontal device resolution.

      • deviceDpiY: number = 72

        The vertical device resolution.

      Returns Point

    • Converts specified visual coordinates (usually in the coordinate system with the origin in the top left corner of the PdfPage and the Y axis going down, see 'fromBottomLeft') to coordinates that take into account PdfPage#rotation, PdfPage#cropBox and 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'.

      Parameters

      • value: Quadrilateral

        The Quadrilateral to adjust.

      • fromBottomLeft: boolean = false

        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).

      • deviceDpiX: number = 72

        The horizontal device resolution.

      • deviceDpiY: number = 72

        The vertical device resolution.

      Returns Quadrilateral

    • Converts specified visual coordinates (usually in the coordinate system with the origin in the top left corner of the PdfPage and the Y axis going down, see 'fromBottomLeft') to coordinates that take into account PdfPage#rotation, PdfPage#cropBox and 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'.

      Parameters

      • value: Rect

        The Rect to adjust.

      • fromBottomLeft: boolean = false

        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).

      • deviceDpiX: number = 72

        The horizontal device resolution.

      • deviceDpiY: number = 72

        The vertical device resolution.

      Returns Rect

    • Draws the PdfPage on the given context into the specified rectangle.

      Parameters

      • context: DrawingContext

        The target drawing context.

      • x: number

        The X coordinate of the destination rectangle.

      • y: number

        The Y coordinate of the destination rectangle.

      • width: number

        The width of the destination rectangle.

      • height: number

        The height of the destination rectangle.

      • Optionaloptions: DrawPdfPageOptions

        The options for the drawing the PdfPage.

      Returns void

      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();
    • Draws the PdfPage on the given context into the specified rectangle.

      Parameters

      Returns void

    • Detaches the object from the ObjectManager and deallocates its memory, if possible.

      Returns void

    • Gets the size of the PdfPage on a device with specified horizontal and vertical resolutions.

      Parameters

      • deviceDpiX: number = 72

        The horizontal device resolution.

      • deviceDpiY: number = 72

        The vertical device resolution.

      Returns Size

    • Retrieves all text on the PdfPage.

      Returns string

    • Replaces a specified text on the PdfPage.

      Note that the results may be affected by the current value of the PdfDocument#recognitionAlgorithm property.

      Parameters

      • findTextParams: FindTextParams

        The text to search for.

      • newText: string

        The replacement text.

      • Optionalfont: Font | null

        The font to use on 'newText', if null the current font will be used.

      • OptionalfontSize: number | null

        The font size to use on 'newText', if null the current font size will be used.

      Returns void

    • Replaces a specified text on the PdfPage.

      Note that the results may be affected by the current value of the PdfDocument#recognitionAlgorithm property.

      Parameters

      • textMapFragment: TextMapFragment

        The text range.

      • newText: string

        The replacement text.

      • Optionalfont: Font | null

        The font to use on 'newText', if null the current font will be used.

      • OptionalfontSize: number | null

        The font size to use on 'newText', if null the current font size will be used.

      Returns void

    • Saves the PdfPage to a byte array in PNG format.

      Parameters

      Returns Uint8Array

      The resulting binary data in PNG format.

      const doc = PdfDocument.load(data);
      const page = doc.pages.getAt(0);
      const imageBytes = page.saveAsPng({ backColor: "GhostWhite" });
    • Saves the PdfPage to a byte array in SVG format.

      Parameters

      Returns Uint8Array

      The resulting data in UTF-8 encoded SVG format.

    • Saves the PdfPage to a byte array in SVG.GZ format.

      Parameters

      Returns Uint8Array

      The resulting binary data in SVG.GZ format.