public class DocxDocument implements AutoClosable
Reads an OpenXML Word document (.docx) using Klyn's native ZIP archiver and XML DOM parser.
Extracts document elements including headings, body paragraphs, bullet lists, and tables, formatting them into clean Markdown text or structured paragraph and table objects. Implements AutoClosable to automatically release staging files upon exit.
import klyn.io.docx
try document = DocxDocument("report.docx"):
print(document.getText())| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | blockCountblockCount as Int |
Returns the total number of structural blocks (paragraphs and tables) in the document. |
| public readonly property | blocks | Returns the list of structural Markdown text blocks extracted from the document. |
| public readonly property | closedclosed as Boolean |
Indicates whether the document has been closed and its staging files cleaned up. |
| public readonly property | paragraphsparagraphs as IList<DocxParagraph> |
Returns the structured paragraphs extracted from the document. |
| public readonly property | tables | Returns the structured tables extracted from the document. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | DocxDocumentDocxDocument(filename as String) |
Opens a Word document (.docx) from a filename string. |
| public | DocxDocumentDocxDocument(path as Path) |
Opens a Word document (.docx) from a Path object. |
| Modifier and Type | Member | Description |
|---|---|---|
| public override | closeclose() as Void |
Closes the document and removes temporary uncompressed OpenXML files. |
| public | getTextgetText(startBlock as Int = 1, maxBlocks as Int = 0) as String throws DocxException, IOException |
Extracts and returns document text formatted in Markdown, optionally bounded to a range of paragraphs or blocks. |