我的一个项目需要将 DOCX 转换为 PDF。我遇到了phpdocx项目,一切都转换得很好,但是它将文件提供给浏览器,在转换后提示用户下载。我需要保留文件,只需读取 MySQL 存储的数据。有任何想法吗?
这是我正在使用的代码:
$docx = new TransformDoc();
$docx ->setStrFile($tmpName);
$docx ->generatePDF();
使用以下 Tim 的修改会产生以下错误:
i
Warning: session_start() [function.session-start]:
Cannot send session cache limiter - headers already sent
(output started at /home/zbtech/public_html/DocCon/classes/TransformDoc.inc:1)
in /home/zbtech/public_html/scribpub.php on line 5
Unable to generate PDF file string. exception 'DOMPDF_Exception' with message
'Unknown image type: files/files_/tmp/phpNQFatu/media/word/.'
in /home/zbtech/public_html/DocCon/pdf/include/image_cache.cls.php:175 Stack trace:
#0 /home/zbtech/public_html/DocCon/pdf/include/image_frame_decorator.cls.php(88):
Image_Cache::resolve_url('files/files_/tm...', NULL, '', '')
#1 /home/zbtech/public_html/DocCon/pdf/include/frame_factory.cls.php(173): Image_Frame_Decorator-
>__construct(Object(Frame), Object(DOMPDF))
#2 /home/zbtech/public_html/DocCon/pdf/include/dompdf.cls.php(499): Frame_Factory::decorate_frame
(Object(Frame), Object(DOMPDF)) #3 /home/zbtech/public_html/DocCon/classes/TransformDoc.inc
(282): DOMPDF->render() #4 /home/zbtech/public_html/scribpub.php(68): TransformDoc->generatePDF
() #5 {main}