I was searching for library that convert my doc files into pdf files. So, I have found Phpword wth Tcpdf library.
I am using this library to convert my doc or docx file into PDF. File conversion is ok but I am passing through a very major issue into this conversion. This library is removing all styles and text formatting that was applied in doc files after converting into pdf file.
Below is code for conversion:
$objReader = \PhpOffice\PhpWord\IOFactory::createReader();
$phpWord = $objReader->load('test.docx');
$rendererName = \PhpOffice\PhpWord\Settings::PDF_RENDERER_TCPDF;
$rendererLibrary = base_path('vendor/phpoffice/phpword/src/PhpWord/Writer/PDF');
$rendererLibraryPath = '' . $rendererLibrary;
if (!\PhpOffice\PhpWord\Settings::setPdfRenderer($rendererName, $rendererLibraryPath)) {
die(
'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
'<br />' .
'at the top of this script as appropriate for your directory structure'
);
}
//$rendererLibraryPath = '' . $rendererLibrary;
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'PDF');
$objWriter->save("test.pdf");
I am using this functionality within Laravel framework. Can anyone please help for how can retain all styles and formatting while converting it into pdf file?
Is there any other library available in market to do the same.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2IbA7bQ
via IFTTT
Aucun commentaire:
Enregistrer un commentaire