1.0.7 • Published 6 years ago
unoconv-promise-win v1.0.7
Unoconv Promise
This is a Node.js wrapper with native Promise support for converting documents with unoconv, inspired by Graham Floyd's implementation
Setup
Requirement
- Unoconv
- Tested with Unoconv version 0.8.2
- LibreOffice (or OpenOffice.)
Mac Only
With Homebrew
$ brew install unoconvand in order to use unoconv, a copy of LibreOffice between versions 3.6.0.1 - 4.3.x must be installed.
Installation
$ npm install unoconv-promiseUsage
Basic
Convert document file into PDF and return as a Buffer
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
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
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
{
"format": "doc",
"doctype": "document",
"extension": "doc",
"description": " Microsoft Word 97/2000/XP",
"mime": "application/msword"
}Unoconv.run options
Option (default) : Description
From unoconv
Please check unoconv -h more details
connectiondoctypeexportfieldformat(pdf): specify the output formatimport-filter-nameimportlistenerno-launchoutput: output basename, filename or directorypasswordpipeportprinterpreserve: keep timestamp and permissions of the original documentservershowstdouttemplatetimeout: timeout after secs if connection to listener failsverboseversion
Extra
bin(unoconv): Binary commandstring(false): Return the output as stringfile(null): Target file
Testing
npm test- Coverage
npm test:coverageSupported Formats
bibbmp- image/bmpcsv- text/csvdbfdifdoc- application/msworddocx- application/vnd.openxmlformats-officedocument.wordprocessingml.documentemf- application/x-msmetafileeps- application/postscriptfodgfodpfodsfodtgif- image/gifhtml- text/htmljpg- image/jpegltxmetoddodg- 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.presentationpswpwppxlras- image/x-cmu-rasterrtf- application/rtfsda- application/vnd.stardivision.drawsdc- application/vnd.stardivision.calcsdd- application/vnd.stardivision.impresssdw- application/vnd.stardivision.writerslkstc- 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+xmlsvmswf- 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/plainuopuosuotvor- 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'