如何从 TabControl 打印所有元素或生成 PDF?
我有一个 silverlight 应用程序,其中包含几个选项卡,我想打印该应用程序或生成包含这些选项卡的 PDF。
我尝试使用 StackPanel 添加每个选项卡,然后使用 PrintDocument 打印我所看到的内容,但是存在问题,因为选项卡太多,所以它们不打印适合A4文档的尺寸。
而且,当我将浏览器调整为较小的尺寸时,只会打印内容的可见部分。
是否有其他方法可以打印一个文档或 PDF 中的所有内容?
I have a silverlight application which consists of a few tabs, which I would like to print or to generate PDF containing these tabs.
I tried to use StackPanel
to add each tab and then use PrintDocument
to print what I see, but there is a problem because there are too many tabs, so they don't fit in the size of A4 document.
And more, when I resize the browser to a smaller size, only the visible part of the content gets printed.
Is there a different method to print all the content in one document or PDF?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
PrintPage 处理程序中的 PrintPageEventArgs 包含纸张的大小,因此您可以计算单页上可以打印的数量。
打印视觉树(一部分)有其缺点;在屏幕上看起来不错的内容可能不适用于纸张,尤其是在涉及滚动和调整大小的情况下。
一种解决方案是设计一个或多个用于打印的View,只需将相同的ViewModel绑定到PrintView即可。有点像创建网页打印版本的特殊 CSS。
如果内容不适合,您应该使用更多页面。
Charles Petzold 的这篇文章也值得一读
The PrintPageEventArgs in the PrintPage handler contains the size of the paper so you can calculate how much can be printed on a single page.
Printing (a part of) the visual tree has its disadvantages; what looks good on screen might not be good for paper, especially if scrolling and sizing are involved.
A solutions is to design one or multiple Views for printing and simply bind the same ViewModel to the PrintView. A bit like the special CSS for creating a print version of a web page.
If the content doesn't fit you should use more pages.
This article by Charles Petzold is worth reading too