New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

libreoffice-convert

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libreoffice-convert - npm Package Compare versions

Comparing version 1.0.5 to 1.1.0

16

index.js
'use strict';
const fs = require('fs');
const temp = require('temp').track();
const path = require('path');
const async = require('async');
const tmp = require('tmp');
const { exec } = require('child_process');
exports.convert = (document, format, filter, callback) => {
const tempDir = tmp.dirSync({prefix: 'libreofficeConvert_', unsafeCleanup: true});
const installDir = tmp.dirSync({prefix: 'soffice', unsafeCleanup: true});
return async.auto({

@@ -40,10 +42,9 @@ soffice: (callback) => {

},
tempDir: callback => temp.mkdir('libreofficeConvert', callback),
saveSource: ['tempDir', (results, callback) => fs.writeFile(path.join(results.tempDir, 'source'), document, callback)],
saveSource: callback => fs.writeFile(path.join(tempDir.name, 'source'), document, callback),
convert: ['soffice', 'saveSource', (results, callback) => {
let command = `${results.soffice} --headless --convert-to ${format}`;
let command = `${results.soffice} -env:UserInstallation=file://${installDir.name} --headless --convert-to ${format}`;
if (filter !== undefined) {
command += `:"${filter}"`;
}
command += ` --outdir ${results.tempDir} ${path.join(results.tempDir, 'source')}`;
command += ` --outdir ${tempDir.name} ${path.join(tempDir.name, 'source')}`;

@@ -56,6 +57,7 @@ return exec(command, callback);

interval: 200
}, (callback) => fs.readFile(path.join(results.tempDir, `source.${format}`), callback), callback)
}, (callback) => fs.readFile(path.join(tempDir.name, `source.${format}`), callback), callback)
]
}, (err, res) => {
temp.cleanup();
tempDir.removeCallback();
installDir.removeCallback();

@@ -62,0 +64,0 @@ if (err) {

{
"name": "libreoffice-convert",
"version": "1.0.5",
"version": "1.1.0",
"description": "A simple and fast node.js module for converting office documents to different formats",

@@ -25,3 +25,3 @@ "main": "index.js",

"async": "^2.6.2",
"temp": "^0.9.0"
"tmp": "^0.2.1"
},

@@ -28,0 +28,0 @@ "devDependencies": {

@@ -22,5 +22,5 @@ # libreoffice-convert #

// Read file
const enterPath = fs.readFileSync(enterPath);
const file = fs.readFileSync(enterPath);
// Convert it to pdf format with undefined filter (see Libreoffice doc about filter)
libre.convert(enterPath, extend, undefined, (err, done) => {
libre.convert(file, extend, undefined, (err, done) => {
if (err) {

@@ -27,0 +27,0 @@ console.log(`Error converting file: ${err}`);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc