Convert Word doc docx and Excel xls xlsx to PDF with PHP

0 votes
I'm trying to figure out how to use PHP to convert Word and Excel files to PDF.

I need to be able to integrate files in different formats into one document, which is why I'm doing this. I'm confident that if I can convert everything to PDF, I can utilize PDFMerger to combine the PDFs into a single file (which uses pdf).

I'm already able to convert various pictures and file kinds to PDFs, but I'm limited to Word Docs. (I believe that using the PHPExcel module, which I already use to generate Excel files from HTML code, I might be able to convert the Excel files.)

If there is a way to create image (jpg) files from the Word documents, that would be workable.
Nov 20 in Others by Kithuzzz
• 20,660 points
30 views

1 answer to this question.

0 votes

After receiving a request, I'll put the resolution I found here to assist others. It's been a while since I worked on this solution, so I apologise if I missed any important information.

Installing OpenOffice.org on the server is the first step that must be taken. I asked my web host to set up the open office RPM on my VPS. You can accomplish this simply through WHM.

You can convert the files by running command line instructions through PHP now that the server can handle MS Office files. For this, I discovered PyODConverter: https://github.com/mirkonasato/pyodconverter

I created a directory on the server and placed the PyODConverter python file within it. 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
filename=$2
extension=$3
SERVICE='soffice'
if [ "`ps ax|grep -v grep|grep -c $SERVICE`" -lt 1 ]; then 
unset DISPLAY
/usr/bin/soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard & 
sleep 5s
fi
python /home/website/python/DocumentConverter.py /home/website/$directory$filename$extension /home/website/$directory$filename.pdf
answered Nov 20 by narikkadan
• 37,660 points

Related Questions In Others

0 votes
1 answer

Convert Excel to PDF issue with documents4j

MS Excel may not always be used ...READ MORE

answered Sep 26 in Others by narikkadan
• 37,660 points
164 views
0 votes
1 answer

Merge and export Excel/Word/PDF to PDF

Use GroupDocs.Merger for .NET API to merge Word, Excel, ...READ MORE

answered Oct 3 in Others by narikkadan
• 37,660 points
74 views
0 votes
1 answer
0 votes
1 answer

Convert an excel file (xls,xlsx) for PDF

Try this: import java.io.FileInputStream; import ...READ MORE

answered Nov 6 in Others by narikkadan
• 37,660 points
39 views
0 votes
1 answer

How to upload excel file to php server from <input type="file">

You first need to upload the file ...READ MORE

answered Jun 9 in JQuery by gaurav
• 22,040 points
1,728 views
0 votes
0 answers

PHP import Excel into database (xls & xlsx)

One of the plugins I looked for ...READ MORE

Jul 30 in PHP by Kithuzzz
• 20,660 points
326 views
0 votes
1 answer

Online Excel Web-based Platform

You can use any of the following ...READ MORE

answered Sep 24 in Others by narikkadan
• 37,660 points
38 views
0 votes
1 answer

Codeigniter convert excel file to pdf

This is a basic php script for ...READ MORE

answered Sep 27 in Others by narikkadan
• 37,660 points
156 views
0 votes
1 answer

Convert Excel and Word files to PDF Using ruby

 You can combine some: For excel files - ...READ MORE

answered Sep 26 in Others by narikkadan
• 37,660 points
119 views
0 votes
1 answer

Convert csv- or Excel-file (xlsx) to kml with custom markers

With some help from the community, I ...READ MORE

answered Sep 26 in Others by narikkadan
• 37,660 points
86 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP