PHP code example of mrcnpdlk / unoconv-api

1. Go to this page and download the library: Download mrcnpdlk/unoconv-api 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/ */

    

mrcnpdlk / unoconv-api example snippets



use Monolog\Handler\ErrorLogHandler;
use Psr\Log\LogLevel;


$logger->pushHandler(new ErrorLogHandler(ErrorLogHandler::OPERATING_SYSTEM, LogLevel::DEBUG));

// Set default value for handler
$oConfig = new \Mrcnpdlk\Api\Unoconv\Config([
    'binary' => '/usr/bin/unoconv',
    'logger' => $logger,
    'timeout'=> 300
]);
$oApi    = new \Mrcnpdlk\Api\Unoconv\Api($oConfig);

$res     = $oApi->transcode($sourceFile, $format, $destination, $exportOpts);
var_dump($res);

$oApi    = new \Mrcnpdlk\Api\Unoconv\Api($oConfig);

$from = __DIR__ . '/../devel/test.docx';
$res  = $oApi->transcode($from, null, __DIR__, [
    ExportType::PageRange              => '1-1', // page range (string)
    ExportType::Watermark              => 'FOO bar BAZ', // watermark text (string)
    ExportType::Printing               => 0, // printing permission (int)
    ExportType::RestrictPermissions    => true, // restrict permission (bool)
    ExportType::PermissionPassword     => 'password1',
    ExportType::EnableCopyingOfContent => false, // copy permission (bool)
    ExportType::Changes                => 0, // changes permission (int)
    ExportType::DocumentOpenPassword   => 'password2', // password to open file (string)
]);
var_dump($res);

$res     = $oApi->wsGetPdf($sourceFile, $destination);
var_dump($res);