Skip to content

Word

This documents the Word module and how to use it from JavaScript flows.

You can load the module using the following code:

js
var c = Module.load("Word", {version: "X.Y.Z"});

Inspect a document

To parse and inspect a document, use the inspect method:

js
var doc = c.inspect("path/to/document.docx");

The returned doc is a document-object-model of a sorts of the document in question. You can use it to retrieve all paragraphs, tables, lists, etc. in the document.

Each node in the inspect() output has a type property that indicates the type of node. The following types are supported:

  • document: the root node of the document
  • paragraph: a paragraph
  • table: a table
  • list: a list
  • listitem: an item in a list
  • text: a text node

In addition you can invoke the toHtml() method on each node to get a simplified HTML representation of the node.