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:
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:
The last two parameters of this parameter are the pdf file path and the image storage directory.