0.1.2 • Published 5 years ago

docx-list-style v0.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

docx-list-style

Lists the styles in a Word (.docx) file.

Installation

$ yarn add docx-list-style

Or, if using npm:

$ npm install --save docx-list-style

Usage

With Buffer-s:

const listDocxStyles = require('docx-list-style');
const getStream = require('get-stream');

const MY_WORD_FILE = '<... path to Word file ...>';

listDocxStyles
  .fromBuffer(getStream.buffer(fs.createReadStream(MY_WORD_FILE), { encoding: 'binary' })) // NOTE: make sure to open file in binary mode.
  .then(console.log)
  .catch(console.error);

With Stream-s:

const listDocxStyles = require('docx-list-style');

const MY_WORD_FILE = '<... path to Word file ...>';

listDocxStyles
  .fromStream(fs.createReadStream(MY_WORD_FILE))
  .then(console.log)
  .catch(console.error);

With a file path:

const listDocxStyles = require('docx-list-style');

const MY_WORD_FILE = '<... path to Word file ...>';

listDocxStyles
  .fromFilePath(MY_WORD_FILE)
  .then(console.log)
  .catch(console.error);

Command-line

npx docx-list-style <... path to Word file ...>
# outputs:
# Heading1
# Heading2
# Heading3
# ...

API

TODO