Home >Backend Development >PHP Problem >How to convert php word to pdf under linux

How to convert php word to pdf under linux

藏色散人
藏色散人Original
2020-09-01 09:22:273214browse

How to convert PHP word to PDF under Linux: first install openoffice; then enter the RPMS directory and execute the command "rpm –ivh *rpm"; then choose to install the relevant packages and start OpenOffice; finally implement it through the jodconverter method Just convert.

How to convert php word to pdf under linux

Recommended: "PHP Video Tutorial"

Linux platform PHP to realize word to pdf

1. Searching for information on the Internet is nothing more than the COM component of openoffice PHP, but it is not reliable after trying many times

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

一, Install openoffice

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

2. Download your own The Linux version I chose is 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

4. If Chinese garbled characters appear (Chinese is not displayed), please refer to: Solution to the problem of converting openoffice word files to PDF Chinese garbled characters under Linux

The above is the detailed content of How to convert php word to pdf under linux. 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