如何使用Silverlight 4 Beta打印预览?
许多 PDC 文档中列出的 Silverlight 4 功能之一是打印预览。
我已经搜索了有关如何使用它的示例,但到目前为止什么也没找到。有人已经开始工作了吗?您能给我一些关于如何实现带有打印预览的简单 Web 应用程序的指导吗?
One of the Silverlight 4 features listed in a lot of the PDC documents is Print Preview.
I've searched for examples on how to use this and found nothing so far. Has anyone got this working yet? Can you give me some pointers on how to implement a simple web app with print preview in.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我没有看到打印预览,但有实际的打印支持,您可以在其中控制打印哪些控件以及基于打印过程的事件。
I have not seen print preview as any of them but actual Printing support in which you can control which controls are printed and events based on the printing process.
经过一段时间的寻找,我找到了一种方法,通过结合我在其他项目中发现的一些功能来做到这一点,但他们将其用于图像处理。我尝试过打印,看起来效果很好。
这是它的工作原理:
使用 WriteableBitmap 获取转换为位图的打印内容的基本容器,这里我将使用 Canvas:
使用此位图作为 Image 控件的源(可以在 ScrollViewer 内部,更好)。
设置缩放基本单位(在本例中使用 1%):
然后使用滑块调整缩放比例(可选)
After looking for a while I found a way to do this by combining some features I found in other projects, but they used it for image manipulation. I tried with printing and it seems to work fine.
Here how it works:
Get the base container for the print contents converted to a bitmap by using WriteableBitmap, here I´ll use a Canvas:
Use this bitmap as a source for a Image control (can be inside a ScrollViewer, what is even better).
Set scaling base units (used 1 percent in this case):
Then adjust the scaling using a Slider (optional)
我认为,由于缺乏回应,而且事实是,正如 Hurricanepkt 在他的回复中指出的那样,Tim Heuer 和其他人谈论了虚拟打印,如果在屏幕上显示相同的内容,可以很容易地将其构建到您自己的定制打印预览功能中,某些列表中列出的打印预览实际上是人们误解了虚拟打印文档的实际含义。
I think from the lack of responses and the fact that as Hurricanepkt pointed out in his reply Tim Heuer and others talk about a virtual print which if displying the same thing on the screen could be built quite easily into your own bespoke Print Preview functionality that the Print Preview listed in some lists is actually people misinterpretting what the Virtual Print documents actually are.