Skip to main content
Module

x/docxml/mod.ts>Docx

An experimental Deno tool to transform XML to DOCX with a little XPath- and component based configuration
Go to Latest
class Docx
import { Docx } from "https://deno.land/x/docxml@2.4.2/mod.ts";

Represents the .docx file, which is essentially a ZIP archive with a bunch of XML files and some naming conventions.

An instance of this class can access other classes that represent the various XML files in a DOCX archive, such as ContentTypes.xml, word/document.xml, and _rels/.rels.

Constructors

new
private
Docx(contentTypes?, relationships?)

Properties

private
_officeDocument: OfficeDocument | null
readonly
contentTypes: ContentTypes

The utility function dealing with the XML for recording content types. Every DOCX file has exactly one of these.

readonly
document

A short-cut to the relationship that represents visible document content.

readonly
relationships: Relationships

The utility function dealing with the top-level XML file for recording relationships. Other relationships may have their own relationship XMLs.

Methods

toArchive(): ZipArchive

Create a ZIP archive, which is the handler for .docx files as a ZIP archive.

Static Methods

fromArchive(archive: ZipArchive): Promise<Docx>

Instantiate this class by giving it a .docx file if it is already loaded as a ZipArchive instance.

fromArchive(location: string): Promise<Docx>

Instantiate this class by pointing at a .docx file location.

fromJsx(roots: OfficeDocumentChild[])

Create a new DOCX with contents composed by this library's components. Needs a single JSX component as root, for example <Document>, <Section> or <Paragragh>.

Create an empty DOCX, and populate it with the minimum viable contents to appease MS Word.