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, 2022 in Others by Kithuzzz
• 38,000 points
1,362 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, 2022 by narikkadan
• 63,600 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, 2022 in Others by narikkadan
• 63,600 points
1,533 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, 2022 in Others by narikkadan
• 63,600 points
1,510 views
0 votes
1 answer

How can I convert excel to PDF by Libreoffice and keep all format from excel file?

"Times New Roman" typeface does not have ...READ MORE

answered Oct 3, 2022 in Others by narikkadan
• 63,600 points
1,674 views
0 votes
1 answer

Convert an excel file (xls,xlsx) for PDF

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

answered Nov 6, 2022 in Others by narikkadan
• 63,600 points
1,050 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, 2022 in JQuery by gaurav
• 23,260 points
6,802 views
0 votes
0 answers

PHP import Excel into database (xls & xlsx)

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

Jul 30, 2022 in PHP by Kithuzzz
• 38,000 points
1,490 views
0 votes
1 answer

Online Excel Web-based Platform

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

answered Sep 24, 2022 in Others by narikkadan
• 63,600 points
581 views
0 votes
1 answer

Codeigniter convert excel file to pdf

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

answered Sep 27, 2022 in Others by narikkadan
• 63,600 points
1,883 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, 2022 in Others by narikkadan
• 63,600 points
1,353 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, 2022 in Others by narikkadan
• 63,600 points
1,245 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