@squareys/webdecks-sdk - v0.0.0
    Preparing search index...

    Class Document

    A document. Reads are property getters straight off the engine model; navigation returns cached wrappers (=== identity); editing and authoring mutators chain and repaint any attached viewport. The PNG path is thumbnail-only — the live view presents through the WebGPU swapchain, never a pixel readback.

    Hierarchy (View Summary)

    Index
    • get isValid(): boolean

      Whether this wrapper still refers to a live engine object.

      Returns boolean

    • set _index(value: number): void

      Parameters

      • value: number

      Returns void

    • get paragraphCount(): number

      Body paragraph count.

      Returns number

    • get wordCount(): number

      Word count across the document body.

      Returns number

    • get characterCount(): number

      Character count across the document body.

      Returns number

    • get pageCount(): number

      Laid-out page count (0 until a layout exists — the live GPU path produces one).

      Returns number

    • Reference equality is the identity test — prefer a === b. This is retained only for the rare cross-realm case where two wrappers describe the same handle by value. Reads the raw index so comparing a stale wrapper never throws.

      Parameters

      • other: Handle<unknown> | null

      Returns boolean

    • A readable identity for logs and diagnostics, never [object Object].

      Returns string

    • The index-th body paragraph, or null if out of range.

      Parameters

      • index: number

      Returns Paragraph | null

    • Collect the body paragraphs into out (or a fresh array).

      Parameters

      Returns Paragraph[]

    • Insert text at the caret, replacing any selection.

      Parameters

      • text: string

      Returns this

    • Toggle one or more character-format bits over the selection (see TextFormat).

      Parameters

      • format: number

      Returns this

    • Apply a paragraph style to every paragraph the selection touches.

      Parameters

      • style: number

      Returns this

    • Set the alignment of the paragraph at index directly (see Alignment).

      Parameters

      • index: number
      • alignment: number

      Returns this

    • Start a headless find/replace session over the document body. Navigation moves the selection onto each match. flags bits: 1 = match case, 2 = whole word.

      Parameters

      • query: string
      • flags: number = 0

      Returns FindSession

    • Undo one step; returns whether anything changed.

      Returns boolean

    • Redo one step; returns whether anything changed.

      Returns boolean

    • Reset the document to a single empty paragraph.

      Returns this

    • Finalize a batch of authoring operations (mirrors the importer's tail step).

      Returns this

    • Set the page size and margins.

      Parameters

      Returns this

    • Set a document metadata field (title, author, …) by its engine field ordinal.

      Parameters

      • field: number
      • value: string

      Returns this

    • Append a new body paragraph with the given alignment and style; returns its wrapper.

      Parameters

      • alignment: number
      • style: number

      Returns Paragraph

    • Append a formatted run to the last body paragraph; returns the appended byte length.

      Parameters

      Returns number

    • Resolve a font-family name to its registry id (needs the GPU renderer).

      Parameters

      • name: string

      Returns number

    • Create a rows×columns table; returns its wrapper.

      Parameters

      • rows: number
      • columns: number

      Returns Table

    • Add an image from its original encoded bytes (PNG/JPEG); returns the engine image id.

      Parameters

      Returns number

    • The inline-image controls for the image carried by paragraph.

      Parameters

      • paragraph: number

      Returns InlineImage | null

    • Add a comment anchored to [start, end) of paragraph; returns its wrapper.

      Parameters

      • paragraph: number
      • start: number
      • end: number
      • body: string
      • author: string = ""

      Returns Comment

    • Add a header paragraph with the given alignment; returns its header-paragraph index.

      Parameters

      • alignment: number

      Returns number

    • Add a footer paragraph with the given alignment; returns its footer-paragraph index.

      Parameters

      • alignment: number

      Returns number

    • Append a run to the last header paragraph (a non-zero field emits a field code).

      Parameters

      • text: string
      • properties: RunProperties & { field?: number } = {}

      Returns this

    • Append a run to the last footer paragraph (a non-zero field emits a field code).

      Parameters

      • text: string
      • properties: RunProperties & { field?: number } = {}

      Returns this

    • Skip the header/footer on the first page.

      Parameters

      • on: boolean

      Returns this

    • Enable distinct even/odd-page headers and footers.

      Returns this

    • Load already-inflated .docx parts into the model (word/document.xml, styles.xml, …). Use this when the host inflated the package itself; DocumentEngine.import does the inflation for you.

      Parameters

      Returns this

    • Replace this document's content with an inflated .docx read from encoded bytes.

      Parameters

      Returns Promise<Document>

    • Export the document. docx and odt work anywhere; pdf needs the GPU renderer.

      Parameters

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Render one page offscreen and return it as a PNG Blob. This uses the export/ capture path (the browser encodes the PNG) and never the live view. Needs the GPU renderer; returns an empty blob if nothing was rendered.

      Parameters

      • page: number
      • width: number
      • height: number
      • scale: number = 1

      Returns Promise<Blob>

    • Close the document handle and release its wrappers.

      Returns void