elwerene / libreoffice-convert

MIT License
242 stars 94 forks source link

Could not find soffice binary #16

Closed SushKenyNeosoft closed 4 years ago

SushKenyNeosoft commented 4 years ago

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.

elwerene commented 4 years ago

Where did you install Libre Office?

Am 18. Februar 2020 06:20:26 MEZ schrieb SushKenyNeosoft notifications@github.com:

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.

SushKenyNeosoft commented 4 years ago

Do I need to install Libre Office in machine?

elwerene commented 4 years ago

yes!

Am 18. Februar 2020 10:44:13 MEZ schrieb SushKenyNeosoft notifications@github.com:

Do I need to install Libre Office in windows too?

SushKenyNeosoft commented 4 years ago

yes! Am 18. Februar 2020 10:44:13 MEZ schrieb SushKenyNeosoft notifications@github.com: Do I need to install Libre Office in windows too?

Ok Sir, Thanks!

muhammadrohan3 commented 1 year ago

What if I have to deploy my code on heroku

averrows commented 6 months ago

Me too. Any answer for this?

JorgeSilvaVM commented 5 months ago

Me too. Any answer for this?

You have to install libreoffice in your machine, because libreoffice-convert use the program installed

manusiakemos commented 2 months ago

i install libreoffice on docker but it show me error Could not find soffice binary

manusiakemos commented 2 months ago
image
version: "3.9"
services:
  mysql:
    build:
      context: "./docker/mysql"
      dockerfile: "Dockerfile"
      args:
        - MYSQL_VERSION=${MYSQL_VERSION}
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      - MYSQL_DATABASE=${MYSQL_DATABASE}
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - TZ=${WORKSPACE_TIMEZONE}
    ports:
      - '3306:3306'
    volumes:
      - ./data/db:/var/lib/mysql
    networks:
      - backend
      - frontend
  node:
    working_dir: /home/node/app
    build:
      context: .
      dockerfile: "Dockerfile"
    restart: no
    environment:
      DB_SCHEMA: mysql
      DB_USER: ${MYSQL_USER}
      DB_PASSWORD: ${MYSQL_USER}
      DB_HOST: mysql
    depends_on:
      - mysql
    ports:
      - ${WORKSPACE_PORT}:8000
    stdin_open: true
    tty: true
    volumes:
      - .:/home/node/app
      - ./node_modules:/home/node/app/node_modules
    networks:
      - backend
      - frontend
  libreoffice:
    image: lscr.io/linuxserver/libreoffice:latest
    security_opt:
      - seccomp:unconfined #optional
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
      - CUSTOM_USER=username
      - PASSWORD=password
    volumes:
      - ./data/libreoffice/config:/config
    ports:
      - 3000:3000
      - 3001:3001
    restart: unless-stopped
networks:
  frontend:
  backend:
manusiakemos commented 2 months ago
image
elwerene commented 2 months ago

Well I guess you need to specify the path to the soffice binary in the options ;)

kamelabiad commented 1 month ago

@manusiakemos have u managed to make it work ?

juanovt10 commented 1 month ago

Having the same problem... I ran the container and check the path for soffice and it is indeed there but then how should I specify the path? Where and how?

manusiakemos commented 1 month ago

@manusiakemos have u managed to make it work ?

Yes. I just installed on my Dockerfile. I will share my Dockerfile later

juanovt10 commented 1 month ago

@manusiakemos I made it work at the end. However, not only with the installation in the Dockerfile but also in the convert service by adding the binary options:

libre.convertAsync = (inputFile, outputFormat) => {
  return new Promise((resolve, reject) => {
    const options = {
      sofficeBinaryPaths: [process.env.LIBREOFFICE_PATH]
    };
    libre.convertWithOptions(inputFile, outputFormat, undefined, options, (err, done) => {
      if (err) {
        reject(err);
      } else {
        resolve(done);
      }
    });
  });
};
manusiakemos commented 1 month ago

@manusiakemos I made it work at the end. However, not only with the installation in the Dockerfile but also in the convert service by adding the binary options:

libre.convertAsync = (inputFile, outputFormat) => {
  return new Promise((resolve, reject) => {
    const options = {
      sofficeBinaryPaths: [process.env.LIBREOFFICE_PATH]
    };
    libre.convertWithOptions(inputFile, outputFormat, undefined, options, (err, done) => {
      if (err) {
        reject(err);
      } else {
        resolve(done);
      }
    });
  });
};

Glad to hear it. 🥂

islovingness commented 1 month ago

@manusiakemos I made it work at the end. However, not only with the installation in the Dockerfile but also in the convert service by adding the binary options:

libre.convertAsync = (inputFile, outputFormat) => {
  return new Promise((resolve, reject) => {
    const options = {
      sofficeBinaryPaths: [process.env.LIBREOFFICE_PATH]
    };
    libre.convertWithOptions(inputFile, outputFormat, undefined, options, (err, done) => {
      if (err) {
        reject(err);
      } else {
        resolve(done);
      }
    });
  });
};

good job

elwerene commented 1 month ago

If someone of you wants to write this down as a short howto and extend the Readme in a pull request, that would be very welcome as many people come here to open issues for the same questions :)

harryadel commented 4 weeks ago

I already added libreoffice to my docker file as one of the packages to be installed but it fails for some reason. Will anybody share their Dockerfiles?

# Install packages needed to build node modules
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3 bash libreoffice util-linux