【发布时间】:2018-06-07 09:37:05
【问题描述】:
我正在使用这个 jquery 插件来捕获或绘制签名。
http://keith-wood.name/signature.html
和FPDF php插件生成pdf
现在我必须在 pdf 中包含签名...
使用 FPDF 我可以插入图像,但在将签名导出为 jpeg/png 时遇到问题(我什至不知道是否可行)
我该怎么做
【问题讨论】:
我正在使用这个 jquery 插件来捕获或绘制签名。
http://keith-wood.name/signature.html
和FPDF php插件生成pdf
现在我必须在 pdf 中包含签名...
使用 FPDF 我可以插入图像,但在将签名导出为 jpeg/png 时遇到问题(我什至不知道是否可行)
我该怎么做
【问题讨论】:
在您在Save/Restore 选项卡中提供指向 (this one) 的链接的页面上,您可以将其保存为 base64 编码图片(jpeg 或 png)。
所以你可以使用它并将base64编码的图片保存为文件here is a solution
问题是
data:image/png;base64,包含在编码内容中。这将导致 base64 函数解码时图像数据无效。在解码字符串之前删除函数中的数据,就像这样。function base64_to_jpeg($base64_string, $output_file) { // open the output file for writing $ifp = fopen( $output_file, 'wb' ); // split the string on commas // $data[ 0 ] == "data:image/png;base64" // $data[ 1 ] == <actual base64 string> $data = explode( ',', $base64_string ); // we could add validation here with ensuring count( $data ) > 1 fwrite( $ifp, base64_decode( $data[ 1 ] ) ); // clean up the file resource fclose( $ifp ); return $output_file; }
澄清变量$base64string是一个字符串,在你的情况下是由插件生成的,$output_file是一个保存图片的文件路径。
【讨论】: