eurechasherij/office-converter-windows

PHP Wrapper for LibreOffice on Windows

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

This package is auto-updated.

Last update: 2024-05-25 08:09:51 UTC


README

PHP Wrapper for LibreOffice on Windows

Convert offices files to PDF and HTML using LibreOffice or OpenOffice. Supported conversion formats include:

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

Installation

It is recommended to install OfficeConverter through Composer.

Run this command within your project directory

composer require ncjoes/office-converter

Dependencies

In order to use OfficeConverter, you need to install LibreOffice.

Usage

Here are some samples.

<?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');
?>

License

The OfficeConverter package is open-sourced software licensed under the MIT license.

Feedback & Contribute

Notify me of any issues, bugs, or improvements. Thanks 👍

Forked from : https://github.com/ncjoes/office-converter