如何在热敏打印机上打印图像

时间:2014-01-17 11:09:30

标签: c# zebra-printers thermal-printer

我尝试在热敏打印件上打印图像:

   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文件。

2 个答案:

答案 0 :(得分:0)

问题是你没有设置控制器

printDocument.PrintController = new StandardPrintController();

答案 1 :(得分:0)

      
  • 创建Flowdocument并将您的图像放入flowdocument的“BlockUIContainer”
  •   
  • 通过循环PrintServer
  • 查找PrintQue   
  • 使用以下代码打印
IDocumentPaginatorSource flowDocument = You_Flowdocument;
var writer = PrintQueue.CreateXpsDocumentWriter(Your_printQueue);
DocumentPaginator documentPaginator = flowDocument.DocumentPaginator;
writer.Write(documentPaginator);

您可以通过热敏打印机dll使用UserPrintTicket.PageMediaSizeDesity来设置标签尺寸。