我遇到一個從WPF項目打印奇怪的問題。我正在爲報告目的打印應用程序的屏幕截圖,並且所有的工作都很好。目前用戶按下打印,出現打印對話框,並打印出捕獲圖像。打印沒有ShowDialog給出空白頁
但是,我希望能夠直接打印到默認打印機而不顯示對話框。這應該通過註釋ShowDialog()
聲明輕鬆完成,並讓剩下的事情發生。打印機仍然打印,但頁面始終爲空。 任何人都可以解釋這種行爲?
private void PrintCurrentScreen()
{
PrintDialog PD = new PrintDialog();
PD.PrintTicket.OutputColor = OutputColor.Grayscale;
PD.PrintTicket.OutputQuality = OutputQuality.Draft;
PrintTicket PT = new PrintTicket();
PT.PageOrientation = PageOrientation.Landscape;
PT.CopyCount = 1;
PT.PageBorderless = System.Printing.PageBorderless.Borderless;
//---Blank pages print when commented out---//
//if (PD.ShowDialog() == true)
//{
PD.PrintTicket = PT;
DrawingVisual DV = new DrawingVisual();
DV.Offset = new Vector(20, 20);
DrawingContext DC = DV.RenderOpen();
DC.DrawImage(previewimage.Source, new Rect(new Size(PD.PrintableAreaWidth - 40, PD.PrintableAreaHeight - 40)));
DC.Close();
PD.PrintVisual(DV, "TEST");
//}
}
你有沒有發現這方面的任何解決方案,我有同樣的問題,但問題是,這發生在一些具有不同操作系統的PC上 - 並非全部 - – safi