使用phpword将生成的pdf保存到mysql数据库

时间:2019-02-09 12:19:55

标签: php mysql phpword

我正在尝试使用phpword将生成的pdf保存为分层存储在数据库中,但是无法正确保存。 谁能帮我吗?

这是我的代码:

$temp_file = tempnam(sys_get_temp_dir(), 'Word');
$templateProcessor->saveAS($temp_file);

$domPdfPath = realpath(PHPWORD_BASE_DIR . 'dompdf/dompdf');
\PhpOffice\PhpWord\Settings::setPdfRendererPath($domPdfPath);
\PhpOffice\PhpWord\Settings::setPdfRendererName('DomPDF');

$phpWord = \PhpOffice\PhpWord\IOFactory::load($temp_file); 
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF');
$xmlWriter->save('result.pdf');  

//Save it
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF');
$result = $xmlWriter->save('result.pdf'); 

$pdf = $result;


mysql_connect("localhost","root","") or die("Error Connect to Database");
mysql_select_db("word");
mysql_query("INSERT INTO invoice (id,location) VALUES ('', '$pdf')") ;

0 个答案:

没有答案