Skip to content

breadlesscode/office-converter

Repository files navigation

Office converter (with LibreOffice)

Latest Stable Version Downloads License

This package is for converting office formats to something else. You can generate Thumbnails, PDFs etc..

Requirements

Which extension can be converted to what?

You can check the following files:

Installation

This package can be installed through Composer.

composer require breadlesscode/office-converter

How to use

use \Breadlesscode\Office\Converter;

Converter::file('Test.odt') // select a file for convertion
    ->setLibreofficeBinaryPath('/usr/bin/libreoffice') // binary to the libreoffice binary
    ->setTemporaryPath('./temp') // temporary directory for convertion
    ->setTimeout(100) // libreoffice process timeout
    ->save(__DIR__.'/lorem.pdf'); // save as pdf

Examples

Save with original name in folder

use Breadlesscode\Office\Converter;

Converter::file('./Test.odt')
    ->save('./lorem', 'jpg');

Save with custom name

use Breadlesscode\Office\Converter;

Converter::file('./Test.odt')
    ->save('./lorem.jpg');

Testing

$ composer test

License

The MIT License (MIT). Please see License File for more information.