2014-01-09 50 views
0

我有这个演示应用程序,我需要打印FlowDocument而不会弹出操作系统中的打印对话。你有什么想法如何做到这一点?或者你知道其他可能的解决方案?如何在不显示打印对话的情况下打印?

private void Button_Click(object sender, RoutedEventArgs e) 
{ 
    PrintDialog pd = new PrintDialog(); 
    pd.ShowDialog(); 
    if (pd.ShowDialog() != true) return; 

    flowDocument.PageHeight = pd.PrintableAreaHeight; 
    flowDocument.PageWidth = pd.PrintableAreaWidth; 

    IDocumentPaginatorSource idocument = flowDocument as IDocumentPaginatorSource; 

    pd.PrintDocument(idocument.DocumentPaginator, "Printing Flow Document..."); 
} 

回答

4

删除此行:

pd.ShowDialog(); 
if (pd.ShowDialog() != true) return; 
+0

感谢,但.....移除该行代码没有帮助,打印对话框仍然出现 – GibboK

+1

同时删除之前的一个:'pd.ShowDialog ();' – gnarlybracket

+0

我编辑了答案。 – dovid

相关问题