1
這是我如何打印我的FlowDocument:如何獲取WPF中的打印機狀態?
PrintDialog pd = new PrintDialog();
LocalPrintServer local = new LocalPrintServer();
PrintQueue pq = local.DefaultPrintQueue;//GetPrintQueue("[Printer Name]"); //e.g. local.GetPrintQueue("Microsoft XPS Document Writer");
pd.PrintQueue = pq;
PrintTicket pt = pq.DefaultPrintTicket;
pt.PageMediaSize = new PageMediaSize(PageMediaSizeName.ISOA5);// or we can specify the custom size(width, height) here
pd.PrintTicket = pt;
pt.PageBorderless = PageBorderless.Borderless;
pt.PageOrientation = PageOrientation.ReversePortrait;
PrintCapabilities capabilities = pd.PrintQueue.GetPrintCapabilities(pd.PrintTicket);
double sizeWidth = capabilities.PageImageableArea.ExtentWidth;
double sizeHeight = capabilities.PageImageableArea.ExtentHeight;
var fd = new FlowDocument();
DocumentPaginator sd = ((IDocumentPaginatorSource)fd).DocumentPaginator;
sd.PageSize = new Size(sizeWidth + 20, sizeHeight);
pd.PrintDocument(sd, "My Doc");
// GET THE PRINTER STATUS IN MESSAGE BOX HERE..
MessageBox.Show(printerStatus()); // printerStatus() is a pseudo method to retrieve the status of the printer.
我怎樣才能得到打印機的當前狀態,使其輸出,打印,缺紙,卡紙,打印機脫機等消息的??? ?
搜索後,我遇到了這個頁面:http://msdn.microsoft.com/en-us/library/system.printing.printqueuestatus.aspx
但是我不知道它的用法。你身體能幫助我解決嗎?
此打印過程正在STA線程中運行。
我可以檢查LPT打印機端口的狀態,但是我使用的USB打印機,並希望從打印機聽。 – user995387 2011-12-30 10:42:48