Dolibarr / dolibarr

Dolibarr ERP CRM is a modern software package to manage your company or foundation's activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, ...). it's an open source Web application (written in PHP) designed for businesses of any sizes, foundations and freelancers.
https://www.dolibarr.org
GNU General Public License v3.0
5.53k stars 2.81k forks source link

Bug - Getting a strange error on ODT to PDF converstion #10896

Closed hussain-attari closed 4 years ago

hussain-attari commented 5 years ago

Hi,

I am getting the following error while generating PDF from an ODT File.

I believe this is a similar error as this one

I have Dolibarr 9.0.1 installed on my shared linux webserver.

MAIN_ODT_AS_PDF - pyodconverter MAIN_DOL_SCRIPTS_ROOT - is defined

Dolibarr has detected a technical error.
This information can be useful for diagnostic purposes (you can set option $dolibarr_main_prod to '1' to remove such notices):
Date: 20190321170218
Dolibarr: 9.0.1
PHP: 7.0.33
Server: Apache/2.4.38 (cPanel) OpenSSL/1.0.2q mod_bwlimited/1.4 Phusion_Passenger/5.3.7
OS: Linux md-ht-2.webhostbox.net 2.6.32-896.16.1.lve1.4.54.el6.x86_64 #1 SMP Wed May 2 07:43:19 EDT 2018 x86_64
UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0

Requested URL: /erp/comm/propal/card.php?id=2
Referer: https://[www.mywebaddress.in]/erp/comm/propal/card.php?id=2&file=%28PROV2%29%2F%28PROV2%29_Quotation_format.odt&entity=1
Menu manager: eldy_menu.php

Database type manager: mysqli
Latest database access request error: No request in error
Return code for latest database access request error: No request in error
Information for latest database access request error: No request in error

Message: Error generating document for CommonObject. Error: ODT to PDF convert fail : 
hussain-attari commented 5 years ago

So, I did some tweaking in the settings to see if I get the desired results.

I deleted the MAIN_DOL_SCRIPTS_ROOT from Setup Other and tried generating the pdf file I got the error.

Message: Error generating document for CommonObject. Error: Permission execute convert script : ../../scripts/odt2pdf/odt2pdf.sh /home/attarite/erpdata/facture/\(PROV16\)/\(PROV16\)_CGST_SGST_Invoice_format pyodconverter

So I changed the permission to 0755 and then I got this error.

Message: Error generating document for CommonObject. Error: ODT to PDF convert fail : Error while converting odt to pdf: 2<br>

I even tried with 0777 and 0744. Still got the same error.

hussain-attari commented 5 years ago

Update

I was checking the dolibarr.log file to locate any errors if I could after clicking on the generate key to generate the pdf file. I found this one error which I believe might be note worthy

__[MAIN_ODT_AS_PDF]__ not found in the document

Should I be seeing this error?

hussain-attari commented 5 years ago

Hi,

Any update on this?

hussain-attari commented 5 years ago

Any help on this issue please

mikee2 commented 5 years ago

Hi h6585.

What code are you using for the python document converter? Mine is DocumentCoverter.py and is working fine.

Make sure the pyodconverter code is being called with full path. If the python code is in the same folder as the odt2pdf.sh script then make sure you have something like:

  if [ "x$2" == "xpyodconverter" ]
  then
     python `dirname "$0"`/DocumentConverter.py "$1.odt" "$1.pdf" 2>&1
  else

in the shell script. Also that the owner of the pyodconverter must be the one that apache is calling the bash file with.

Hope this help.

hussain-attari commented 5 years ago

Hi,

This is the code that I have, can you please point me in the right direction.

#!/bin/bash
# @copyright  GPL License 2010 - Vikas Mahajan - http://vikasmahajan.wordpress.com
# @copyright  GPL License 2013 - Florian HEnry - florian.henry@open-concept.pro
# @copyright  GPL License 2017 - Laurent Destailleur - eldy@users.sourceforge.net
#
# Convert an ODT into a PDF using "jodconverter" or "pyodconverter" or "unoconv" tool.
# Dolibarr variable MAIN_ODT_AS_PDF must be defined 
#  to value "unoconv" to call unoconv CLI tool after ODT generation.
#  or value "pyodconverter" to call DocumentConverter.py after ODT generation.
#  or value "jodconverter" to call jodconverter wrapper after ODT generation
#  or value "/pathto/jodconverter-cli-file.jar" to call jodconverter java tool without wrapper after ODT generation.
# Dolibarr variable MAIN_DOL_SCRIPTS_ROOT must be defined to path of script directories (otherwise dolibarr will try to guess).

if [ "x$1" == "x" ] 
then
    echo "Usage:   odt2pdf.sh fullfilename [unoconv|jodconverter|pyodconverter|pathtojodconverterjar]"
    echo "Example: odt2pdf.sh myfile unoconv"
    echo "Example: odt2pdf.sh myfile ~/jodconverter/jodconverter-cli-2.2.2.jar"
    exit
fi

# Full patch where soffice is installed 
soffice="/usr/bin/soffice"

# Temporary directory (web user must have permission to read/write). You can set here path to your DOL_DATA_ROOT/admin/temp directory for example. 
home_java="/tmp"

# Main program
if [ -f "$1.odt" ]
then

  if [ "x$2" == "xunoconv" ]
  then
      # See issue https://github.com/dagwieers/unoconv/issues/87
      /usr/bin/unoconv -vvv "$1.odt"
      retcode=$?
      if [ $retcode -ne 0 ]
       then
        echo "Error while converting odt to pdf: $retcode"
        exit 1
      fi
      exit 0
  fi

  nbprocess=$(pgrep -c soffice)
  if [ $nbprocess -ne 1 ]   # If there is some soffice process running
   then
    cmd="$soffice --invisible --accept=socket,host=127.0.0.1,port=8100;urp; --nofirststartwizard --headless -env:UserInstallation=file:///$home_java/"
    export HOME=$home_java && cd $home_java && $cmd&
    retcode=$?
    if [ $retcode -ne 0 ]
     then
      echo "Error running soffice: $retcode"
      exit 1
    fi
    sleep 2
  fi

  if [ "x$2" == "xjodconverter" ]
  then
      jodconverter "$1.odt" "$1.pdf"
  else
      if [ "x$2" == "xpyodconverter" ]
      then
         python DocumentConverter.py "$1.odt" "$1.pdf"
      else
         java -jar $2 "$1.odt" "$1.pdf" 
      fi
  fi

  retcode=$?
  if [ $retcode -ne 0 ]
   then
    echo "Error while converting odt to pdf: $retcode"
    exit 1
  fi

  sleep 1
else
  echo "Error: Odt file $1.odt does not exist"
  exit 1
fi

I don't have the line python 'dirname......

eldy commented 5 years ago

I have some reason to think this may be fixed into more recent version. Does this bug still occurs with last stable version ? If not, can you close ticket ? If yes, can you confirm the last stable version you reproduced the bug with ?

hussain-attari commented 5 years ago

Hi,

I have updated to Dolibarr V10.0 today and tried converting the document. This is the error I am getting now. I have attached the following files for your reference: 1] error message, 2] DocumentConverter.py, and 3] odt2pdf.sh

My settings are: MAIN_DOL_SCRIPTS_ROOT - public_html/erp/includes/odtphp MAIN_ODT_AS_PDF - DocumentConverter.py

Here is the Error Message

Dolibarr has detected a technical error.
You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.
This information can be useful for diagnostic purposes (you can set option $dolibarr_main_prod to '1' to remove such notices):
Date: 20190717120836
Dolibarr: 10.0.0
Level of features: 1
PHP: 7.0.33
Server: Apache/2.4.39 (cPanel) OpenSSL/1.0.2r mod_bwlimited/1.4 Phusion_Passenger/5.3.7
OS: Linux md-ht-2.webhostbox.net 2.6.32-896.16.1.lve1.4.54.el6.x86_64 #1 SMP Wed May 2 07:43:19 EDT 2018 x86_64
UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0

Requested URL: /erp/compta/facture/card.php?facid=58
Referer: https://www.[mycompanywebaddress].in/erp/compta/facture/card.php?facid=58
Menu manager: eldy_menu.php

Modules/Applications: api, syslog, user, tax, oauth, stock, propal, numberwords, product, categorie, fckeditor, import, export, mailing, multicurrency, agenda, cron, commande, ecm, facture, fournisseur, printing, societe, variants, notification
Database type manager: mysqli
Latest database access request error: No request in error
Return code for latest database access request error: No request in error
Information for latest database access request error: No request in error

Message: Error generating document for CommonObject. Error: ODT to PDF convert fail (option MAIN_ODT_AS_PDF is DocumentConverter.py, command was public_html/erp/includes/odtphp/scripts/odt2pdf/odt2pdf.sh /home/attarite/erpdata/facture/\(PROV58\)/\(PROV58\)_CGST_SGST DocumentConverter.py, retval=127) :

Here is the DocumentConverter.py file

#
# PyODConverter (Python OpenDocument Converter) v1.2 - 2012-03-10
#
# This script converts a document from one office format to another by
# connecting to an OpenOffice.org instance via Python-UNO bridge.
#
# Copyright (C) 2008-2012 Mirko Nasato
# Licensed under the GNU LGPL v2.1 - http://www.gnu.org/licenses/lgpl-2.1.html
# - or any later version.
#
DEFAULT_OPENOFFICE_PORT = 2002

import uno
from os.path import abspath, isfile, splitext
from com.sun.star.beans import PropertyValue
from com.sun.star.task import ErrorCodeIOException
from com.sun.star.connection import NoConnectException

FAMILY_TEXT = "Text"
FAMILY_WEB = "Web"
FAMILY_SPREADSHEET = "Spreadsheet"
FAMILY_PRESENTATION = "Presentation"
FAMILY_DRAWING = "Drawing"

#---------------------#
# Configuration Start #
#---------------------#

# see http://wiki.services.openoffice.org/wiki/Framework/Article/Filter

# most formats are auto-detected; only those requiring options are defined here
IMPORT_FILTER_MAP = {
    "txt": {
        "FilterName": "Text (encoded)",
        "FilterOptions": "utf8"
    },
    "csv": {
        "FilterName": "Text - txt - csv (StarCalc)",
        "FilterOptions": "44,34,0"
    }
}

EXPORT_FILTER_MAP = {
    "pdf": {
        FAMILY_TEXT: { "FilterName": "writer_pdf_Export" },
        FAMILY_WEB: { "FilterName": "writer_web_pdf_Export" },
        FAMILY_SPREADSHEET: { "FilterName": "calc_pdf_Export" },
        FAMILY_PRESENTATION: { "FilterName": "impress_pdf_Export" },
        FAMILY_DRAWING: { "FilterName": "draw_pdf_Export" }
    },
    "html": {
        FAMILY_TEXT: { "FilterName": "HTML (StarWriter)" },
        FAMILY_SPREADSHEET: { "FilterName": "HTML (StarCalc)" },
        FAMILY_PRESENTATION: { "FilterName": "impress_html_Export" }
    },
    "odt": {
        FAMILY_TEXT: { "FilterName": "writer8" },
        FAMILY_WEB: { "FilterName": "writerweb8_writer" }
    },
    "doc": {
        FAMILY_TEXT: { "FilterName": "MS Word 97" }
    },
    "rtf": {
        FAMILY_TEXT: { "FilterName": "Rich Text Format" }
    },
    "txt": {
        FAMILY_TEXT: {
            "FilterName": "Text",
            "FilterOptions": "utf8"
        }
    },
    "ods": {
        FAMILY_SPREADSHEET: { "FilterName": "calc8" }
    },
    "xls": {
        FAMILY_SPREADSHEET: { "FilterName": "MS Excel 97" }
    },
    "csv": {
        FAMILY_SPREADSHEET: {
            "FilterName": "Text - txt - csv (StarCalc)",
            "FilterOptions": "44,34,0"
        }
    },
    "odp": {
        FAMILY_PRESENTATION: { "FilterName": "impress8" }
    },
    "ppt": {
        FAMILY_PRESENTATION: { "FilterName": "MS PowerPoint 97" }
    },
    "swf": {
        FAMILY_DRAWING: { "FilterName": "draw_flash_Export" },
        FAMILY_PRESENTATION: { "FilterName": "impress_flash_Export" }
    }
}

PAGE_STYLE_OVERRIDE_PROPERTIES = {
    FAMILY_SPREADSHEET: {
        #--- Scale options: uncomment 1 of the 3 ---
        # a) 'Reduce / enlarge printout': 'Scaling factor'
        "PageScale": 100,
        # b) 'Fit print range(s) to width / height': 'Width in pages' and 'Height in pages'
        #"ScaleToPagesX": 1, "ScaleToPagesY": 1000,
        # c) 'Fit print range(s) on number of pages': 'Fit print range(s) on number of pages'
        #"ScaleToPages": 1,
        "PrintGrid": False
    }
}

#-------------------#
# Configuration End #
#-------------------#

class DocumentConversionException(Exception):

    def __init__(self, message):
        self.message = message

    def __str__(self):
        return self.message

class DocumentConverter:

    def __init__(self, port=DEFAULT_OPENOFFICE_PORT):
        localContext = uno.getComponentContext()
        resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext)
        try:
            context = resolver.resolve("uno:socket,host=localhost,port=%s;urp;StarOffice.ComponentContext" % port)
        except NoConnectException:
            raise DocumentConversionException, "failed to connect to OpenOffice.org on port %s" % port
        self.desktop = context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", context)

    def convert(self, inputFile, outputFile):

        inputUrl = self._toFileUrl(inputFile)
        outputUrl = self._toFileUrl(outputFile)

        loadProperties = { "Hidden": True }
        inputExt = self._getFileExt(inputFile)
        if IMPORT_FILTER_MAP.has_key(inputExt):
            loadProperties.update(IMPORT_FILTER_MAP[inputExt])

        document = self.desktop.loadComponentFromURL(inputUrl, "_blank", 0, self._toProperties(loadProperties))
        try:
            document.refresh()
        except AttributeError:
            pass

        family = self._detectFamily(document)
        self._overridePageStyleProperties(document, family)

        outputExt = self._getFileExt(outputFile)
        storeProperties = self._getStoreProperties(document, outputExt)

        try:
            document.storeToURL(outputUrl, self._toProperties(storeProperties))
        finally:
            document.close(True)

    def _overridePageStyleProperties(self, document, family):
        if PAGE_STYLE_OVERRIDE_PROPERTIES.has_key(family):
            properties = PAGE_STYLE_OVERRIDE_PROPERTIES[family]
            pageStyles = document.getStyleFamilies().getByName('PageStyles')
            for styleName in pageStyles.getElementNames():
                pageStyle = pageStyles.getByName(styleName)
                for name, value in properties.items():
                    pageStyle.setPropertyValue(name, value)

    def _getStoreProperties(self, document, outputExt):
        family = self._detectFamily(document)
        try:
            propertiesByFamily = EXPORT_FILTER_MAP[outputExt]
        except KeyError:
            raise DocumentConversionException, "unknown output format: '%s'" % outputExt
        try:
            return propertiesByFamily[family]
        except KeyError:
            raise DocumentConversionException, "unsupported conversion: from '%s' to '%s'" % (family, outputExt)

    def _detectFamily(self, document):
        if document.supportsService("com.sun.star.text.WebDocument"):
            return FAMILY_WEB
        if document.supportsService("com.sun.star.text.GenericTextDocument"):
            # must be TextDocument or GlobalDocument
            return FAMILY_TEXT
        if document.supportsService("com.sun.star.sheet.SpreadsheetDocument"):
            return FAMILY_SPREADSHEET
        if document.supportsService("com.sun.star.presentation.PresentationDocument"):
            return FAMILY_PRESENTATION
        if document.supportsService("com.sun.star.drawing.DrawingDocument"):
            return FAMILY_DRAWING
        raise DocumentConversionException, "unknown document family: %s" % document

    def _getFileExt(self, path):
        ext = splitext(path)[1]
        if ext is not None:
            return ext[1:].lower()

    def _toFileUrl(self, path):
        return uno.systemPathToFileUrl(abspath(path))

    def _toProperties(self, dict):
        props = []
        for key in dict:
            prop = PropertyValue()
            prop.Name = key
            prop.Value = dict[key]
            props.append(prop)
        return tuple(props)

if __name__ == "__main__":
    from sys import argv, exit

    if len(argv) < 3:
        print "USAGE: python %s <input-file> <output-file>" % argv[0]
        exit(255)
    if not isfile(argv[1]):
        print "no such input file: %s" % argv[1]
        exit(1)

    try:
        converter = DocumentConverter()    
        converter.convert(argv[1], argv[2])
    except DocumentConversionException, exception:
        print "ERROR! " + str(exception)
        exit(1)
    except ErrorCodeIOException, exception:
        print "ERROR! ErrorCodeIOException %d" % exception.ErrCode
        exit(1)

Here is the odt2pdf.sh file

#!/bin/bash
# @copyright  GPL License 2010 - Vikas Mahajan - http://vikasmahajan.wordpress.com
# @copyright  GPL License 2013 - Florian HEnry - florian.henry@open-concept.pro
# @copyright  GPL License 2017 - Laurent Destailleur - eldy@users.sourceforge.net
#
# Convert an ODT into a PDF using "jodconverter" or "pyodconverter" or "unoconv" tool.
# Dolibarr variable MAIN_ODT_AS_PDF must be defined 
#  to value "unoconv" to call unoconv CLI tool after ODT generation.
#  or value "pyodconverter" to call DocumentConverter.py after ODT generation.
#  or value "jodconverter" to call jodconverter wrapper after ODT generation
#  or value "/pathto/jodconverter-cli-file.jar" to call jodconverter java tool without wrapper after ODT generation.
# Dolibarr variable MAIN_DOL_SCRIPTS_ROOT must be defined to path of script directories (otherwise dolibarr will try to guess).

if [ "x$1" == "x" ] 
then
    echo "Usage:   odt2pdf.sh fullfilename [unoconv|jodconverter|pyodconverter|pathtojodconverterjar]"
    echo "Example: odt2pdf.sh myfile unoconv"
    echo "Example: odt2pdf.sh myfile ~/jodconverter/jodconverter-cli-2.2.2.jar"
    exit
fi

# Full patch where soffice is installed 
soffice="/usr/bin/soffice"

# Temporary directory (web user must have permission to read/write). You can set here path to your DOL_DATA_ROOT/admin/temp directory for example. 
home_java="/tmp"

# Main program
if [ -f "$1.odt" ]
then

  if [ "x$2" == "xunoconv" ]
  then
      # See issue https://github.com/dagwieers/unoconv/issues/87
      /usr/bin/unoconv -vvv "$1.odt"
      retcode=$?
      if [ $retcode -ne 0 ]
       then
        echo "Error while converting odt to pdf: $retcode"
        exit 1
      fi
      exit 0
  fi

  nbprocess=$(pgrep -c soffice)
  if [ $nbprocess -ne 1 ]   # If there is some soffice process running
   then
    cmd="$soffice --invisible --accept=socket,host=127.0.0.1,port=8100;urp; --nofirststartwizard --headless -env:UserInstallation=file:///$home_java/"
    export HOME=$home_java && cd $home_java && $cmd&
    retcode=$?
    if [ $retcode -ne 0 ]
     then
      echo "Error running soffice: $retcode"
      exit 1
    fi
    sleep 2
  fi

  if [ "x$2" == "xjodconverter" ]
  then
      jodconverter "$1.odt" "$1.pdf"
  else
      if [ "x$2" == "xpyodconverter" ]
      then
         python DocumentConverter.py "$1.odt" "$1.pdf"
      else
         java -jar $2 "$1.odt" "$1.pdf" 
      fi
  fi

  retcode=$?
  if [ $retcode -ne 0 ]
   then
    echo "Error while converting odt to pdf: $retcode"
    exit 1
  fi

  sleep 1
else
  echo "Error: Odt file $1.odt does not exist"
  exit 1
fi

At least we are getting a message now to rectify the issue.

So, how can I remedy this problem?

eldy commented 5 years ago

The variable MAIN_DOL_SCRIPTS_ROOT must contains pull path where the odt2pdf.sh is stored, so a directory like '../scripts/odtphp'

hussain-attari commented 5 years ago

Did that and this the error I am getting now

Message: Error generating document for CommonObject. Error: ODT to PDF convert fail (option MAIN_ODT_AS_PDF is pyodconverter, command was public_html/erp/scripts/odt2pdf/scripts/odt2pdf/odt2pdf.sh /home/attarite/erpdata/propale/AT-Q-052019-007/AT-Q-052019-007_Quotation pyodconverter, retval=127) :

Do I have to install any other software apart from what comes in the Dolibarr package?

hussain-attari commented 5 years ago

Here is the full error

Dolibarr has detected a technical error.
You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.
This information can be useful for diagnostic purposes (you can set option $dolibarr_main_prod to '1' to remove such notices):
Date: 20190802100700
Dolibarr: 10.0.0
Level of features: 1
PHP: 7.0.33
Server: Apache/2.4.39 (cPanel) OpenSSL/1.0.2r mod_bwlimited/1.4 Phusion_Passenger/5.3.7
OS: Linux md-ht-2.webhostbox.net 2.6.32-896.16.1.lve1.4.54.el6.x86_64 #1 SMP Wed May 2 07:43:19 EDT 2018 x86_64
UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36

Requested URL: /erp/comm/propal/card.php?id=26
Referer: https://www.[mywebaddress].in/erp/comm/propal/card.php?id=26
Menu manager: eldy_menu.php

Modules/Applications: api, syslog, user, tax, oauth, stock, propal, numberwords, product, categorie, fckeditor, import, export, mailing, multicurrency, agenda, cron, commande, ecm, facture, fournisseur, printing, societe, variants, notification
Database type manager: mysqli
Latest database access request error: No request in error
Return code for latest database access request error: No request in error
Information for latest database access request error: No request in error

Message: Error generating document for CommonObject. Error: ODT to PDF convert fail (option MAIN_ODT_AS_PDF is pyodconverter, command was public_html/erp/scripts/odt2pdf/scripts/odt2pdf/odt2pdf.sh /home/attarite/erpdata/propale/AT-Q-052019-007/AT-Q-052019-007_Quotation pyodconverter, retval=127) : 
hussain-attari commented 4 years ago

Hi,

Any update on this issue?

mikee2 commented 4 years ago

Mine is working fine, I'm using it all the time.

Here are my recommendations just in case they are useful to you (I am using your previous data to try being more specific to your setup):

1.- MAIN_DOL_SCRIPTS_ROOT - /home/site_folder/public_html/erp/includes/odtphp Use full posix path, not relative. This is, if the 'scripts' folder is INSIDE the /includes/odtphp folder you have written.

In the error message you publish it looks like you are trying to run 'public_html/erp/scripts/odt2pdf/scripts/odt2pdf/odt2pdf.sh'. Can you run that script from a shell session with that same line (take into account that dolibarr only add the 'scripts' part to that path)? Is the script odt2pdf.sh in that location?. is that script executable (chmod +x ....)?

2.- MAIN_ODT_AS_PDF - pyodconverter You were using the shell script name. Please use the 'if' selector name instead. All lowercase.

3.- As told in my former message make sure that you use the full path, inside the odt2pdf.sh script, when calling the converter. Else it will fail. And make sure about the owner of that pyhon script (.py). you have to guarantee that it is ownerd by the apache user it runs under or it will not be able to run.

With all this in place it should work.

Good luck.

Edited to fix full path being hidden by the forum interpreter

hussain-attari commented 4 years ago

Hi,

Thank you for your immediate reply.

I tried a few changes however still getting an error.

Will try once again tomorrow and update here.

Can I email you? I want to send you a screen shot of my file structure and I don't want to share it over here on a public forum.

mikee2 commented 4 years ago

Hi h6585.

I think it is the same bad idea to share a private email address here too :)

Regards

hussain-attari commented 4 years ago

Hi,

I wanted to ask this again do I have to install any other software for document convesion?

I have installed Dolibarr on my shared web server and through Softaculous so the folder structure is different than the one on GITHUB probably that's whats causing the error.

Further in the odt2pdf.sh file this line

# Full patch where soffice is installed 
soffice="/usr/bin/soffice"

which defines the path to soffice does not exists on my server. So, would this be the issue?

in the error message that I get "retval=127" what error would this be probably a code line is corrupted on softaculous installation.

mikee2 commented 4 years ago

Of course that you need to have soffice installed so you have to install libreoffice.

And, besides, you may have to launch a headless instance of soffice under the user account that dolibarr is running so that the script is able to execute it. I'll try to explain.

soffice convert documents in headless mode without any issues under the root account. But the instance that dolibarr executes may not run under root but under another, less privileged, account (in my case I use CWP and your case may be the same because you write about using softaculous that is usually linked to control panels). This is for security in shared systems and makes the conversion fail.

To avoid this and to guarantee that the user that the system is running the script under is able to run soffice, I have to 'preload' it by running this from root:

su -s /bin/bash - <user_account_it_will_run_under> -c '/usr/bin/soffice --invisible --accept="socket,host=127.0.0.1,port=8100;urp;" --nofirststartwizard --headless --nodefault --nologo -env:UserInstallation=file:///tmp/ &'

Now the process can run and convert the docs it gets passed without issues. This has nothing to do with dolibarr per se but with the underlying environment I am running the app on.

Hope this helps.

hussain-attari commented 4 years ago

Where do I insert the code? in the odt2pdf.sh file?

How do I load soffice or LibreOffice. As far as I am aware I will be unable to install any software unless provided by softaculous.

mikee2 commented 4 years ago

Well, nope... Your best bet it to put it somewhere in your system that runs it at boot time because you will have to run it at each boot. Once you run it, it keeps running until next boot so you can use it from dolibarr safely without further action.

If you have shell access you may try to install it from there.

If you cannot install anything outside softaculous and LibreOffice is not in the listing then you have a problem because soffice is not installed by default in most systems but you may try to find it running a find / -name soffice, again, if you have shell access.

Or ask your provider to install it for you.

hussain-attari commented 4 years ago

So I'll have to install soffice first. Will request my service provider to help me out here. Although I know their professional reply.

Thanks for pointing this out Mike. Closing this issue now.

ranasaad08 commented 2 years ago

@h6585 are you able to solve this issue? I have the same issue with me and would appreciate your help.