PHP / TCPDF 库 - 将 PDF 中的图像调整为特定的英寸数?

发布于 2024-08-02 15:26:25 字数 239 浏览 10 评论 0原文

有谁知道如何让 TCPDF 输出具有特定宽度 x 高度英寸数的 .GIF 文件?

我正在尝试将 GIF 嵌入到 PDF 中,以便打印时精确为 4x6 英寸。我尝试了这个:

$this->setpageUnit('in');
$this->Image($tmp, 0, 0, 4, 6, 'gif', '', '', true);

但这似乎只会导致空白页。有什么想法吗?

Does anyone know how to get TCPDF to output a .GIF file with a specific number of inches width x height?

I am trying to get a GIF embedded in a PDF so that it will print at exactly 4x6 inches. I tried this:

$this->setpageUnit('in');
$this->Image($tmp, 0, 0, 4, 6, 'gif', '', '', true);

But that only seemed to result in a blank page. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

两仪 2024-08-09 15:26:26

我认为发生这种情况是因为您没有使用大写“P”

$this->setpageUnit('in');

也许应该是:

$this->setPageUnit('in');

I think it's happen because you are not using a capital "P"

$this->setpageUnit('in');

maybe is should be :

$this->setPageUnit('in');
指尖上得阳光 2024-08-09 15:26:26

我认为您需要计算出每英寸有多少像素,然后使用方法 setImageScale(float $scale);

例如:

$this->setImageScale(24.5);

设置比例后,您的代码应该可以工作:

$this->Image($tmp, 0, 0, 4, 6, 'gif', '', '', true);

I think you'll need to figure out how many pixel's per inch and then use the method setImageScale(float $scale);

For example:

$this->setImageScale(24.5);

Then your code should work, after setting the scale:

$this->Image($tmp, 0, 0, 4, 6, 'gif', '', '', true);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文