docx
    Preparing search index...

    Class Textbox

    Represents a textbox in a WordprocessingML document.

    A Textbox creates a floating text container using VML shapes that can be positioned anywhere on the page. Unlike regular paragraphs, textboxes support absolute positioning, custom dimensions, and text wrapping control.

    The textbox is implemented as a paragraph containing a picture element (w:pict) with a VML shape (v:shape) that contains a VML textbox (v:textbox) with the actual content.

    The Textbox combines multiple OOXML elements:

    • w:p (paragraph container)
    • w:pict (picture element containing VML)
    • v:shape (VML shape with styling)
    • v:textbox (VML textbox content container)
    • w:txbxContent (WordprocessingML textbox content)
    // Simple textbox with text
    new Textbox({
    children: [new TextRun("Hello World")],
    style: {
    width: "3in",
    height: "1in"
    }
    });

    // Positioned textbox with wrapping
    new Textbox({
    children: [
    new TextRun({ text: "Floating Text", bold: true }),
    new TextRun({ text: " in a textbox", break: 1 })
    ],
    style: {
    width: "2.5in",
    height: "1.5in",
    position: "absolute",
    left: "1in",
    top: "2in",
    wrapStyle: "square"
    }
    });

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    fileChild: symbol = ...

    Marker property identifying this as a FileChild

    Methods

    • Prepares this component and its children for XML serialization.

      This method is called by the Formatter to convert the component tree into an object structure compatible with the xml library (https://www.npmjs.com/package/xml). It recursively processes all children and handles special cases like attribute-only elements and empty elements.

      The method can be overridden by subclasses to customize XML representation or execute side effects during serialization (e.g., creating relationships).

      Parameters

      • context: IContext

        The serialization context containing document state

      Returns IXmlableObject | undefined

      The XML-serializable object, or undefined to exclude from output

      // Override to add custom serialization logic
      prepForXml(context: IContext): IXmlableObject | undefined {
      // Custom logic here
      return super.prepForXml(context);
      }