PHP code example of ngekoding / office-to-pdf

1. Go to this page and download the library: Download ngekoding/office-to-pdf 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/ */

    

ngekoding / office-to-pdf example snippets




// Include autoloader
onverter;

$converter = new Converter();
$converter->convert('path/to/file.docx');

$converter = new Converter();
$converter->setTimeout(3600);

$converter = new Converter('path/to/libreoffice');

$converter = new Converter();
$converter->convert('path/to/file.docx', './pdf-outputs');

// The result filename will be result.pdf in the same directory as the source file
$converter->convert('path/to/file.docx', 'result.pdf');

// Or save to spesific directory
$converter->convert('path/to/file.docx', './pdf-outputs/result.pdf');