iT邦幫忙

0

TCPDF 圖片問題

  • 分享至 

  • xImage
$img_base64_encoded = $row_sign_check['landlord_sign'];
$imageContent = file_get_contents($img_base64_encoded);
$path = tempnam(sys_get_temp_dir(), 'prefix');
file_put_contents ($path, $imageContent);
$landlord_sign = '<img src="'.$path.'">';


// $tenant_sign = $pdf->Image('@'.$images);

// Set some content to print
$html = <<<EOD
$landlord_sign
EOD;

想請問為甚麼我這段再local端測試都沒問題,圖片會照常顯示,但是放到server端上卻不會顯示,也沒有抱錯,謝謝

WQ iT邦新手 2 級 ‧ 2019-12-27 11:06:05 檢舉
確認圖片有放在路徑裡嗎?
豬豬人 iT邦新手 4 級 ‧ 2019-12-27 11:14:23 檢舉
base64
WQ iT邦新手 2 級 ‧ 2019-12-27 13:41:27 檢舉
看起來您應該是要先寫成HTML再轉到PDF...
我的寫法是這樣,請參考

$img = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCAAgACADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBA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LCLdpGlUq3mZ4dmJ5B4XGRkV9A+H7vUPGH9jQ6lLY3B0+CC71GbTHLWs94UDxpETyUXIl59Yvevl3R/+CedrY6pa3Fzcz30MUgdrae8RY5MHO1isRO098c47jrX2T4b0OLw7o9vYxkOyDdJIFC+Y5OWbA4GT0A4AwBwK0x2Fy2jOKy6rKaesrx5UtrJJpb9en3nn4rNsTnFOlQxMFaG8mmpSV21Ft76u+22jvc//2Q==';
$landlord_sign = '<img src="'.$img.'">';
$html = $landlord_sign;//<--可以串其它的HTML
$pdf->writeHTML($html, true, 0, true, 0);

我這樣就執行出來了~
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答