mops1k/unoserver-client

PHP client for unoserver(ex. unoconv) converter.

v0.0.2 2024-07-07 13:27 UTC

This package is auto-updated.

Last update: 2024-11-07 14:12:01 UTC


README

Simple library to run unoconvert inside your php applications.

Installation

composer require mops1k/unoserver-client

Usage example

  1. From document:
<?php
use Unoserver\Converter\ClientBuilder;
use Unoserver\Converter\Wrapper\Remote;
use Unoserver\Converter\Source\Format;

$builder = new ClientBuilder();
$builder->init(Remote::class, [
    'command' => '/usr/bin/unoconvert', // path to unoconvert binary
    'host' => '127.0.0.1', // remote unoserver host
    'port' => 2003, // remote unoserver port
]);
$client = $builder->fromDocument('/document/path.docx'); // set path to file convert from
$client->toFormat(Format::PDF); // set format to convert to
$file = $client->convert(); // will return \SplFileInfo object with converted file
  1. From spreadsheet:
<?php
use Unoserver\Converter\ClientBuilder;
use Unoserver\Converter\Wrapper\Remote;
use Unoserver\Converter\Source\Format;

$builder = new ClientBuilder();
$builder->init(Remote::class, [
    'command' => '/usr/bin/unoconvert', // path to unoconvert binary
    'host' => '127.0.0.1', // remote unoserver host
    'port' => 2003, // remote unoserver port
]);
$client = $builder->fromSpreadsheet('/document/path.xlsx'); // set path to file convert from
$client->toFormat(Format::PDF); // set format to convert to
$file = $client->convert(); // will return \SplFileInfo object with converted file

More docs soon...