如何打印WPF网格分页?
我正在打印 WPF 网格。只要数据适合一页,一切就可以正常工作。但有时网格包含更多数据。因此我需要将网格分成多个页面。有人可以帮助我吗?
我的代码如下所示(视觉上是网格)。
var printCapabilities = printDialog.PrintQueue.GetPrintCapabilities(printDialog.PrintTicket);
var size = new Size(printCapabilities.PageImageableArea.ExtentWidth,
printCapabilities.PageImageableArea.ExtentHeight);
visual.Measure(size);
visual.Arrange(new Rect(new Point(printCapabilities.PageImageableArea.OriginWidth,
printCapabilities.PageImageableArea.OriginHeight), size));
printDialog.PrintVisual(visual, "Print ListView");
我应该尝试其他控件吗?我尝试过 WPF Toolkit DataGrid,但无法打印它。我听说过一些流程文档,这对我有帮助吗?
最好的问候
奥利弗·哈纳皮
I'm printing a WPF grid. As long as the data fits on one page, everything works fine. But sometimes the grid contains more data. Therefore I need to split the grid into multiple pages. Can anybody help me?
My code looks like this (visual is the grid).
var printCapabilities = printDialog.PrintQueue.GetPrintCapabilities(printDialog.PrintTicket);
var size = new Size(printCapabilities.PageImageableArea.ExtentWidth,
printCapabilities.PageImageableArea.ExtentHeight);
visual.Measure(size);
visual.Arrange(new Rect(new Point(printCapabilities.PageImageableArea.OriginWidth,
printCapabilities.PageImageableArea.OriginHeight), size));
printDialog.PrintVisual(visual, "Print ListView");
Should I try another control? I've tried WPF Toolkit DataGrid, but I couldn't manage to get it printed. I've heard something of a flow document, can this help me?
Best Regards
Oliver Hanappi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您想使用 PrintDocument 而不是 PrintVisual。不过,您可能需要实现自己的 DocumentPaginator 类来将网格拆分为单独的可打印文档。
It sounds like you want to use PrintDocument instead of PrintVisual. You will probably need to implement your own DocumentPaginator class to split your grid into separate printable documents, though.