Using Libreoffice in linux can convert office documents (doc, ppt, xls) to pdf files

In some projects, perhaps the word document, excel sheet, and ppt presentation that the user wants to upload can be previewed online, but the office document cannot be previewed online.

However, we can use Libreoffice , an open source software, to convert office documents into pdf files, and then use pdf.js to preview online.

Of course, if the ppt is to be played like a slideshow, then we can also use ImageMagick to convert the pdf file into a picture, and then use various js carousel tools to do it.

 

The commands are used as follows:

Libreoffice converts office documents to ppt files:

wrote
export DISPLAY=:0.0 && libreoffice --headless --invisible --convert-to pdf --outdir ./ ./test.ppt

 

Note: The parameter following --outdir is the directory to output to, and the last parameter is the path where the ppt and other office document files are located. Both relative paths and absolute paths can be executed.

But I found in the project that if you use apache's php to execute, that is, the way of browser access, the php code uses system, exec, etc. to execute this command, and it has no effect. On the command line it does.

 

 

The way to convert the image is as follows:

wrote
convert -density 150 -quality 100 -resize 800 ./test.pdf ./

 

The last two parameters of this parameter are the pdf file path and the image storage directory.

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326569856&siteId=291194637