

This PHP function is called once the Word / Excel file has been uploaded to the server. use Įxec("/opt/adocpdf ", $output, $return_var) The script will create a PDF version of the document in the same directory as the original.įinally, initiating the conversion of a Word / Excel file from within PHP (I have it within a function that checks if the file we are dealing with is a word / excel document). I have used this for months now and the 5s gap seems to give enough breathing room. The delay ("sleep 5s") is used to ensure that has enough to time to initiate if required. The 3 variables on the first three lines are provided when the script is executed from with a PHP file. This checks that the libraries are running and then calls the PyODConverter script to process the file and output it as a PDF. Python /home/website/python/DocumentConverter.py /home/website/$directory$filename$extension /home/website/$directory$filename.pdf usr/bin/soffice -headless -accept="socket,host=127.0.0.1,port=8100 urp " -nofirststartwizard &

I also created a plain text file above the web root (I named it "adocpdf"), with the following command line instructions in it: directory=$1 I created a directory on the server and placed the PyODConverter python file within it. Now that the server has the capability to handle MS Office files you are able to convert the files by executing command line instructions via PHP. I requested my hosting provider to install the open office RPM on my VPS. The first thing that is required is to install on the server. Apologies if I missed any details, it's been a while since I worked on this solution. I found a solution to my issue and after a request, will post it here to help others.
