0
下面是我在Windows窗體中打印的過程。 我使用了PrintDocument類。它包含PrintPage事件,我用它來繪製我需要打印的圖形,並按我的預期成功獲得結果。在WPF中打印與Winforms相似
下面是代碼:
public PrintDocument Printing
{
m_printDocument = new PrintDocument();
m_printDocument.PrintPage += new PrintPageEventHandler(OnPrintPage);
}
爲OnPrintPage的代碼如下:
protected virtual void OnPrintPage(object sender, PrintPageEventArgs e)
{
//Image img = I have the things to be printing in the form of image.
e.Graphics.DrawImage(img, new Point(0,0));
}
在WPF:
我有固定的文件,並通過使用下面的代碼,我的工作可打印
PrintDialog print = new PrintDialog();
print.PrintDocument(FixedDocument.DocumentPaginator, "Print") //Where Fixed document contains the data to be printed.
結果是內存不足以繼續執行程序。 但我得到固定文件沒有任何問題。 任何解決方案...? 我希望類似的東西就像Windows窗體一樣也會出現在WPF中...
感謝朋友.... –
這可直接打印到默認打印機。有沒有辦法讓我選擇打印機? –