Edit word files and convert to PDF php

Asked

Viewed 649 times

-1

I have a document and every time I need to change information in it I need to do all this procedure that I will explain lowers again, I would like a solution that would make it easier to convert Word to PDF.

Problem: I have a system of proposals that has "templates" in Word documents for every proposal we have need to be changed depending on the proposal, these documents have text pictures, tables, etc.

Resolution: What I did to resolve the problem was to convert Word documents to .odt and then open them with PHP and replace the strings I want.

The problem I have at the moment is that when there is a change in a document I have to convert again and put all the strings on the right site that takes a lot of time, because the documents are on average 18 pages.

Does anyone know any way to alter documents more quickly and effectively to later be generated the PDF of the same.

At first I thought to use the tcpdf library but it would take much longer to pass everything that is in the documents to PDF, the solution I present was the fastest I could but it is still very time consuming.

1 answer

-1

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

https://github.com/mirkonasato/pyodconverter

  • 2

    Hello @Anderson. Try creating an example of how to use, why does your solution fit the AP case? For questions about how the answer template works, see []

  • Thank you for the reply at this time already use that system my question is not in the conversation to PDF.. But how to edit word documents simply and quickly through PHP in k I am currently using Str_replace

Browser other questions tagged

You are not signed in. Login or sign up in order to post.