@qrcommunication/gigapdf-lib — SDK API reference - v0.121.0
    Preparing search index...

    Interface TextElementInfo

    A text element from GigaPdfDoc.textElements: the decoded text plus everything a host editor needs to recreate the run. index is the text-run index accepted by GigaPdfDoc.replaceText; the bounding box is page user space (origin bottom-left).

    interface TextElementInfo {
        index: number;
        text: string;
        x: number;
        y: number;
        width: number;
        height: number;
        fontFamily: string;
        baseFont: string;
        fontId?: string;
        bold: boolean;
        italic: boolean;
        fontSize: number;
        color: [number, number, number];
        rotation: number;
        direction: "ltr" | "rtl" | "neutral";
        segments: TextSegment[];
    }
    Index

    Properties

    index: number
    text: string
    x: number
    y: number
    width: number
    height: number
    fontFamily: string

    Resolved /BaseFont family (e.g. "Helvetica", "Times New Roman").

    baseFont: string

    The raw /BaseFont name with the subset prefix kept (e.g. "ABCDEF+TimesNewRomanPSMT"), resolved against the run's own scope — the page, or the form XObject the run is drawn inside. Lets a host target the exact embedded subset rather than only the collapsed fontFamily. Empty when the run's font carried no /BaseFont (e.g. a Type3 font).

    fontId?: string

    The physical identity of the run's embedded font program — the first 8 hex chars of the SHA-256 of its decoded /FontFile* bytes, matching EmbeddedFontV2.fontId. Unlike baseFont (a name, ambiguous when many wrapper dicts share one program), this pins the exact program: feed it to GigaPdfDoc.extractWebFontById (with this run's baseFont as preferWrapper) to always get the run's own glyphs. Empty when the run's font embeds no program (base-14 / non-embedded faces, Type3).

    bold: boolean
    italic: boolean
    fontSize: number

    Effective glyph size in points.

    color: [number, number, number]

    RGB fill colour, 0..1 per channel.

    rotation: number

    Baseline rotation in degrees (0 = upright).

    direction: "ltr" | "rtl" | "neutral"

    Reading direction of this run by its strong characters: "rtl" for Arabic/Hebrew, "ltr" for Latin/Greek/Cyrillic/CJK, "neutral" when the run is only digits/punctuation/whitespace.

    segments: TextSegment[]

    The run's visually contiguous fragments when it contains internal TJ position jumps — justified / per-glyph-positioned text (a legal footer, a spread-out table cell) that a single overlay box cannot reproduce. Each fragment carries its own text and page-space box, computed from the SAME pen walk the rasterizer uses (glyph widths + Tc/Tw/Tz + kerns), so a host paints one positioned box per fragment — 1:1 with the render — while still editing the whole run via index. Empty for a plain run (its own x/y/width already position it).