使用C#从ASP.NET打印Zebra标签 [英] Printing Zebra Label from ASP.NET with C#

查看:146
本文介绍了使用C#从ASP.NET打印Zebra标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在开展一个项目,我必须直接从网页打印到条形码打印机(Zebra GC420t)。我面临的问题是,当我通过源代码打印时,打印成功。但是,托管到Web服务器时它会失败。我正在使用的代码是:

Hi,

I am working on a project where I have to print to a barcode printer(Zebra GC420t) directly from the webpage. The issue I'm facing is, when I print it through my source code, the print succeeds. But, it fails when hosted to a web server. The code I'm using is:

PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.Print();

void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
   System.Drawing.Font printFont = new System.Drawing.Font("IDAutomationHC39M", 9);
   SolidBrush br = new SolidBrush(Color.Black);
   ev.Graphics.DrawString("test", printFont, Brushes.Black, new RectangleF(5, 30, 180, 50));
}



会出现什么问题。这是一个与网络相关的问题,还是应该将其更改为客户端代码,如javascript。建议我提供一些好的解决方案。



提前致谢,

Ranjith


What would be the issue. Is this a network related issue or should I change it to a client side code like javascript. Suggest me with some good solutions.

Thanks in advance,
Ranjith

推荐答案

如果您希望在客户端打印机上打印代码,则代码将无法运行,因为您的代码在服务器端运行并将尝试打印到该服务器上可用的打印机。

要打印到客户端打印机使用:



1. javascript代码即经典window.print( https://www.google.com/#q=asp.net+window.print [ ^ ])



2.或尝试一些报告免费的ReportViewer RDLC报告工具( http://www.gotreportviewer.com/ [ ^ ])



3.或尝试将原始Zebra命令发送到打印机:



http://start-coding.blogspot。 com / 2010/02 / print-zebra-barcode-label-thru-asp-net.html [ ^ ]

http://forums.asp.net/t/1835622.aspx [ ^ ]
Your code will not work if you expect it to be printed at the client printer because your code runs at server side and will try to print to the printer available at that server.
To print to client printer use:

1. javascript code i.e. the classic window.print (https://www.google.com/#q=asp.net+window.print[^])

2. or try some reporting tool like free ReportViewer RDLC reports (http://www.gotreportviewer.com/[^])

3. or try sending raw Zebra commands to the printer:

http://start-coding.blogspot.com/2010/02/print-zebra-barcode-label-thru-asp-net.html[^]
http://forums.asp.net/t/1835622.aspx[^]


这篇关于使用C#从ASP.NET打印Zebra标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆