问题
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