Home  >  Article  >  Backend Development  >  How to convert word to pdf using PHP on linux platform

How to convert word to pdf using PHP on linux platform

藏色散人
藏色散人Original
2020-08-18 09:11:163609browse

How to convert linux php word to pdf: first install openoffice; then enter the RPMS directory and execute the "rpm –ivh *rpm" command; then start OpenOffice; and finally achieve the conversion by calling the jodconverter method.

How to convert word to pdf using PHP on linux platform

Recommended: "PHP Video Tutorial"

1. Searching for information online is nothing more than the com component of openoffice PHP. However, I tried many times but it was not reliable

2. Later I found openoffice jodconverter (requires java environment)

1. Install openoffice

1. Attached is the openoffice download link https://www.openoffice.org/download/index.html

2. Download your own corresponding Linux version. I chose the Red Hat version

3. The decompressed directory is zh-CN, which contains RPMS, readmes, and licenses.

4. Enter the RPMS directory

5. Execute rpm –ivh *rpm (install all rpm files)

6. Enter the desktop-integration directory and select the installation related Suite, I chose redhat

rpm -ivh openoffice4.1.5-redhat-menus-4.1.5-9789.noarch.rpm

7. OpenOffice has been installed and will be installed under /opt by default

Start OpenOffice

soffice -headless -accept=”socket,host=127.0.0.1,port=8100:urp;” -nofirststartwizard &

After starting, enter program againnetstat –tln Check whether the startup is successful! As shown in the picture above, port 8100 can be used.

Stop Openoffice

  • Check ps -ef|grep soffice process
  • Check Kill process kill -9 4119/4119

2. Install jodconverter

1. Download jodconverter-2.2.2 Download address https://sourceforge.net/projects/jodconverter/files/

2. Unzip in linux jodconverter-2.2.2.zip

unzip /opt/jodconverter-2.2.2.zip -d /opt

3. Call the jodconverter method to convert word->pdf

java -jar /opt/jodconverter-2.2.2/lib/jodconverter-cli-2.2.2.jar ./1.docx ./1.pdf

The above is the detailed content of How to convert word to pdf using PHP on linux platform. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn