php FPDF 错误:不支持 Alpha 通道:
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12938440/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
FPDF error: Alpha channel not supported:
提问by Farid Siddiqui
I am trying to generate PDF from HTML (output of a PHP file).
我正在尝试从 HTML(PHP 文件的输出)生成 PDF。
I am using FPDF to generate the PDFs.
我正在使用 FPDF 生成 PDF。
I have three PNG transparent images (Alpha channel), that go on top of each other and it looks like one image.
我有三个 PNG 透明图像(Alpha 通道),它们叠在一起,看起来像一张图像。
The minute FPDF encounters the first image it give me "FPDF error: Alpha channel not supported:"
FPDF 遇到它给我的第一张图像的那一刻“FPDF 错误:不支持 Alpha 通道:”
Is there a work arround this. Any help will be much appritiated.
有没有这方面的工作。任何帮助都会非常受欢迎。
采纳答案by Farid Siddiqui
DOMPDF has done the trick for me. It supports the Alpha channels images very well. It manages the CSS floats quite well.
DOMPDF 帮我解决了这个问题。它很好地支持 Alpha 通道图像。它很好地管理 CSS 浮动。
As compare to non-alpha channel images, it takes alot more time to process tranparent PNG (Alpha Channel images).
与非 Alpha 通道图像相比,处理透明 PNG(Alpha 通道图像)需要更多时间。
Because of the size of my HTML and the number of images, my script was taking couple of seconds more than, what is allowed by my host in terms of execution time.
由于我的 HTML 的大小和图像的数量,我的脚本比我的主机在执行时间方面允许的时间长了几秒钟。
By increasing the execution time and DOMPDF, now it all works to perfection.
通过增加执行时间和 DOMPDF,现在一切都完美无缺。
I hope it will be helpfull to someone else.
我希望它会对其他人有所帮助。
回答by user1111929
Actually, there is a fan-made extension that does allow alpha channels. Try it, it is just PHP code: http://www.fpdf.de/downloads/addons/1091/
实际上,有一个粉丝制作的扩展允许使用 alpha 通道。试试吧,它只是PHP代码:http: //www.fpdf.de/downloads/addons/1091/
回答by Chris
FPDF does not support alpha transparency but it does support index transparency. So just edit your PNG so that it is using index transparency instead. I am using Fireworks and this was an export option for both PNG8 and PNG24.
FPDF 不支持 alpha 透明度,但它支持索引透明度。因此,只需编辑您的 PNG,使其使用索引透明度。我正在使用 Fireworks,这是 PNG8 和 PNG24 的导出选项。
回答by Edson Medina
As stated, FPDF does not support alpha channel, so there's no workaround.
如前所述,FPDF 不支持 alpha 通道,因此没有解决方法。
Maybe you could render a single image and use that?
也许您可以渲染单个图像并使用它?

