Skip to content

Instantly share code, notes, and snippets.

@webschik
Last active July 31, 2018 11:22
Show Gist options
  • Select an option

  • Save webschik/ff65ca94d9d6eaa1bcf05d748d9eeaf8 to your computer and use it in GitHub Desktop.

Select an option

Save webschik/ff65ca94d9d6eaa1bcf05d748d9eeaf8 to your computer and use it in GitHub Desktop.
Reading of the .docx file with file2html
/**
* Node.js v10.3.0+
*
* 1. npm i file2html-ooxml
* 2. Place test-file.docx file in the same folder with this script
*/
const fs = require('fs');
const file2html = require('file2html');
const OOXMLReader = require('file2html-ooxml').default;
file2html.config({
readers: [
OOXMLReader
]
});
const fileBuffer = fs.readFileSync('./test-file.docx');
const meta = {
mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
};
file2html.read({
fileBuffer,
meta
}).then((file) => {
console.log('result:', file);
}).catch(console.error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment