node-docto

0.3.2 • Public • Published

Node-DocTo

Support

This package's development is sponsored by Task Force IT-Consulting GmbH.

Task Force IT-Consulting Logo

About

This library is a wrapper around the DocTo-Tool.

From DocTo's README:

Simple utility for converting a Microsoft Word Document '.doc' and Microsoft Excel '.xls' files to any other supported format such as .txt .csv .rtf .pdf.

Motivation

The main motivation was to convert .doc(x) files to PDF. While there are many tools out there that can do this, they often break the layout or design of the document, because they're using a different PDF renderer than Microsoft Word. DocTo uses the installed Microsoft Word and its PDF-renderer to create its output. As such, they end up looking exactly as you expect them to.

There are two obvious drawbacks.

  1. You must have Microsoft Word/Excel installed on the system
  2. Due to point 1, this tool isn't cross-platform

Usage

Example:

const { wordToPdf } = require('node-docto');
 
wordToPdf('./input.docx', './output.pdf', {deleteOriginal: true})
  .then(stdout => console.log(stdout));

API Reference

wordToPdf(source, output[, options])

parameters:
  source: path to source .doc or .docx file
  output: path and filename of the output .pdf file
  options: object with options

returns:
  Promise:
    reject: ({err, stderr})
    resolve: (stdout)
wordToText(source, output[, options])

parameters:
  source: path to source .doc or .docx file
  output: path and filename of the output .pdf file
  options: object with options

returns:
  Promise:
    reject: ({err, stderr})
    resolve: (stdout)
xlsToCsv(source, output[, options])

parameters:
  source: path to source .doc or .docx file
  output: path and filename of the output .pdf file
  options: object with options

returns:
  Promise:
    reject: ({err, stderr})
    resolve: (stdout)

The options object:

const options = {
  // converts a certain file type in a directory and its subdirectory
  // not yet implemented
  recursive: false,  
 
  // deletes original file
  deleteOriginal: false,
  }
}

Package Sidebar

Install

npm i node-docto

Weekly Downloads

2

Version

0.3.2

License

MIT

Unpacked Size

1.83 MB

Total Files

10

Last publish

Collaborators

  • real_kerim