ComPDFKit Web SDK
    Preparing search index...

    Class ContentBox

    A text box shown while editing page content. Image boxes are ContentImageBox.

    Hierarchy (View Summary)

    Index
    • get id(): string

      Box id, unique within the document while content editing is active.

      Returns string

    • data is replaced with the Worker's latest data by ContentEditManager after every operation.

      Parameters

      • data: ContentBoxData

        Latest box data from the Worker, refreshed after every operation.

      • pageNumber: number

        Page number (1-based) of the box.

      • Optionalmanager: ContentEditManager
      • OptionaldocViewer: DocumentViewer

      Returns ContentBox

    • Moves the box one step backward in the stacking order.

      Returns Promise<void>

    • Moves the box one step forward in the stacking order.

      Returns Promise<void>

    • Moves the box to the back of the stacking order.

      Returns Promise<void>

    • Stacking order (names follow AnnotationManager.bringToFront / bringToBack): bring to front, forward one, send to back, backward one. Each move of an image box is one history entry. Note: stacking moves of text boxes cannot be undone (the engine records undo only for bring-to-front and only when it actually moves, not the other three, so the step counts would not match; text boxes are never recorded).

      Returns Promise<void>

    • Clear characters independently of block multi-selection; active editor collapses at its caret.

      Returns Promise<void>

    • Rectangle (page coordinates) and type.

      Returns ContentBoxAttributes

    • Returns a snapshot of the box.

      Returns Promise<ContentBoxInfo>

      Id, page number, type and rectangle (page coordinates); text boxes also include their full text.

    • Synchronous selection read from the authoritative Worker text model, never the reading selection.

      Returns string

    • Current character range in this text block, including an inactive block. Detached snapshot.

      Returns { endIndex: number; startIndex: number } | null

      • { endIndex: number; startIndex: number }
        • endIndex: number

          Index after the last selected character.

        • startIndex: number

          Index of the first selected character.

      • null
    • Geometry for the character selection captured at call time, including an inactive block. Detached native layout snapshot; null when no character range is retained. This read does not open an editor, alter selection, or apply tool safe distances.

      Returns Promise<ContentTextSelectionGeometry | null>

    • Checks whether an editor is open on the box.

      Returns boolean

      true while the box is being edited.

    • Set a rectangle in unrotated page coordinates (pt), with one content undo entry. visible (default): move/resize the visible bounds, retaining image crop proportions. frame: set the complete image/text frame, as the native SetFrame primitive does. clip: for a cropped image use SetClipRect; otherwise use SetFrame. This preserves the distinction between an image's frame and clip placement without exposing handles. Programmatic coordinates are not clamped to tool safe distances.

      Parameters

      • rect: Core.Annotations.Rect
      • Optionaloptions: { mode?: "visible" | "frame" | "clip" }
        • Optionalmode?: "visible" | "frame" | "clip"

          How the rectangle is applied: 'visible' (default), 'frame' or 'clip' (image boxes only).

      Returns Promise<void>

    • Select characters without opening a keyboard editor or changing the selected boxes.

      Parameters

      • start: number
      • Optionalend: number

      Returns Promise<void>

    • Commits the changes in the editor and closes it; fires contentBoxEditEnded.

      Parameters

      • Optionaloptions: { preserveSelection?: boolean }
        • OptionalpreserveSelection?: boolean

          Keeps the box's text selection after editing stops. Defaults to false.

      Returns Promise<void>

    data: ContentBoxData

    Latest box data from the Worker, refreshed after every operation.

    pageNumber: number

    Page number (1-based) of the box.

    type: Types

    Box kind; Types.TEXT for text boxes.