Giter Site home page Giter Site logo

libreoffice-convert's Introduction

libreoffice-convert

A simple and fast node.js module for converting office documents to different formats.

Dependency

Please install libreoffice in /Applications (Mac), with your favorite package manager (Linux), or with the msi (Windows).

Usage example

'use strict';

const path = require('path');
const fs = require('fs').promises;

const libre = require('libreoffice-convert');
libre.convertAsync = require('util').promisify(libre.convert);

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
    await fs.writeFile(outputPath, pdfBuf);
}

main().catch(function (err) {
    console.log(`Error converting file: ${err}`);
});

libreoffice-convert's People

Contributors

a7i avatar asjidkalam avatar bokuweb avatar conor-odro avatar denyshubh avatar dependabot[bot] avatar elwerene avatar gsvarovsky avatar jamieslome avatar khoazero123 avatar lesageyann avatar mcunha avatar no0dles avatar snigdha920 avatar squalsoft avatar thisromantelecom avatar wdongxv avatar wedyarit avatar yktakaha4 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

libreoffice-convert's Issues

enterPath is declared twice in README.md

const enterPath = path.join(__dirname, '/resources/example.docx');
const outputPath = path.join(__dirname, /resources/example${extend});

// Read file
const enterPath = fs.readFileSync(enterPath);

Receiving error: no such file or directory, open "/var/folders/...../source..html"

Hi,

I was able to successfully use the library to convert local files stored on the same server by following the example code. I now, however, would like to convert a remote file.

My idea was to read the file's content first (via request) and then pass the body received to libreoffice-convert.

Below is the code I'm using:

request(fileUrl, {encoding: 'binary'}, function(error, response, body) {
    const ext = '.html';

    libre.convert(body, ext, undefined, (err, done) => {
      if (err) {
        console.log(`Error converting file: ${err}`);
        res.sendStatus(500);
      } else {
        console.log(done);
      }
    });

  });

I can see that when I run this, libreoffice starts the conversion but eventually, I'm getting this error:
Error: ENOENT: no such file or directory, open '/var/folders/j9/z_z85kh5501dbslrg53mpjsw0000gn/T/libreofficeConvert_-6529-x08o2o3peLMh/source..html

Is there something I'm missing?

Thanks!

In windows if we are going to delete a folder it won't allow to delete the folder unless it is empty.

Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users...\AppData\Local\Temp\libreofficeConvert_-14784-6r6ph8TQRyqc'
at Object.rmdirSync (fs.js:890:10)
at rmkidsSync (C:\Users...\node_modules\rimraf\rimraf.js:349:27)
at rmdirSync (C:\Users...\node_modules\rimraf\rimraf.js:329:7)
at rimrafSync (C:\Users...\node_modules\rimraf\rimraf.js:301:9)
at Object.cleanupCallback [as removeCallback] (C:\Users...\node_modules\tmp\lib\tmp.js:356:16)
at C:\Users...\node_modules\libreoffice-convert\index.js:63:17
at wrapper (C:\Users...\node_modules\async\dist\async.js:271:20)
at C:\Users...\node_modules\async\dist\async.js:1143:21
at C:\Users...\node_modules\async\dist\async.js:327:20
at C:\Users...\node_modules\libreoffice-convert\index.js:39:32 {
errno: -4051,
syscall: 'rmdir',
code: 'ENOTEMPTY',
path: 'C:\Users\...\AppData\Local\Temp\libreofficeConvert
-14784-6r6ph8TQRyqc'
}

Does not work in parallel

When I try to make 2 or more simultaneous conversions it always fails.
It would be nice to be able to use promises with the library

Error converting file: Error: Command failed

i get this Error.
Error converting file: Error: Command failed: "C:\Program Files\LibreOffice\program\soffice.exe" -env:UserInstallation=file://C:\Users\DEV_CR~1\AppData\Local\Temp\soffice-6052-5bec0zaQKRBk --headless --convert-to .pdf --outdir C:\Users\DEV_CR~1\AppData\Local\Temp\libreofficeConvert_-6052-iBxGkJXLM0NO C:\Users\DEV_CR~1\AppData\Local\Temp\libreofficeConvert_-6052-iBxGkJXLM0NO\source

Having issues when converting files

(node:4877) UnhandledPromiseRejectionWarning: error file un supported
(node:4877) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:4877) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Error converting file: Error: ENOENT: no such file or directory, open '/tmp/libreofficeConvert202007-4877-1kijeej.1pn9/source..pdf'
Error converting file: Error: ENOENT: no such file or directory, open '/tmp/libreofficeConvert202007-4877-131h2y9.ovkq/source..pdf'
Error converting file: Error: ENOENT: no such file or directory, open '/tmp/libreofficeConvert202007-4877-f7h33.2qayw8/source..pdf'
Error converting file: Error: ENOENT: no such file or directory, open '/tmp/libreofficeConvert202007-4877-1bo4kq9.n8t3/source..pdf'
Error converting file: Error: Command failed: /usr/bin/libreoffice --headless --convert-to .pdf --outdir /tmp/libreofficeConvert202007-4877-wkpi55.bi3xb /tmp/libreofficeConvert202007-4877-wkpi55.bi3xb/source
Error: source file could not be loaded
terminate called after throwing an instance of 'com::sun::star::lang::WrappedTargetRuntimeException'
Application Error

Error converting file: Error: Command failed: /usr/bin/libreoffice --headless --convert-to .pdf --outdir /tmp/libreofficeConvert202007-4877-18yn9n4.yj9s /tmp/libreofficeConvert202007-4877-18yn9n4.yj9s/source
Error: source file could not be loaded
terminate called after throwing an instance of 'com::sun::star::lang::WrappedTargetRuntimeException'
Application Error

Error converting file: Error: Command failed: /usr/bin/libreoffice --headless --convert-to .pdf --outdir /tmp/libreofficeConvert202007-4877-tq1z98.niqnb /tmp/libreofficeConvert202007-4877-tq1z98.niqnb/source
Error: source file could not be loaded
terminate called after throwing an instance of 'com::sun::star::lang::WrappedTargetRuntimeException'
Application Error

Error converting file: Error: ENOENT: no such file or directory, open '/tmp/libreofficeConvert202007-4877-m15z6e.dqc9/source..pdf'
Error converting file: Error: ENOENT: no such file or directory, open '/tmp/libreofficeConvert202007-4877-15wbn6q.nmkg/source..pdf'
Error converting file: Error: ENOENT: no such file or directory, open '/tmp/libreofficeConvert202007-4877-b774wb.v989l/source..pdf'
Error converting file: Error: Command failed: /usr/bin/libreoffice --headless --convert-to .pdf --outdir /tmp/libreofficeConvert202007-4877-6tu44f.g72kb /tmp/libreofficeConvert202007-4877-6tu44f.g72kb/source

Error converting file: Error: ENOENT: no such file or directory, open '/tmp/libreofficeConvert202007-4877-m3747.lakzqi/source..pdf'
Error converting file: Error: Command failed: /usr/bin/libreoffice --headless --convert-to .pdf --outdir /tmp/libreofficeConvert202007-4877-wo5v95.zbm9 /tmp/libreofficeConvert202007-4877-wo5v95.zbm9/source
Error: source file could not be loaded
terminate called after throwing an instance of 'com::sun::star::lang::WrappedTargetRuntimeException'
Application Error

Error converting file: Error: ENOENT: no such file or directory, open '/tmp/libreofficeConvert202007-4877-1ba6tcp.q9eb/source..pdf'
Error converting file: Error: ENOENT: no such file or directory, open '/tmp/libreofficeConvert202007-4877-1380jar.d0ph/source..pdf'

Bug in example code

Hi,

There is a bug in your example code. The second parameter to the callback is the buffered stream of output file which should be used to write the output file. Otherwise the code generates a pdf without content.

Error: Could not find soffice binary

Hi there -
I have installed LibreOffice on Amazon Linux using RPMs and updated the PATH variable.

Binary version: LibreOffice_7.1.4_Linux_x86-64_rpm
Install location: /opt/libreoffice7.1/program/

I can see the soffice.bin file and can access it from my NodeJs deployment directory (without specifying the absolute path). However, at runtime the libre.convert call is throwing error -
Error: Could not find soffice binary

I am stuck here. I would greatly appreciate any help in resolving this issue.

just a q ?

can i implement this in my api on shared host ?

Doesn't work in windows

It works well in OSX but when I deploy it to windows(both in win10 and win7) it failed, and the error is something like:

The program can't start because the config file [C:\Program Files\LibreOffice\program\bootstrap.ini] has corrupted.

I do check the bootstrap.ini file and find that content is well defined.

However, I can open soffice.exe and lanch LibreOffice by clicking the file Icon.

LibreOffice version: V7.0 (lastest)

Corrupted PDF

Hey! I'm trying to use this library for an enterprise use case (can't name the company at this time). We are trying to convert DOCX files into PDF format so they can be uploaded to AWS. When converting, the command succeeds and writes the PDF, but the PDF is corrupted. I copied the code directly from your example to use in a Typescript module.

import * as libre from 'libreoffice-convert';
// ...
async docxToPdf(fileName: string): Promise<boolean> {
    try {
      await new Promise((resolve, reject) => {
        const docx = fs.readFileSync(`${fileName}.docx`);
        libre.convert(docx, 'pdf', undefined, (done) => {
          console.log(done);
          fs.writeFileSync(`${fileName}.pdf`, done);
          resolve();
        });
      });
      return true;
    } catch (e) {
      this.logger.error('Encountered error while writing or converting to PDF.');
      this.logger.error(e);
      console.log(e);
      return false;
    }
  }```

Cannot run the example

Hello, I've been trying to run the "Usage Example", first I've had an error with the 2 const having the same name, renamed one, but then I think there's something not working somewhere because when I test it with Postman I get a simple file with name: xxxxxxx{extend}

Here is the code:

const path = require("path");
const fs = require("fs");
const multiparty = require("multiparty");
const util = require("util");
const { exec } = require('child_process');
const libre = require('libreoffice-convert');

exports.postfile =(req,res,next) =>{
const extend = '.png';
const input = path.join(__dirname, '../core/ressources/images/test.pdf');
const outputPath = path.join(__dirname, ../core/ressources/images/test{extend});

const enterPath = fs.readFileSync(input);
libre.convert(enterPath, extend, undefined, (err, done) => {
	if (err) {
		console.log(`Error converting file: ${err}`);
	}
	fs.writeFileSync(outputPath, done);
});

});
};

@types support?

hi,

can we have @types support for typescript?
currently im using this:

declare module 'libreoffice-convert' {
  export const convertWithOptions = (document: string, format: string,
  filter: string, options = {tmpOptions? : {}, asyncOptions? : {}}, 
  callback: (err: Error | undefined, any) => {
  
  }) => {}

  export const convert = (document: string, format: string,
  filter: string | undefined, callback: (err: Error | undefined, any) => {
  
  }) => {}
}

Error: ENOENT: no such file or directory, open '/tmp/libreofficeConvert_-32447-PWkldkvtqA0b/source..docx'

Error occurs when convert function is called

const path = require("path");
const fs = require("fs").promises;

const libre = require("libreoffice-convert");
libre.convertAsync = require("util").promisify(libre.convert);

(async function fn() {
  try {
    const ext = req.body.convertTo;

    const temp1 = req.body.data.resp.fileName.lastIndexOf(".");

    const inputPath = path.join(__dirname, "../", req.body.data.resp.path);
    const outputPath = path.join(
      __dirname,
      "../",
      `uploads/${req.body.data.resp.fileName.substring(0, temp1)}${ext}`
    );

    // Read file
    const docxBuf = await fs.readFile(inputPath);

    // Convert it to pdf format with undefined filter (see Libreoffice docs about filter)
    libre.convert(docxBuf, ext, undefined, (err, done) => {
      if (err) {
        console.log(docxBuf);
        console.log(`Error converting file: ${err}`);
        res.sendStatus(500);
      } else {
        console.log(done);
      }
    });
  } catch (err) { 
    console.log(err);
  }
})();

output Error:Error converting file: Error: ENOENT: no such file or directory, open '/tmp/libreofficeConvert_-3947-L12WFnW9nmeG/source..docx'

Needs Promise Wrapper around Example Code for calling 'convert' method

For this code to be reused in a Web Service capacity, the sequencing of the call to 'convert' and it's return callback both need to be managed to prevent premature returning.

      var rWsResultT = {};
      var rWsResult_Convert = await new Promise( (resolve, reject) => {

        var rWsResult_ConvertT = convert(sHtmlContent, 'docx:"Office Open XML Text"', undefined, (err, done) => 
        {
          if( err )
          {
            console.log(`Error converting file: ${err}`);

            rWsResultT['Status'] = 'ERROR';
            rWsResultT['Message'] = err;
            if( err.stack !== undefined )
            {
              rWsResultT['Stack'] = err.stack;
            }
          }
          else
          {
            rWsResultT['Status'] = 'OK';
            rWsResultT['Payload'] = done;
          }
          
          // Here in done you have pdf file which you can save or transfer in another stream
          //fs.writeFileSync( outputPath, done );

          return resolve( rWsResultT );

        }); // End of convert function

      }); // End of Promise wrapper

A future improvement could be to migrate 'convert' away from callbacks and toward use of Promises where the final Promise is returned from 'convert' and thus use 'await' to control it without needing a wrapper Promise. However, the above code does work effectively to control the open source without modifying it.

Error converting file

Error converting file: Error: spawn "C:\Program Files\LibreOffice\program\soffice.exe" ENOENT
I installed LibreOffice in the correct location already.

Specify custom binary path

My applications runs on Heroku (where you can deploy your node application) and in this application I use your library.

Because the default binary path is not /usr/bin/soffice or /usr/bin/libreoffice it fails to convert my libreoffice document.

Is it possible to specify a custom binary path?

linux yum installs libreoffice under the /opt/ folder

Hi,

I'm trying to use libreoffice-convert on an aws ec2 instance.

In order to make the module work I had to install libreoffice on the linux machine.
However, the package manager (yum) installs it on /opt/libreoffice6.4/program/soffice,
while the convert function only looks under /usr/bin folder and cannot find it.

Any help would be appreciated.

Thanks

Cannot read property 'O_CREAT' of undefined

Hello,

I'm trying to use libreoffice-convert to convert some docx files I have in my react web app to pdf files. I have created a file very similar to the usage example provided in npm named converter.js.

I can open my terminal and use "node converter.js" and it will successfully output the converted file. However, whenever I try to do the same thing via my react app by importing converter.js, I get the following error message:

Uncaught TypeError: Cannot read property 'O_CREAT' of undefined at Object.<anonymous> (tmp.js:22) at Object../node_modules/tmp/lib/tmp.js (tmp.js:780) at __webpack_require__ (bootstrap:784) at fn (bootstrap:150) at Object.<anonymous> (index.js:6) at Object../node_modules/libreoffice-convert/index.js (index.js:68) at __webpack_require__ (bootstrap:784) at fn (bootstrap:150) at Module../src/providers/Converter.js (Converter.js:1) at __webpack_require__ (bootstrap:784) at fn (bootstrap:150) at Module../src/pages/Client.js (Billing.js:288) at __webpack_require__ (bootstrap:784) at fn (bootstrap:150) at Module../src/App.js (App.css?4433:45) at __webpack_require__ (bootstrap:784) at fn (bootstrap:150) at Module../src/index.js (index.css?f3f6:45) at __webpack_require__ (bootstrap:784) at fn (bootstrap:150) at Object.1 (serviceWorker.js:141) at __webpack_require__ (bootstrap:784) at checkDeferredModules (bootstrap:45) at Array.webpackJsonpCallback [as push] (bootstrap:32) at main.chunk.js:1

directory not empty, rmdir on windows 10

OS: Windows Server 2019
Node: v14.4.0
npm: 6.14.5

My Code:

const libre = require('libreoffice-convert');
 
const path = require('path');
const fs = require('fs');
 
const extend = '.pdf'
const enterPath = path.join(__dirname, '/input/CAD 00001.docx');
const outputPath = path.join(__dirname, `/output/example${extend}`);
 
// 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) {
      return console.log(`Error converting file: ${err}`);
    }
    
    // Here in done you have pdf file which you can save or transfer in another stream
    fs.writeFileSync(outputPath, done);
});

$ node converter.js
C:\PROJECTS\test\node_modules\rimraf\rimraf.js:310
        throw er
        ^

Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users\VIPUL_~1\AppData\Local\Temp\2\libreofficeConvert_-1312-rs7W0TWfuZDn'
?[90m    at Object.rmdirSync (fs.js:865:3)?[39m
    at rmkidsSync (C:\PROJECTS\test\node_modules\?[4mrimraf?[24m\rimraf.js:349:27)
    at rmdirSync (C:\PROJECTS\test\node_modules\?[4mrimraf?[24m\rimraf.js:329:7)
    at rimrafSync (C:\PROJECTS\test\node_modules\?[4mrimraf?[24m\rimraf.js:301:9)
    at Object._cleanupCallback [as removeCallback] (C:\PROJECTS\test\node_modules\?[4mtmp?[24m\lib\tmp.js:356:16)
    at C:\PROJECTS\test\node_modules\?[4mlibreoffice-convert?[24m\index.js:59:17
    at C:\PROJECTS\test\node_modules\?[4masync?[24m\dist\async.js:473:16
    at C:\PROJECTS\test\node_modules\?[4masync?[24m\dist\async.js:1622:17
    at C:\PROJECTS\test\node_modules\?[4masync?[24m\dist\async.js:969:16
    at C:\PROJECTS\test\node_modules\?[4mlibreoffice-convert?[24m\index.js:35:32 {
  errno: ?[33m-4051?[39m,
  syscall: ?[32m'rmdir'?[39m,
  code: ?[32m'ENOTEMPTY'?[39m,
  path: ?[32m'C:\\Users\\VIPUL_~1\\AppData\\Local\\Temp\\2\\libreofficeConvert_-1312-rs7W0TWfuZDn'?[39m
}

However the above code works fine on macos.

PDF page formatting issue

PDF page formatting issue
ex:-
DOCX file upload with single page

san-valley-assisted-living-p2-evacuation_plan (2).docx

it's generate pdf with two pages like above EX

san-valley-assisted-living-p2-evacuation_plan-(2) (1).pdf


const libre = require('libreoffice-convert');

const path = require('path');
const fs = require('fs');

const extend = '.pdf'
const enterPath = path.join(__dirname, '/resources/example.docx');
const outputPath = path.join(__dirname, /resources/example${extend});

// 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});
}

// Here in done you have pdf file which you can save or transfer in another stream
fs.writeFileSync(outputPath, done);

});

Specify other directory for libreoffice instalation

Is there any way to specify a different path for the libreoffice instalation in Linux other than the default:
['/usr/bin/libreoffice', '/usr/bin/soffice']
paths?

I am trying to run this package within heroku but my libreoffice installation is under:

$HOME/vendor/libreoffice

I can't use ln -s or mount --bind commands to link this path to the default paths since there is no super user access on heroku.

Any help is appreciated!

Azure App Service support

I use this package for backend development to convert docx to pdf. I works fine on my local since libre office has been installed. But once I deploy it to azure app service, it doesn't work. Is there any way to fix this issue?

Could not find soffice

I have installed libreoffice using dpkg instead of apt-get because apt-get was installing older version of the package.

Via dpkg the package gets installed in a different location. Is there a workaround for this ?

Ability to set the tmp directory

In environments such as Kubernetes where volumes are mounted to a specific directory, it would be ideal to set the root temp directory to the volume mount location.
Based on tmp's documentation tmpdir allows the option to override that.

Output PDF font

Hi,
Thanks for this awesome package.

How can I keep the font used in the excel file.
The input xslx font is Calibri, but the output PDF is in Liberation.
I've changed the default font on LibreOffice to Carlito, but the headless doesn't take that into account.
Do you have any suggestion?

Cheers,

Wrong soffice.exe path on x64 installation.

When i install LibreOffice x64 package it installed in C:\Program Files\LibreOffice\program\soffice.exe. So converter can't find it. Please add this path in search array.

Conversion is very slowly.

I just converted a 5MB of a .doc file and took 4.19 minutes to be completed!
And I converted another file with size of 99MB manually from LibreOffice program and took me similar to the previous one around 4 minutes. The same 99MB tested throw this module, it took me very long time not finished and I skipped it.
Thank you for your help.

The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined

As in the title, there is something going on that the "done" variable is coming up short.

I'm on Linux, using node express to host an API to convert a docx that is generated with docxtemplater based on the answers of a form.

This is the code that is converting:

fs.writeFileSync(path.resolve(__dirname, /home/ec2-user/oficial_formulario/documentos/Prospeccao/${nome_docx}.docx`), buf);

const libre = require('libreoffice-convert');

const extend = '.pdf'
const enterPath = path.join(__dirname, `/documentos/Prospeccao/${nome_docx}.docx`);
const outputPath = path.join(__dirname, `/documentos/Prospeccao/${nome_docx}${extend}`);

// Read file
console.log(fs.readdirSync(`/home/ec2-user/oficial_formulario/documentos/Prospeccao/`))
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}`);
    }
    
    // Here in done you have pdf file which you can save or transfer in another stream
    fs.writeFileSync(outputPath, done);
    res.setHeader('Content-Disposition', `attachment; filename=${nome_docx}.docx`);
    res.sendFile(`/home/ec2-user/oficial_formulario/documentos/Prospeccao/${nome_docx}.docx`);
});`

And this is the error coming up:

Error converting file: Error: Could not find soffice binary
internal/fs/utils.js:779
throw new ERR_INVALID_ARG_TYPE(
^

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or >DataView. Received undefined
at Object.writeFileSync (fs.js:1460:5)
at /home/ec2-user/oficial_formulario/index.js:495:12
at /home/ec2-user/node_modules/libreoffice-convert/index.js:65:20
at /home/ec2-user/node_modules/async/dist/async.js:473:16
at /home/ec2-user/node_modules/async/dist/async.js:1622:17
at /home/ec2-user/node_modules/async/dist/async.js:969:16
at /home/ec2-user/node_modules/libreoffice-convert/index.js:37:32
at /home/ec2-user/node_modules/async/dist/async.js:3377:9
at /home/ec2-user/node_modules/async/dist/async.js:473:16
at iteratorCallback (/home/ec2-user/node_modules/async/dist/async.js:1064:13)
at /home/ec2-user/node_modules/async/dist/async.js:969:16
at /home/ec2-user/node_modules/async/dist/async.js:3369:13
at /home/ec2-user/node_modules/libreoffice-convert/index.js:34:68
at FSReqCallback.oncomplete (fs.js:171:23) {
code: 'ERR_INVALID_ARG_TYPE'
}
[nodemon] app crashed - waiting for file changes before

The first console.log on the code shows the file being converted, so I don't know what's going on.

excel 宽度太长

excel 宽度太长转pdf文件时会换行,可以设置转换比例让它在一页上显示吗

Could not find soffice binary

I'm trying to convert a buffer of .jpg file to pdf using libreoffice-convert in Windows 10.

I'm getting this error:

stack:"Error: Could not find soffice binary\n at D:\Projects\eVisa\Workspace\Source Code\Microservices\Back Office\node_modules\libreoffice-convert\index.js:33:41\n at D:\Projects\eVisa\Workspace\Source Code\Microservices\Back Office\node_modules\libreoffice-convert\node_modules\async\dist\async.js:3377:9\n at D:\Projects\eVisa\Workspace\Source Code\Microservices\Back Office\node_modules\libreoffice-convert\node_modules\async\dist\async.js:473:16\n at iteratorCallback (D:\Projects\eVisa\Workspace\Source Code\Microservices\Back Office\node_modules\libreoffice-convert\node_modules\async\dist\async.js:1064:13)\n at D:\Projects\eVisa\Workspace\Source Code\Microservices\Back Office\node_modules\libreoffice-convert\node_modules\async\dist\async.js:969:16\n at D:\Projects\eVisa\Workspace\Source Code\Microservices\Back Office\node_modules\libreoffice-convert\node_modules\async\dist\async.js:3369:13\n at D:\Projects\eVisa\Workspace\Source Code\Microservices\Back Office\node_modules\libreoffice-convert\index.js...

I've just installed the library and my Node.js version is 12.x.

async/await vs. callback

Would you be open to supporting promises vs. callbacks? I realize there are many considerations including API backward compatibility.

I would be happy to contribute an async approach if this aligns with future plans for this library (i.e. async/await).

Error when converting C:\Program ENOENT

Win10
LibreOffice v7.0.2.2 installed at C:\Program Files\LibreOffice\program\soffice.exe
Node v14.7.0

Error details:

Error converting file: Error: spawn "C:\Program ENOENT
Error: spawn "C:\Program ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
    at onErrorNT (internal/child_process.js:468:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn "C:\\Program',
  path: '"C:\\Program',
  spawnargs: [
    'Files\\LibreOffice\\program\\soffice.exe"',
    '-env:UserInstallation=file://C:\\Users\\Roman\\AppData\\Local\\Temp\\soffice-11300-d9d9mKfvSSfo',
    '--headless',
    '--convert-to',
    '.pdf',
    '--outdir',
    'C:\\Users\\Roman\\AppData\\Local\\Temp\\libreofficeConvert_-11300-wBV3EUYjmTul',
    'C:\\Users\\Roman\\AppData\\Local\\Temp\\libreofficeConvert_-11300-wBV3EUYjmTul\\source'
  ],
  cmd: '"C:\\Program Files\\LibreOffice\\program\\soffice.exe" -env:UserInstallation=file://C:\\Users\\Roman\\AppData\\Local\\Temp\\soffice-11300-d9d9mKfvSSfo --headless --convert-to .pdf --outdir C:\\Users\\Roman\\AppData\\Local\\Temp\\libreofficeConvert_-11300-wBV3EUYjmTul C:\\Users\\Roman\\AppData\\Local\\Temp\\libreofficeConvert_-11300-wBV3EUYjmTul\\source'
}

Convert PPT to PNG

I'm trying to convert PPT to PNG, but I got only the first slide converted as PNG.

Is there any option/param to convert all slides?

Error: Could not find soffice binary

my app is prefectly running on local machine but on heroku its giving me a error,
Error: Could not find soffice binary
2022-06-23T07:45:26.091735+00:00 app[web.1]: at /app/node_modules/libreoffice-convert/index.js:39:41
2022-06-23T07:45:26.091735+00:00 app[web.1]: at /app/node_modules/async/dist/async.js:2965:13
2022-06-23T07:45:26.091736+00:00 app[web.1]: at wrapper (/app/node_modules/async/dist/async.js:271:20)
2022-06-23T07:45:26.091736+00:00 app[web.1]: at iteratorCallback (/app/node_modules/async/dist/async.js:501:17)
2022-06-23T07:45:26.091736+00:00 app[web.1]: at /app/node_modules/async/dist/async.js:327:20
2022-06-23T07:45:26.091737+00:00 app[web.1]: at /app/node_modules/async/dist/async.js:2957:17
2022-06-23T07:45:26.091737+00:00 app[web.1]: at /app/node_modules/libreoffice-convert/index.js:36:68
2022-06-23T07:45:26.091737+00:00 app[web.1]: at FSReqCallback.oncomplete (node:fs:188:23)
2022-06-23T07:45:56.072200+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST

Not working on heroku server with libreoffice buildpack

Hi I am using this package on my heroku server and have installed the libreoffice buildpack for Heroku stack-18 however whenever I try to run this package to convert word docx to pdf on the server I get an error message saying soffice binary is not found.

If I run heroku run soffice --version is says that soffice is installed.

I'm wondering if anyone has successfully used this on a Heroku server

Deprecation warning

Hi! Thank you for your great small library! I use it on latest node.js and on run i receive warning:
(node:30076) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead

Can you fix it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.