参考seafile文档
linux环境
apt-get install libreoffice libreoffice-headless
sudo apt-get install ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy
soffice --headless --invisible --convert-to pdf /tmp/abc.docx --outdir /tmp/
windows环境
php启用com扩展
添加:extension=com_dotnet.dll
去除注释:com.allow_dcom = true
$doc = dirname(__FILE__) . "/index.doc";
$pdf = dirname(__FILE__) . "/index.pdf";
$word = new COM("Word.Application") or die ("Could not initialise Object.");
// 或者 $dd = $word = new COM("Word.Application") or die ("Could not initialise Object.");
// set it to 1 to see the MS Word window (the actual opening of the document)
$word->Visible = 0;
// recommend to set to 0, disables alerts like "Do you want MS Word to be the default .. etc"
$word->DisplayAlerts = 0;
// open the word 2007-2013 document
$word->Documents->Open($doc);
$word->ActiveDocument->ExportAsFixedFormat($pdf, 17, false, 0, 0, 0, 0, 7, true, true, 2, true, true, false);
// quit the Word process
$word->Quit(false);
赞助一杯咖啡☕️
本文由 widdy 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: Jul 23, 2020 at 05:08 pm