ComPDFKit Web SDK
    Preparing search index...

    Class Rect

    A rectangle given by two corners (x1, y1) and (x2, y2). In page coordinates (top-left origin, y down) x1/y1 is the top-left corner once normalized.

    Index
    • Also accepts a Rect, [x1, y1, x2, y2] or { x1, y1, x2, y2 }.

      Parameters

      • Optionalx1: number | number[] | RectLike
      • Optionaly1: number
      • Optionalx2: number
      • Optionaly2: number

      Returns Core.Annotations.Rect

    • Checks whether another rectangle lies entirely inside this one.

      Parameters

      Returns boolean

      true when r is inside.

    • Creates a rectangle from a corner and a size.

      Parameters

      • x: number

        Left edge.

      • y: number

        Top edge.

      • width: number

        Width.

      • height: number

        Height.

      Returns Core.Annotations.Rect

      A new rectangle (x, y, x + width, y + height).

    • For PDF export: x1 ≤ x2 and y1 ≥ y2 (PDF y points up).

      Returns void

    • Returns the bottom edge (y2).

      Returns number

      y2.

    • Returns the height; signed, may be negative before normalize.

      Returns number

      y2 - y1.

    • Returns the left edge (x1).

      Returns number

      x1.

    • Returns the right edge (x2).

      Returns number

      x2.

    • Returns the top edge (y1).

      Returns number

      y1.

    • Signed; may be negative before normalize.

      Returns number

    • Returns x1.

      Returns number

      The x of the first corner.

    • Returns y1.

      Returns number

      The y of the first corner.

    • Checks whether this rectangle intersects another; touching edges count.

      Parameters

      Returns boolean

      true when they intersect.

    • Swaps corners in place so that x1 ≤ x2 and y1 ≤ y2.

      Returns void

    • Transforms the two opposite corners and returns their bounding box.

      Parameters

      Returns void

    • Moves the rectangle in place.

      Parameters

      • dx: number

        Horizontal offset.

      • dy: number

        Vertical offset.

      Returns void

    x1: number

    x of the first corner (left edge when normalized).

    x2: number

    x of the second corner (right edge when normalized).

    y1: number

    y of the first corner (top edge when normalized).

    y2: number

    y of the second corner (bottom edge when normalized).