How to convert word to pdf using PHP on linux platform

藏色散人
Release: 2023-03-04 16:46:02
Original
3571 people have browsed it

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
Copy after login

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 –tlnCheck 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. Downloadjodconverter-2.2.2Download address https://sourceforge.net/projects/jodconverter/files/

2. Unzip in linuxjodconverter-2.2.2.zip

unzip /opt/jodconverter-2.2.2.zip -d /opt
Copy after login

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
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!