eurechasherij/office-converter-windows

Windows上LibreOffice的PHP包装器

v1.0.2 2022-08-25 04:12 UTC

This package is auto-updated.

Last update: 2024-09-25 08:47:12 UTC


README

Windows上LibreOffice的PHP包装器

使用LibreOffice或OpenOffice将办公文件转换为PDF和HTML。支持的转换格式包括

  • pptx => pdf
  • ppt => pdf
  • pdf => pdf
  • docx => pdf, odt, html
  • doc => pdf, odt, html
  • xlsx => pdf
  • xls => pdf
  • png => pdf
  • jpg => pdf
  • jpeg => pdf

安装

建议通过Composer安装OfficeConverter。

在您的项目目录下运行此命令

composer require ncjoes/office-converter

依赖项

为了使用OfficeConverter,您需要安装LibreOffice

用法

以下是一些示例。

<?php
// if you are using composer, just use this
use EurechaSherij\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许可证

反馈与贡献

通知我任何问题、错误或改进。谢谢 👍

分支自: https://github.com/ncjoes/office-converter