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

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

问题描述

是否可以通过编程方式从特定DIV或完整(网页)页面创建(客户端或服务器端(PHP))图像?我当前正在创建一个免费优惠券的网站,其想法是当最终用户单击打印"按钮时,该应用程序将打开一个新标签/窗口,其中所有选定的优惠券均作为单个图像(JPG,PNG等等.)以准备打印的A4格式.每个优惠券都有自己的数据(商品名称,价格,说明等),因此我需要在我设计的优惠券模板上以编程方式完成.

Is there any way to programmatically 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 programmatically 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 :)

更新:我是用PHP GD库完成的:)仍然对使用图像而不是PDF的想法不满意,因为每次打印结果在不同PC上具有不同的Coupon尺寸(图像).这就是为什么PDF可能是更好的解决方案.您可以在 demo.svikuponi.ba 上查看/测试它-只需选择一些优惠券,然后单击上方的PRINTAJ按钮

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.

推荐答案

您不能确定是否可以从div创建图像,但是可以,您可以使用其gd库在php中创建动态图像. 以下链接会有所帮助:

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天全站免登陆