以编程方式从网页或单个DIV创建图像 [英] Programatically create image from web-page or a single DIV

查看:98
本文介绍了以编程方式从网页或单个DIV创建图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么方法可以通过编程方式创建(客户端或服务器端(PHP))来自特定DIV或完整(web)页面的图像?我目前正在创建一个免费优惠券网站,当最终用户点击打印按钮时,该应用程序将打开一个新选项卡/窗口,并将所有选定的优惠券作为单个图像(JPG,PNG或者等等)以A4格式准备好打印。每张优惠券都有它自己的数据(商品名称,价格,说明等),所以我需要通过我设计的优惠券模板进行编程。



我不要求你为我写代码,只是为了提出一个我可以使用/开发的解决方案。如果还不存在,我会免费上传/发布:)

更新:我使用PHP GD库完成了:)仍然不满意使用这个想法图像而不是PDF,因为每个打印在不同的PC上使用不同的优惠券尺寸(图像)。这就是为什么PDF可能是更好的解决方案。您可以在 demo.svikuponi.ba 上查看/测试它 - 只需选择几张优惠券并点击上面的PRINTAJ按钮即可。

解决方案

您无法从div创建图像,但是您可以使用其gd库在php中创建动态图像。
以下链接将有助于:

http://php.net/manual/en/function.imagecreate.php

http://phptutorial.info/learn/create_images/


Is there any way to programatically create (client or server side (PHP)) a image from a specific DIV or a complete (web) page? I'm currently creating a web-site for free coupons and the idea is when the end-user clicks on the "Print" button, the app opens a new tab/window with all the selected coupons as a single image (JPG, PNG or etc..) in A4 format ready for printing. Each coupons has it's own data (Article name, price, description etc..) so I need it to be done programmaticaly over a coupon-template I designed.

I do not ask you to write code for me, just to suggest a solution I could use/develop. If not already exist, I will upload/publish it for free :)

Update: I did it with the PHP GD library :) Still not satisfied with the idea to use Images instead of PDF, because each printing results with different Coupon sizes (images) on different PC's. That's why PDF may would be a better solution. You can see/test it on demo.svikuponi.ba - Just select a few Coupons and click the PRINTAJ button above.

解决方案

You cannot create image from div for sure but yes you can create dynamic images in php using its gd library. Following links will help:

http://php.net/manual/en/function.imagecreate.php

http://phptutorial.info/learn/create_images/

这篇关于以编程方式从网页或单个DIV创建图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆