libreoffice-convert
Advanced tools
Comparing version 1.3.4 to 1.3.5
{ | ||
"name": "libreoffice-convert", | ||
"version": "1.3.4", | ||
"version": "1.3.5", | ||
"description": "A simple and fast node.js module for converting office documents to different formats", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,33 +0,38 @@ | ||
# libreoffice-convert # | ||
# libreoffice-convert | ||
A simple and fast node.js module for converting office documents to different formats. | ||
## Dependency ## | ||
## Dependency | ||
Please install libreoffice in /Applications (Mac), with your favorite package manager (Linux), or with the msi (Windows). | ||
## Usage example | ||
## Usage example ## | ||
```javascript | ||
const libre = require('libreoffice-convert'); | ||
'use strict'; | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const fs = require('fs').promises; | ||
const extend = '.pdf' | ||
const enterPath = path.join(__dirname, '/resources/example.docx'); | ||
const outputPath = path.join(__dirname, `/resources/example${extend}`); | ||
const libre = require('libreoffice-convert'); | ||
libre.convertAsync = require('util').promisify(libre.convert); | ||
// Read file | ||
const file = fs.readFileSync(enterPath); | ||
// Convert it to pdf format with undefined filter (see Libreoffice doc about filter) | ||
libre.convert(file, extend, undefined, (err, done) => { | ||
if (err) { | ||
console.log(`Error converting file: ${err}`); | ||
} | ||
async function main() { | ||
const ext = '.pdf' | ||
const inputPath = path.join(__dirname, '/resources/example.docx'); | ||
const outputPath = path.join(__dirname, `/resources/example${ext}`); | ||
// Read file | ||
const docxBuf = await fs.readFile(inputPath); | ||
// Convert it to pdf format with undefined filter (see Libreoffice docs about filter) | ||
let pdfBuf = await libre.convertAsync(docxBuf, ext, undefined); | ||
// Here in done you have pdf file which you can save or transfer in another stream | ||
fs.writeFileSync(outputPath, done); | ||
await fs.writeFile(outputPath, pdfBuf); | ||
} | ||
main().catch(function (err) { | ||
console.log(`Error converting file: ${err}`); | ||
}); | ||
``` | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18759
39