Node.js wrapper with Promise for converting documents with unoconv
npm install unoconv-promise 
This is a Node.js wrapper with native Promise support for converting documents with unoconv, inspired by Graham Floyd's implementation
- Unoconv
- Tested with Unoconv version 0.8.2
- LibreOffice (or OpenOffice.)
- Tested with LibreOffice version 3.6.5 - MacOS, Windows
#### Mac Only
With Homebrew
``shell`
$ brew install unoconv
and in order to use unoconv, a copy of LibreOffice between versions 3.6.0.1 - 4.3.x must be installed.
`shell`
$ npm install unoconv-promise
#### Convert document file into PDF and return as a Buffer
`javascript
const unoconv = require("unoconv-promise");
unoconv
.convert("./mydoc.doc")
.then(fileBuffer => {
// Converted file buffer
return Promise.resolve(fileBuffer);
})
.catch(e => {
throw e;
});
`
#### Convert document first page to PDF and save to a file
`javascript
const unoconv = require("unoconv-promise");
unoconv
.run({
file: "./mydoc.doc",
output: "./temp.pdf",
export: "PageRange=1-1"
})
.then(filePath => {
console.log(filePath);
})
.catch(e => {
throw e;
});
`
#### Show supported formats
`javascript
const unoconv = require("unoconv-promise");
unoconv
.formats()
.then(formats => {
// formats will be an array contains supports formats
formats.forEach(format => {
console.log(format);
});
})
.catch(e => {
throw e;
});
`
- Each format will be look like this
`json`
{
"format": "doc",
"doctype": "document",
"extension": "doc",
"description": " Microsoft Word 97/2000/XP",
"mime": "application/msword"
}
#### Option (default) : Description
From unoconv
Please check unoconv -h more details
- connectiondoctype
- export
- field
- fields
- : object contanig user-defined text fields with values to be relaced in the documentformat
- (pdf): specify the output formatimport-filter-name
- import
- listener
- no-launch
- output
- : output basename, filename or directorypassword
- pipe
- port
- printer
- preserve
- : keep timestamp and permissions of the original documentserver
- show
- stdout
- template
- timeout
- : timeout after secs if connection to listener failsverbose
- version
-
Extra
- bin (unoconv): Binary commandunoconv
- (unoconv): Unoconv custom pathpython
- (python): Python custom ptahstring
- (false): Return the output as stringfile
- (null): Target file
`javascript`
npm test
- Coverage
`javascript`
npm test:coverage
- bibbmp
- - image/bmpcsv
- - text/csvdbf
- dif
- doc
- - application/msworddocx
- - application/vnd.openxmlformats-officedocument.wordprocessingml.documentemf
- - application/x-msmetafileeps
- - application/postscriptfodg
- fodp
- fods
- fodt
- gif
- - image/gifhtml
- - text/htmljpg
- - image/jpegltx
- met
- odd
- odg
- - application/vnd.oasis.opendocument.graphicsodp
- - application/vnd.oasis.opendocument.presentationods
- - application/vnd.oasis.opendocument.spreadsheetodt
- - application/vnd.oasis.opendocument.textotg
- - application/vnd.oasis.opendocument.graphics-templateotp
- - application/vnd.oasis.opendocument.presentation-templateots
- - application/vnd.oasis.opendocument.spreadsheet-templateott
- - application/vnd.oasis.opendocument.text-templatepbm
- - image/x-portable-bitmappct
- - image/x-pictpdb
- - application/vnd.palmpdf
- - application/pdfpgm
- - image/x-portable-graymappng
- - image/pngpot
- - application/vnd.ms-powerpointpotm
- - application/vnd.ms-powerpoint.template.macroenabled.12ppm
- - image/x-portable-pixmappps
- - application/vnd.ms-powerpointppt
- - application/vnd.ms-powerpointpptx
- - application/vnd.openxmlformats-officedocument.presentationml.presentationpsw
- pwp
- pxl
- ras
- - image/x-cmu-rasterrtf
- - application/rtfsda
- - application/vnd.stardivision.drawsdc
- - application/vnd.stardivision.calcsdd
- - application/vnd.stardivision.impresssdw
- - application/vnd.stardivision.writerslk
- stc
- - application/vnd.sun.xml.calc.templatestd
- - application/vnd.sun.xml.draw.templatesti
- - application/vnd.sun.xml.impress.templatestw
- - application/vnd.sun.xml.writer.templatesvg
- - image/svg+xmlsvm
- swf
- - application/x-shockwave-flashsxc
- - application/vnd.sun.xml.calcsxd
- - application/vnd.sun.xml.drawsxi
- - application/vnd.sun.xml.impresssxw
- - application/vnd.sun.xml.writertiff
- - image/tifftxt
- - text/plainuop
- uos
- uot
- vor
- - application/vnd.stardivision.writerwmf
- - application/x-msmetafilewps
- - application/vnd.ms-worksxhtml
- - application/xhtml+xmlxls
- - application/vnd.ms-excelxlsx
- - application/vnd.openxmlformats-officedocument.spreadsheetml.sheetxlt
- - application/vnd.ms-excelxml
- - application/xmlxpm` - image/x-xpixmap'
-
- npm package
- unoconv
- node-unoconv
- filepreview.js
- unoconv man page