I am looking for a way to convert Word or text files to PDF using PHP.
Or is there a way to create image files from Word documents.
I tried with this code, it is well works in localhost but server side no.
<?php
require_once 'vendor/autoload.php';
require_once 'vendor/phpoffice/phpword/src/PhpWord/PHPWord.php';
$objReader= \PhpOffice\PhpWord\IOFactory::createReader('Word2007');
$contents=$objReader->load("2003.docx");
$rendername= \PhpOffice\PhpWord\Settings::PDF_RENDERER_TCPDF;
$renderLibrary="TCPDF";
$renderLibraryPath=''.$renderLibrary;
if(!\PhpOffice\PhpWord\Settings::setPdfRenderer($rendername,$renderLibrary){
die("Provide Render Library And Path");
}
$renderLibraryPath=''.$renderLibrary;
$objWriter= \PhpOffice\PhpWord\IOFactory::createWriter($contents,'PDF');
$objWriter->save("2003.pdf");
?>