1. Go to this page and download the library: Download codeinc/office2pdf-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 / office2pdf-client example snippets
use CodeInc\Office2PdfClient\Office2PdfClient;
use CodeInc\Office2PdfClient\ConvertOptions;
use CodeInc\Office2PdfClient\Format;
$apiBaseUri = 'http://localhost:3000/';
$srcDocPath = '/path/to/local/file.docx';
$destPdfPath = '/path/to/local/file.pdf';
$convertOption = new ConvertOptions(
firstPage: 2,
lastPage: 3,
format: Format::json
);
try {
$client = new Office2PdfClient($apiBaseUri);
// convert
$pdfStream = $client->convert(
$client->createStreamFromFile($srcDocPath),
$convertOption
);
// save the PDF
$client->saveStreamToFile($pdfStream, $destPdfPath);
}
catch (Exception $e) {
// handle exception
}
use CodeInc\Office2PdfClient\Office2PdfClient;
use CodeInc\Office2PdfClient\Exception;
$filename = 'a-file.docx';
$client = new Office2PdfClient('http://localhost:3000/');
$client->isSupported("a-file.docx"); // returns true
$client->isSupported("a-file"); // returns true
$client->isSupported("a-file", false); // returns false (the second argument is the strict mode)
$client->isSupported("a-file.pdf"); // returns false
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.