PHP code example of mops1k / unoserver-client

1. Go to this page and download the library: Download mops1k/unoserver-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mops1k / unoserver-client example snippets



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


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