klyn.io.docx.DocxDocument.getText
method
public getText(startBlock as Int = 1, maxBlocks as Int = 0) as String throws DocxException, IOException
Description

Extracts and returns document text formatted in Markdown, optionally bounded to a range of paragraphs or blocks.

Headings are formatted with #, ##, ###, bullet lists with - , tables as Markdown tables, and body paragraphs separated by double newlines.

Parameters
ParameterDescription
startBlock1-based index of the first paragraph/block to include (default: 1).
maxBlocksMaximum number of paragraphs/blocks to include (0 for all remaining blocks).
Returns

Formatted document content in Markdown.

Throws
  • DocxException If the Word XML structure cannot be parsed.
  • IOException If reading unpacked files fails.
Example
try doc = DocxDocument("notes.docx"):
    content = doc.getText(1, 50)