将 DIV 内容保存为图像
我有一个显示一些内容(多个图像、文本、浮动元素等)的 div,我想添加用户执行“将此内容另存为图像”之类的操作的可能性。
我怎样才能做到这一点?我阅读了所有的 php 文档,但没有什么好的办法,甚至 imagegrabwindow 也很糟糕,因为它的高负载、浏览器限制,而且没有 X/Y 或宽度/高度控制。
基本上,我想这样做: 获取 #div 内容,单击“另存为图像”,然后用户将获得该 div 的 .JPG 或 .PNG,就像它是打印屏幕(屏幕截图)一样。
我不想使用 GD 预先生成内容,也不想另存为 .PDF。
I have a div that shows some content (several images, text, floating elements, etc) and I would like to add the posibility for a user to do something like "Save this content as image".
How can i do that? I read all the php docs but there's nothing good to do this, even imagegrabwindow
sucks because of its high load, browser limitations, and also no X/Y or width/height control.
So basically, I want to do this:
Get #div content, click on Save as Image, then the user gets a .JPG or .PNG of that div, as if it were a printscreen (screenshot).
I don't want to pre-generate the content using GD, and neither do I want to save as .PDF.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我唯一真正能想到的就是序列化div中内容的内容/放置/属性,将其发送到服务器,并让服务器与GD重新创建相同的元素、相同的定位、相同的属性。
我突然想到,可能会检查 div 并创建一个表单帖子,例如:
服务器可以使用此数据来重新创建用户在浏览器中创建的内容。
The only thing I can really think of is to serialize the contents/placement/attributes of the content in the div, send that to the server, and have the server recreate the same elements, same positioning, same attributes with GD.
Off the top of my head, I'd see maybe inspecting the div and creating basically a form post, something like:
The server could use this data to recreate what the user created in their browser.