TCPDF 对 base64 图像有限制吗?
Does TCPDF have limits on base64 images?
我正在将 TCPDF 安装从 4.9 版升级到 6.4.2 版,发现 base64 图像有一个奇怪的行为。
https://tcpdf.org/examples/example_009/ 中的示例图像正确加载了 base64“PHP 规则”图像,但我无法显示任何其他有效的 base64 图像。相反,我看到的是没有图像的空白 PDF 页面。
我缩小了 TCPDF 文档中的示例 009 以找出问题:
这会加载“PHP 规则”图像
require_once('tcpdf_include.php');
$pdf = new TCPDF();
$pdf->AddPage();
$img_encoded = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABlBMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDrEX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg==';
$imgdata = base64_decode($img_encoded);
$pdf->Image('@'.$imgdata);
$pdf->Output('example_009.pdf', 'I');
这会生成空白 PDF 页面,而不是添加卷曲绘图:
require_once('tcpdf_include.php');
$pdf = new TCPDF();
$pdf->AddPage();
$img_encoded ='iVBORw0KGgoAAAANSUhEUgAAAZAAAACWCAYAAADwkd5lAAAI2UlEQVR4nO3dMW8cxxUAYP0E/gT9AJv7JN/OrIAAYm0EIEt3YhGktVwGCGB2MZDCRKp0ZpO0YpMmhaUfYEAsXKQJKATpUpCAgTg2nFyKveXt3h1pUhI5e7zvAxYiyDvqiRT27cy8N/PgAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABsvDrqePKofvrkUf20ieZh6XgAGIkmmodNTHZy5N0m0uc50osm8ssc6ayJPL3ietm+Pu9KLABrLCK2hqOF9CxH/rSJ9Hl35UgvZtdxE/n0ZxLEtIk8zZHOm0ivcqST9uPl16Qq/SdHOstRf5kj70bEVumfBwCXqKOONjHkl9dJBIOkUKV/dMmhTQz5uIl0lCM/b6Leb2Kyc1US6EYtTaSDHPk4V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88bZV+kjyA0Zlv5Z6nOZLu5ju2tA9Wlb5fnLayaA6M0uJUSel4NtGK42t/ti8EoDgJpLyI2FrcD8t5H8DoLSYQc+1lRMRWrtK3uUrTHPW/JQ9g9Ja30jDfDsA1XHcvJgAYWN4m4/LDjADgwk3OowCAgYUSUueiA3A9OdLJdY9UBYALuUpfD0Yh25NPSscEwBpI1eSP/S3FrzpWFQAuLJfy5tPSMQGwBpYrsfK0ifxV6bgAWAOLC+lN5Gmq6i9KxwXAyDUx2Vnc0C9HmuZIZznSiyeP6qelYwRgpPpd6cMtxS92h7W4DsBqjz94vN1EfbRqSitHPi4dHwBrIiK22iNW04EGQwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4DL/B7EdVIEgTgUAAAAAAElFTkSuQmCC';
$imgdata = base64_decode($img_encoded);
$pdf->Image('@'.$imgdata);
$pdf->Output('example_009.pdf', 'I');
我已经验证了 base64 代码 (https://base64.guru/converter/decode/image) 并且完整的 base64 图像在浏览器中正确加载:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAACWCAYAAADwkd5lAAAI2UlEQVR4nO3dMW8cxxUAYP0E/gT9AJv7JN/OrIAAYm0EIEt3YhGktVwGCGB2MZDCRKp0ZpO0YpMmhaUfYEAsXKQJKATpUpCAgTg2nFyKveXt3h1pUhI5e7zvAxYiyDvqiRT27cy8N/PgAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABsvDrqePKofvrkUf20ieZh6XgAGIkmmodNTHZy5N0m0uc50osm8ssc6ayJPL3ietm+Pu9KLABrLCK2hqOF9CxH/rSJ9Hl35UgvZtdxE/n0ZxLEtIk8zZHOm0ivcqST9uPl16Qq/SdHOstRf5kj70bEVumfBwCXqKOONjHkl9dJBIOkUKV/dMmhTQz5uIl0lCM/b6Leb2Kyc1US6EYtTaSDHPk4VenvKxLPixx59y5/JgBcop1qqr9c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5ju2tA9Wlb5fnLayaA6M0uJUSel4NtGK42t/ti8EoDgJpLyI2FrcD8t5H8DoLSYQc+1lRMRWrtK3uUrTHPW/JQ9g9Ja30jDfDsA1XHcvJgAYWN4m4/LDjADgwk3OowCAgYUSUueiA3A9OdLJdY9UBYALuUpfD0Yh25NPSscEwBpI1eSP/S3FrzpWFQAuLJfy5tPSMQGwBpYrsfK0ifxV6bgAWAOLC+lN5Gmq6i9KxwXAyDUx2Vnc0C9HmuZIZznSiyeP6qelYwRgpPpd6cMtxS92h7W4DsBqjz94vN1EfbRqSitHPi4dHwBrIiK22iNW04EGQwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4DL/B7EdVIEgTgUAAAAAAElFTkSuQmCC
这会生成空白 PDF 页面,而不是添加绿色方块:
require_once('tcpdf_include.php');
$pdf = new TCPDF();
$pdf->AddPage();
$img_encoded ='iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAANklEQVR42u3OQQ0AAAgEoDO50TWFmw9IQGXSeawEBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQVvLDGRO9mhGZRRAAAAAElFTkSuQmCC';
$imgdata = base64_decode($img_encoded);
$pdf->Image('@'.$imgdata);
$pdf->Output('example_009.pdf', 'I');
我已经验证了 base64 代码 (https://base64.guru/converter/decode/image) 并且完整的 base64 图像在浏览器中正确加载:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAACWCAYAAADwkd5lAAAI2UlEQVR4nO3dMW8cxxUAYP0E/gT9AJv7JN/OrIAAYm0EIEt3YhGktVwGCGB2MZDCRKp0ZpO0YpMmhaUfYEAsXKQJKATpUpCAgTg2nFyKveXt3h1pUhI5e7zvAxYiyDvqiRT27cy8N/PgAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABsvDrqePKofvrkUf20ieZh6XgAGIkmmodNTHZy5N0m0uc50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KPzqvBShuuNurBHLXlhfQVy+M58iH8wSS/3rHYQIsk0DKSlX6Wz+BrGoe7G+1r/oKGI3hzUkCuWs50jfdIVF5RWXVsGzX4jkwIhJIWcNtZIYJpI769/0TCK9qMAS4c/pAylpeA2kXxxcX13Okcwd9AaOStyef9Kp7/lk6nk2zfGRtvb88bZV+kjyA0Zlv5Z6nOZLu5ju2tA9Wlb5fnLayaA6M0uJUSel4NtGK42t/ti8EoDgJpLyI2FrcD8t5H8DoLSYQc+1lRMRWrtK3uUrTHPW/JQ9g9Ja30jDfDsA1XHcvJgAYWN4m4/LDjADgwk3OowCAgYUSUueiA3A9OdLJdY9UBYALuUpfD0Yh25NPSscEwBpI1eSP/S3FrzpWFQAuLJfy5tPSMQGwBpYrsfK0ifxV6bgAWAOLC+lN5Gmq6i9KxwXAyDUx2Vnc0C9HmuZIZznSiyeP6qelYwRgpPpd6cMtxS92h7W4DsBqjz94vN1EfbRqSitHPi4dHwBrIiK22iNW04EGQwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4DL/B7EdVIEgTgUAAAAAAElFTkSuQmCC
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAANklEQVR42u3OQQ0AAAgEoDO50TWFmw9IQGXSeawEBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQVvLDGRO9mhGZRRAAAAAElFTkSuQmCC
我从一些帖子中知道有人推荐 标签然后写成 HTML,尽管我希望直接使用 base64 图像作为图像。
关于为什么示例中的 base64 有效,但所有其他的都失败的任何想法?
这是 K_PATH_CACHE
变量的文件夹问题。
通过更多实验,我发现任何 PNG 文件都不会添加到让我查看 tcpdf.php 文件的 PDF 中。这导致错误日志并最终导致常量 K_PATH_CACHE.
imgpng()
函数使用 K_PATH_CACHE 在 PHP 安装(通过 AWS Lightsail 的 Bitnami)中定义 /tmp 的位置,但位置定义不正确。
K_PATH_CACHE 的默认值设置为 /opt/bitnami/php/tmp
,但该文件夹为空。实际的 tmp 文件夹位于 /tmp
.
为了解决这个问题,我将 K_PATH_CACHE 的位置重新定义为在其他所有内容之前加载的配置文件中的实际 /tmp 目录:
define('K_PATH_CACHE', '/tmp/');
现在可以从 base64 字符串和文件形式加载 PNG。
我希望这可以节省几个小时的搜索时间!
我正在将 TCPDF 安装从 4.9 版升级到 6.4.2 版,发现 base64 图像有一个奇怪的行为。
https://tcpdf.org/examples/example_009/ 中的示例图像正确加载了 base64“PHP 规则”图像,但我无法显示任何其他有效的 base64 图像。相反,我看到的是没有图像的空白 PDF 页面。
我缩小了 TCPDF 文档中的示例 009 以找出问题:
这会加载“PHP 规则”图像
require_once('tcpdf_include.php');
$pdf = new TCPDF();
$pdf->AddPage();
$img_encoded = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABlBMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDrEX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg==';
$imgdata = base64_decode($img_encoded);
$pdf->Image('@'.$imgdata);
$pdf->Output('example_009.pdf', 'I');
这会生成空白 PDF 页面,而不是添加卷曲绘图:
require_once('tcpdf_include.php');
$pdf = new TCPDF();
$pdf->AddPage();
$img_encoded ='iVBORw0KGgoAAAANSUhEUgAAAZAAAACWCAYAAADwkd5lAAAI2UlEQVR4nO3dMW8cxxUAYP0E/gT9AJv7JN/OrIAAYm0EIEt3YhGktVwGCGB2MZDCRKp0ZpO0YpMmhaUfYEAsXKQJKATpUpCAgTg2nFyKveXt3h1pUhI5e7zvAxYiyDvqiRT27cy8N/PgAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABsvDrqePKofvrkUf20ieZh6XgAGIkmmodNTHZy5N0m0uc50osm8ssc6ayJPL3ietm+Pu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y+M58iH8wSS/3rHYQIsk0DKSlX6Wz+BrGoe7G+1r/oKGI3hzUkCuWs50jfdIVF5RWXVsGzX4jkwIhJIWcNtZIYJpI769/0TCK9qMAS4c/pAylpeA2kXxxcX13Okcwd9AaOStyef9Kp7/lk6nk2zfGRtvb88bZV+kjyA0Zlv5Z6nOZLu5ju2tA9Wlb5fnLayaA6M0uJUSel4NtGK42t/ti8EoDgJpLyI2FrcD8t5H8DoLSYQc+1lRMRWrtK3uUrTHPW/JQ9g9Ja30jDfDsA1XHcvJgAYWN4m4/LDjADgwk3OowCAgYUSUueiA3A9OdLJdY9UBYALuUpfD0Yh25NPSscEwBpI1eSP/S3FrzpWFQAuLJfy5tPSMQGwBpYrsfK0ifxV6bgAWAOLC+lN5Gmq6i9KxwXAyDUx2Vnc0C9HmuZIZznSiyeP6qelYwRgpPpd6cMtxS92h7W4DsBqjz94vN1EfbRqSitHPi4dHwBrIiK22iNW04EGQwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4DL/B7EdVIEgTgUAAAAAAElFTkSuQmCC';
$imgdata = base64_decode($img_encoded);
$pdf->Image('@'.$imgdata);
$pdf->Output('example_009.pdf', 'I');
我已经验证了 base64 代码 (https://base64.guru/converter/decode/image) 并且完整的 base64 图像在浏览器中正确加载:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAACWCAYAAADwkd5lAAAI2UlEQVR4nO3dMW8cxxUAYP0E/gT9AJv7JN/OrIAAYm0EIEt3YhGktVwGCGB2MZDCRKp0ZpO0YpMmhaUfYEAsXKQJKATpUpCAgTg2nFyKveXt3h1pUhI5e7zvAxYiyDvqiRT27cy8N/PgAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABsvDrqePKofvrkUf20ieZh6XgAGIkmmodNTHZy5N0m0uc50osm8ssc6ayJPL3ietm+Pu9KLABrLCK2hqOF9CxH/rSJ9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lX6Wz+BrGoe7G+1r/oKGI3hzUkCuWs50jfdIVF5RWXVsGzX4jkwIhJIWcNtZIYJpI769/0TCK9qMAS4c/pAylpeA2kXxxcX13Okcwd9AaOStyef9Kp7/lk6nk2zfGRtvb88bZV+kjyA0Zlv5Z6nOZLu5ju2tA9Wlb5fnLayaA6M0uJUSel4NtGK42t/ti8EoDgJpLyI2FrcD8t5H8DoLSYQc+1lRMRWrtK3uUrTHPW/JQ9g9Ja30jDfDsA1XHcvJgAYWN4m4/LDjADgwk3OowCAgYUSUueiA3A9OdLJdY9UBYALuUpfD0Yh25NPSscEwBpI1eSP/S3FrzpWFQAuLJfy5tPSMQGwBpYrsfK0ifxV6bgAWAOLC+lN5Gmq6i9KxwXAyDUx2Vnc0C9HmuZIZznSiyeP6qelYwRgpPpd6cMtxS92h7W4DsBqjz94vN1EfbRqSitHPi4dHwBrIiK22iNW04EGQwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4DL/B7EdVIEgTgUAAAAAAElFTkSuQmCC
这会生成空白 PDF 页面,而不是添加绿色方块:
require_once('tcpdf_include.php');
$pdf = new TCPDF();
$pdf->AddPage();
$img_encoded ='iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAANklEQVR42u3OQQ0AAAgEoDO50TWFmw9IQGXSeawEBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQVvLDGRO9mhGZRRAAAAAElFTkSuQmCC';
$imgdata = base64_decode($img_encoded);
$pdf->Image('@'.$imgdata);
$pdf->Output('example_009.pdf', 'I');
我已经验证了 base64 代码 (https://base64.guru/converter/decode/image) 并且完整的 base64 图像在浏览器中正确加载:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAACWCAYAAADwkd5lAAAI2UlEQVR4nO3dMW8cxxUAYP0E/gT9AJv7JN/OrIAAYm0EIEt3YhGktVwGCGB2MZDCRKp0ZpO0YpMmh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rq35BUYJXRnuI3rLi6rDmwicmO0SIwCsMbkqqeEpb7Pa46KKq/4aUEAhQkgZTXn0JsIk+v2pqkn2zuMkaAJcOeAwnkri1OX131OxhONzrzGyhMAilrOAK8urcjbac/NRdnj1tABwqTQMpa7jpfnRhmO/K2SaZKPzqvBShuuNurBHLXlhfQVy+M58iH8wSS/3rHYQIsk0DKSlX6Wz+BrGoe7G+1r/oKGI3hzUkCuWs50jfdIVF5RWXVsGzX4jkwIhJIWcNtZIYJpI769/0TCK9qMAS4c/pAylpeA2kXxxcX13Okcwd9AaOStyef9Kp7/lk6nk2zfGRtvb88bZV+kjyA0Zlv5Z6nOZLu5ju2tA9Wlb5fnLayaA6M0uJUSel4NtGK42t/ti8EoDgJpLyI2FrcD8t5H8DoLSYQc+1lRMRWrtK3uUrTHPW/JQ9g9Ja30jDfDsA1XHcvJgAYWN4m4/LDjADgwk3OowCAgYUSUueiA3A9OdLJdY9UBYALuUpfD0Yh25NPSscEwBpI1eSP/S3FrzpWFQAuLJfy5tPSMQGwBpYrsfK0ifxV6bgAWAOLC+lN5Gmq6i9KxwXAyDUx2Vnc0C9HmuZIZznSiyeP6qelYwRgpPpd6cMtxS92h7W4DsBqjz94vN1EfbRqSitHPi4dHwBrIiK22iNW04EGQwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4DL/B7EdVIEgTgUAAAAAAElFTkSuQmCC
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAANklEQVR42u3OQQ0AAAgEoDO50TWFmw9IQGXSeawEBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQVvLDGRO9mhGZRRAAAAAElFTkSuQmCC
我从一些帖子中知道有人推荐
关于为什么示例中的 base64 有效,但所有其他的都失败的任何想法?
这是 K_PATH_CACHE
变量的文件夹问题。
通过更多实验,我发现任何 PNG 文件都不会添加到让我查看 tcpdf.php 文件的 PDF 中。这导致错误日志并最终导致常量 K_PATH_CACHE.
imgpng()
函数使用 K_PATH_CACHE 在 PHP 安装(通过 AWS Lightsail 的 Bitnami)中定义 /tmp 的位置,但位置定义不正确。
K_PATH_CACHE 的默认值设置为 /opt/bitnami/php/tmp
,但该文件夹为空。实际的 tmp 文件夹位于 /tmp
.
为了解决这个问题,我将 K_PATH_CACHE 的位置重新定义为在其他所有内容之前加载的配置文件中的实际 /tmp 目录:
define('K_PATH_CACHE', '/tmp/');
现在可以从 base64 字符串和文件形式加载 PNG。
我希望这可以节省几个小时的搜索时间!