Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 5 使用PHPWord和TCPDF将文档、docx转换为PDF文件时丢失样式和格式_Laravel 5_Pdf Generation_Tcpdf_Phpword - Fatal编程技术网

Laravel 5 使用PHPWord和TCPDF将文档、docx转换为PDF文件时丢失样式和格式

Laravel 5 使用PHPWord和TCPDF将文档、docx转换为PDF文件时丢失样式和格式,laravel-5,pdf-generation,tcpdf,phpword,Laravel 5,Pdf Generation,Tcpdf,Phpword,我正在搜索将我的文档文件转换为pdf文件的库。所以,我找到了带有Tcpdf库的Phpword 我正在使用此库将我的文档或docx文件转换为PDF。文件转换是可以的,但我正在通过一个非常重要的问题进入这个转换。此库正在删除转换为pdf文件后应用于文档文件的所有样式和文本格式 以下是转换代码: $objReader=\PhpOffice\PhpWord\IOFactory::createReader() $phpWord=$objReader->load('test.docx'); $rendere

我正在搜索将我的文档文件转换为pdf文件的库。所以,我找到了带有Tcpdf库的Phpword

我正在使用此库将我的文档或docx文件转换为PDF。文件转换是可以的,但我正在通过一个非常重要的问题进入这个转换。此库正在删除转换为pdf文件后应用于文档文件的所有样式和文本格式

以下是转换代码:

$objReader=\PhpOffice\PhpWord\IOFactory::createReader()

$phpWord=$objReader->load('test.docx');
$rendererName=\PhpOffice\PhpWord\Settings::PDF\u RENDERER\u TCPDF;
$rendererLibrary=base_路径('vendor/phpoffice/phpword/src/phpword/Writer/PDF');
$renderLibraryPath=''$渲染器库;
if(!\PhpOffice\PhpWord\Settings::setPdfRenderer($rendername,$renderLibraryPath)){
死(
'注意:请设置$RenderName和$RenderLibraryPath值'。
“
”。 '在此脚本的顶部,以适合您的目录结构' ); } //$renderLibraryPath=''$渲染器库; $objWriter=\PhpOffice\PhpWord\IOFactory::createWriter($PhpWord,'PDF'); $objWriter->save(“test.pdf”);
我正在Laravel框架中使用此功能。任何人都可以在转换为pdf文件时,如何保留所有样式和格式


市场上还有其他图书馆可以这样做吗。

我也有同样的问题。我丢失了所有编号/项目符号,甚至间距。
    $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");