1. Go to this page and download the library: Download michaeld555/pdf-converter 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/ */
michaeld555 / pdf-converter example snippets
use Michaeld555\PdfConverter\Converter;
$converter = new Converter();
$converter->convert('/data/input.docx', '/data/output.pdf');
use Michaeld555\PdfConverter\Converter;
use Michaeld555\PdfConverter\Driver\LibreOfficeConverter;
$driver = new LibreOfficeConverter(
binary: '/usr/bin/libreoffice',
timeout: 120.0,
overwrite: false,
temporaryDirectory: '/var/tmp/pdf-converter',
);
$converter = new Converter($driver);
$converter->convert('/data/input.docx', '/data/output.pdf');
use Michaeld555\PdfConverter\Converter;
use Michaeld555\PdfConverter\Exception\ConversionException;
try {
(new Converter())->convert('/data/input.docx', '/data/output.pdf');
} catch (ConversionException $exception) {
error_log($exception->getMessage());
}
public function __construct(?DocumentConverter $driver = null)
public function convert(string $source, string $destination): void
public function __construct(
string $binary = 'libreoffice',
float $timeout = 60.0,
bool $overwrite = false,
?ProcessRunner $processRunner = null,
?string $temporaryDirectory = null,
)
public function convert(string $source, string $destination): void
use Michaeld555\PdfConverter\Contract\DocumentConverter;
use Michaeld555\PdfConverter\Converter;
final class CompanyConverter implements DocumentConverter
{
public function convert(string $source, string $destination): void {}
}
$converter = new Converter(new CompanyConverter());