Converting xlsx, docx, pdf files as jpg images using PHP

本小妞迷上赌 提交于 2019-12-12 03:07:13

问题


Is there any way to convert xlsx, docx and pdf files to image(jpg) format programtically using PHP? I need to read this files from a server and convert them as images and show on page.

Thanks in adv


回答1:


If you want to achieve this you must first convert your xlsx or docx to pdf

The best way to do it is to install libreoffice on your server.

Then use the headless command of libreoffice to perform the conversion to pdf

shell_exec('libreoffice --headless -convert-to pdf fileToConvert.docx -outdir output/path/for/pdf');

Then convert your pdf to jpg

shell_exec('/usr/local/bin/convert myfile.pdf myfile.jpg ');


来源:https://stackoverflow.com/questions/29077910/converting-xlsx-docx-pdf-files-as-jpg-images-using-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!