如何使用Silverlight 4 Beta打印预览?

发布于 2024-08-16 04:36:52 字数 130 浏览 12 评论 0原文

许多 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

千年*琉璃梦 2024-08-23 04:36:52

我没有看到打印预览,但有实际的打印支持,您可以在其中控制打印哪些控件以及基于打印过程的事件。

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.

成熟的代价 2024-08-23 04:36:52

经过一段时间的寻找,我找到了一种方法,通过结合我在其他项目中发现的一些功能来做到这一点,但他们将其用于图像处理。我尝试过打印,看起来效果很好。

这是它的工作原理:
使用 WriteableBitmap 获取转换为位图的打印内容的基本容器,这里我将使用 Canvas:

WriteableBitmap wb = new WriteableBitmap(this.canvas1, null);

使用此位图作为 Image 控件的源(可以在 ScrollViewer 内部,更好)。

this.imagePreview.Height = wb.PixelHeight;
this.imagePreview.Width = wb.PixelWidth;
this.imagePreview.Source = wb;

设置缩放基本单位(在本例中使用 1%):

Point scale = new Point();      

scale.X = imagePreview.Width/100d;
scale.Y = imagePreview.Height/100d;

然后使用滑块调整缩放比例(可选)

private void vSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {

                imagePreview.Height = scale.Y * vSlider.Value;
                imagePreview.Width = scale.X * vSlider.Value;           
        }

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:

WriteableBitmap wb = new WriteableBitmap(this.canvas1, null);

Use this bitmap as a source for a Image control (can be inside a ScrollViewer, what is even better).

this.imagePreview.Height = wb.PixelHeight;
this.imagePreview.Width = wb.PixelWidth;
this.imagePreview.Source = wb;

Set scaling base units (used 1 percent in this case):

Point scale = new Point();      

scale.X = imagePreview.Width/100d;
scale.Y = imagePreview.Height/100d;

Then adjust the scaling using a Slider (optional)

private void vSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {

                imagePreview.Height = scale.Y * vSlider.Value;
                imagePreview.Width = scale.X * vSlider.Value;           
        }
一梦等七年七年为一梦 2024-08-23 04:36:52

我认为,由于缺乏回应,而且事实是,正如 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文