在应用程序窗口中有 ScrollView ,
从窗口中取出打印时,整个 ScrollView 没有出现,只有窗口大小打印出现,
我可以采取仅打印 ScrollView ,但有没有办法通过窗口打印整个 ScrollView ?
PrintDialog printDialog = new PrintDialog(); if (printDialog.ShowDialog() == true) { // printDialog.PrintVisual(canvas, "Scrollview Description"); printDialog.PrintVisual(this, this.Title); }
最佳答案
即使编辑了这个问题,我也没有得到任何答案,我多次查看谷歌,经过多次失败的尝试,终于得到了一个解决方案,我的代码中的问题是,我在 ScrollView 中使用了网页浏览器控件,之后阅读一种解决方案,我删除了 ScrollView 并放置了用于从浏览器控制中获取打印的代码,它可以工作,这是我使用的代码
mshtml.IHTMLDocument2 doc = webbrwsr.Document as mshtml.IHTMLDocument2;
doc.execCommand("Print", true, null);
为此我必须包含一个 .NET 引用Microsoft.mshtml
希望这个解决方案适用于任何面临同样问题的人。
关于wpf - WPF 中的打印 Web 浏览器控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11226739/