From 26f7cefe6379e9b76f5bb1963433a6832a55caa6 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 30 Mar 2013 22:01:09 +0000 Subject: Allow path to be passed into convertToHtml --- lib/index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/index.js') diff --git a/lib/index.js b/lib/index.js index a4d51a6..5db51a8 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,4 +1,6 @@ var q = require("q"); +var _ = require("underscore"); +var ZipFile = require("zipfile").ZipFile; var xmlreader = require("./xmlreader"); var documents = require("./documents"); @@ -19,6 +21,18 @@ function Converter(options) { } Converter.prototype.convertToHtml = function(docxFile) { + if (_.isString(docxFile)) { + var zipFile = new ZipFile(docxFile); + docxFile = { + read: function(path) { + return q.ninvoke(zipFile, "readFile", path, "utf-8") + .then(function(value) { + return value.toString(); + }); + } + }; + } + var documentConverter = this._documentConverter; return docxFile.read("word/document.xml").then(function(documentXmlString) { return parseXml(documentXmlString); -- cgit v1.2.3