我正在嘗試使用 mPDF 導(dǎo)入 PDF 文件。PDF 文件是從其他服務(wù)發(fā)送的,我最初的想法是使用wrappers。(最好php://memory)。我得到什么錯(cuò)誤:Warning: filesize(): stat failed for php://memory in /var/www/scrm/modules/AOS_PDF_Templates/PDF_Lib/mpdfi/pdf_parser.php on line 181mPDF error: Cannot open php://memory !(這個(gè)打印到瀏覽器 BTW)我檢查了PDF:顯示在瀏覽器中保存到文件,并從中導(dǎo)入兩者都有效,所以 PDF 不是問題。我檢查了 的內(nèi)容php://memory,它們也是有效的。這是示例代碼://part of the code, $content is defined earlier (.pdf file content)$memoryFile = 'php://memory';$handle = fopen($memoryFile,'r+');fwrite($handle,$content);rewind($handle);/* dump it to string, just to be sure, part of how i was checking that pdf got saved to $memoryFile? ?even with this part removed still doesn't work, so no file issue here$str=? fread($handle,strlen($content)); //str gets filled with expected datarewind($handle); //rewind for use by mPDF*/$pdf = new mPDF;$pdf->SetImportUse();$pagecount = $pdf->SetSourceFile($memoryFile);我想到的解決方案:保存到常規(guī)臨時(shí)文件(我不想這樣做)mPDF 有沒有辦法從字符串中導(dǎo)入文件?(谷歌沒有為我產(chǎn)生任何結(jié)果)操作系統(tǒng):Ubuntu 18.04 WSL,PHP 7.2.31 版,mPDF 5.7.1 版
1 回答

斯蒂芬大帝
TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超8個(gè)贊
至少將您的 mPDF 版本升級(jí)到 8.0.0。
從版本 8 開始,mPDF 使用更新的底層庫(kù) FPDI 2,它通常支持從php://memory
任何流導(dǎo)入文件。
- 1 回答
- 0 關(guān)注
- 213 瀏覽
添加回答
舉報(bào)
0/150
提交
取消