0
我一直在試圖通過電子郵件發送一個包含fieldname-value列表的表。當我達到圖像值時,我濾除圖像字符串以用於tcpdf圖像輸出。我做了一個條件,如果data:image/png被發現,它應該被刪除。否則,請刪除數據:image/jpeg。php tcpdf圖像字符串過濾器
$pdf->writeHTMLCell(50, 0, '', '', "{$fieldname}", 1, 0, 0, true, 'R', true);
$base64 = strpos("data:image/png", $col_value) ? str_replace("data:image/png;base64,", "", $field_value) : str_replace("data:image/jpeg;base64,", "", $field_value);
$imgdata = base64_decode($base64);
$pdf->Image('@'.$imgdata, '', '', 0,65, '', '', 'B', false, 300, 'R');
$pdf->writeHTMLCell(0, 10, '', '', "", 1, 1, 0, true, '', true);
導致:
TCPDF ERROR: [Image] Unable to get the size of the image: @
沒有條件/做一個的if/else爲$的base64值,我沒有得到錯誤。但是我的base64不會像兩種類型那樣靈活。