PHP code example of codeinc / unoconv-webservice-client
1. Go to this page and download the library: Download codeinc/unoconv-webservice-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/ */
codeinc / unoconv-webservice-client example snippets
use CodeInc\UnoconvClient\UnoconvClient;
$client = new UnoconvClient('http://localhost:3000');
// lists supported formats (calls /unoconv/formats)
$client->getFormats();
// list supported format for the graphics type (calls /unoconv/formats/graphics)
$client->getFormats('graphics');
// returns the API server's uptime (calls /healthz)
$client->getHealth();
// returns all versions of installed dependencies lookup (calls /unoconv/versions)
$client->getVersions();
// converts a document
$responseStream = $client->convert($sourceStream, 'pdf');
use CodeInc\UnoconvClient\UnoconvClient;
use GuzzleHttp\Psr7\LazyOpenStream;
$client = new UnoconvClient('http://localhost:3000');
$localFilePath = '/path/to/my/document.docx';
$localFileStream = new LazyOpenStream($localFilePath, 'r');
$responseStream = $client->convert($localFileStream, 'pdf');
header('Content-Type: application/pdf');
echo $responseStream;
use CodeInc\UnoconvClient\UnoconvClient;
use GuzzleHttp\Psr7\LazyOpenStream;
use function GuzzleHttp\Psr7\copy_to_stream;
$client = new UnoconvClient('http://localhost:3000');
$localFilePath = '/path/to/my/document.docx';
$localFileStream = new LazyOpenStream($localFilePath, 'r');
$responseStream = $client->convert($localFileStream, 'pdf');
$pdfFilePath = '/path/to/my/document.pdf';
$pdfFileStream = new LazyOpenStream($pdfFilePath, 'w');
copy_to_stream($responseStream, $pdfFileStream);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.