1. Go to this page and download the library: Download yowfung/officetopdf 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/ */
yowfung / officetopdf example snippets
use YowFung\OfficeToPdf\OfficeToPdf;
class Controller
{
public function Example()
{
$outdir = __DIR__.'/../resource/pdfs/'; //输出文件夹
$filedir = __DIR__.'/../resource/docs/';
$filenames = scandir($filedir); //待转换文件
$office = new OfficeToPdf($filenames, $outdir, true);
$success_row = $office->convertToPdf(); //执行转换操作
echo '成功转换'.$success_row.'个文件。';
}
}
$office = new OfficeToPdf();
$office->setOutputDir('directory path...');