有没有一种方法可以通过SWF打印网页? [英] Is there a way to print a web page via a SWF?
问题描述
在我的Web应用程序中,我想使用Flash通过真实的物理打印机打印网页.我要这样做是为了使浏览器添加的典型页面标题(例如URL和"y的第x页")不会添加到打印输出中.
In my web app, I would like to print a web page via a real, physical printer using Flash. I want to do this so that typical page headers added by the browser (eg. the URL and "Page x of y") do not get added to the printout.
也许我可以生成PDF并将其传递给SWF,或者也许我可以仅将原始HTML和CSS发送给SWF,然后可以通过Javascript针对SWF调用一些.print()方法.
Perhaps I could generate a PDF and pass it to the SWF, or perhaps I could just send raw HTML ann CSS to the SWF, and then I could call some .print() method via Javascript against the SWF.
所以,1)这可能吗?和2)是否有某个库(也许在GitHub上)可以让我做到这一点?
So, 1) is this possible? and 2) is there a library (on GitHub perhaps) somewhere that would let me do this?
推荐答案
我会服务器端脚本(php),该脚本会快照您想要的页面并显示要使用Flash的图像,然后可以使用Flash的
I would ping a server-side script (php) which would snap shot the page you want and display the image which flash can then print using flash's printjob functionality. Hope that helps!
步骤:
- 1)加载将显示url快照的页面(拍摄快照 使用php)使用Loader类.确保标题正确 php页面(因此浏览器认为它是图像).
- 2)使用闪光灯 printjob来打印图像
- 1) load the page that will display the url snapshot (snapshot taken with php) using a Loader class. Make sure the headers are correct on the php page (so browsers think it's an image).
- 2) use the flash printjob to print the image
这篇关于有没有一种方法可以通过SWF打印网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!