digitalideastudio / office-converter
LibreOffice的PHP包装器
1.0.2
2019-11-20 13:26 UTC
Requires
- php: >=5.4.4
Requires (Dev)
- phpunit/phpunit: 7.*
README
LibreOffice的PHP包装器
使用LibreOffice或OpenOffice将办公文件转换为PDF和HTML。支持的转换格式包括
- pptx => pdf
- ppt => pdf
- pdf => pdf, html
- html => txt
- docx => pdf, odt, html
- doc => pdf, odt, html
- xlsx => pdf
- xls => pdf
- png => pdf
- jpg => pdf
- jpeg => pdf
- tiff => pdf
- tif => pdf
- pps => pdf
- ppsx => pdf
安装
建议通过Composer安装OfficeConverter。
在您的项目目录中运行以下命令
composer require digitalideastudio/office-converter
依赖
为了使用OfficeConverter,您需要安装LibreOffice。
Ubuntu 18.04.2 LTS的示例
apt-get update
apt-get install --no-install-recommends -y ghostscript openjdk-11-jre-headless:amd64 libreoffice
用法
以下是一些示例。
<?php // if you are using composer, just use this use NcJoes\OfficeConverter\OfficeConverter; $converter = new OfficeConverter('test-file.docx'); $converter->convertTo('output-file.pdf'); //generates pdf file in same directory as test-file.docx $converter->convertTo('output-file.html'); //generates html file in same directory as test-file.docx //to specify output directory, specify it as the second argument to the constructor $converter = new OfficeConverter('test-file.docx', 'path-to-outdir'); ?>
许可证
OfficeConverter软件包是开源软件,采用MIT许可证。
反馈 & 贡献
通知我任何问题、错误或改进。谢谢 👍