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

查看:30
本文介绍了以编程方式从网页或单个 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 上,每次打印结果都具有不同的优惠券尺寸(图像).这就是为什么 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 创建图像,但是您可以使用 php 的 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天全站免登陆