2014-01-17 146 views
0

上我嘗試熱敏打印打印圖像:如何打印圖像熱敏打印機

void Method() 
    { 
     var printDocument = new PrintDocument(); 
     printDocument.PrinterSettings = new PrinterSettings() { PrinterName = "zebra" }; 
     printDocument.PrintPage += new PrintPageEventHandler(printDocument_PrintPage); 
     printDocument.Print(); 
    } 

    void printDocument_PrintPage(object sender, PrintPageEventArgs e) 
    { 
     e.Graphics.DrawImage(System.Drawing.Image.FromFile(Server.MapPath("~/Images/orderedList6.png")), 0, 0); 
    } 

但不打印文檔。另外文檔在打印隊列中可見,我可以打印到.xps文件。

+0

這可能是Windows打印後臺處理程序的問題,而不是您的代碼。你能打印這臺PC上的文字文件嗎? –

+0

當然可以。打印機和系統正在工作。代碼中的問題。 – christo

+0

Server.MapPath表明這是ASP.NET。我不知道有關使用asp.net進行打印的任何信息,但出於安全原因,這很可能不起作用。 – Laurijssen

回答

0

問題是你不是要設置控制器

printDocument.PrintController = new StandardPrintController(); 
+0

它沒有工作。 – christo

0
  • 創建的FlowDocument,把你的形象裏的FlowDocument的「BlockUIContainer」
  • 通過打印服務器循環
  • 使用下面的代碼查找PrintQue打印
IDocumentPaginatorSource flowDocument = You_Flowdocument; 
var writer = PrintQueue.CreateXpsDocumentWriter(Your_printQueue); 
DocumentPaginator documentPaginator = flowDocument.DocumentPaginator; 
writer.Write(documentPaginator); 

您可以通過熱敏打印機dll使用UserPrintTicket.PageMediaSizeDesity來設置標籤大小。