问题描述
尊敬的先生,
我需要从客户端计算机上打印条形码,而在Visual Studio中运行该程序时,条形码可以完美打印,而一旦代码发布&将条形码不打印在IIS服务器中,而是在服务器端打印.
即使我尝试从客户端计算机进行打印也无法正常工作,一旦条形码打印机计算机与服务器连接,它就会打印客户端计算机以及服务器中给出的所有条形码.条形码仅打印条形码打印机与服务器而不是客户端连接.
我需要从客户端计算机上打印条形码".我的代码:
Dear Sir,
I need to print barcode from client Machine, While running the program in Visual studio Barcode prints perfectly whereas once code is published & Put into IIS server the barcode is not printing in client machine rather it prints in server side.
Even if i try to print from client machine it will not work, once barcode printer machine connects with server it prints all the barcode given in client machine as well as in server. Barcode is printing only barcode printer is connected with server not with client.
"I NEED TO PRINT BARCODE FROM CLIENT MACHINE".MY CODE:
protected void btnPrint_Click(object sender, EventArgs e)
{
List<string> list = new List<string>();
foreach (String printer in PrinterSettings.InstalledPrinters)
{
list.Add(printer.ToString());
}
string printerName = "";
for (int i = 0; i < list.Count; i++) // Loop through List with for
{
printerName = list[i].ToString().ToLower();
if (printerName.Equals(@"tsc ttp-244 plus"))
{
// Console.WriteLine("Printer = " + printer["Name"]);
if (list[i].ToString().ToLower().Equals("true"))
{
// printer is offline by user
//lblMsg.Text = "Your Plug-N-Play printer is not connected.";
}
else
{
// printer is not offline
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.PrinterSettings.PrinterName = "TSC TTP-244 Plus";
pd.DefaultPageSettings.PaperSize = new PaperSize("Label", 197, 98);//Document No Size
// pd.DefaultPageSettings.Margins = new Margins(70, 12, 12, 12);
// pd.DefaultPageSettings.Margins.Left = 100;
pd.Print();
}
}
}
PlBarcodeFileNo.Controls.Add(_BarcodeImageView(lblBarcode.Text));
}
private System.Web.UI.WebControls.Image _BarcodeImageView(string barCodeimgNo)
{
System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
using (Bitmap bitMap = new Bitmap(barCodeimgNo.Length * 40, 80))
{
using (Graphics graphics = Graphics.FromImage(bitMap))
{
Font oFont = new Font("IDAutomationHC39M", 16);
PointF point = new PointF(2f, 2f);
SolidBrush blackBrush = new SolidBrush(Color.Black);
SolidBrush whiteBrush = new SolidBrush(Color.White);
graphics.FillRectangle(whiteBrush, 0, 0, bitMap.Width, bitMap.Height);
graphics.DrawString("*" + barCodeimgNo + "*", oFont, blackBrush, point);
}
using (MemoryStream ms = new MemoryStream())
{
bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
byte[] byteImage = ms.ToArray();
Convert.ToBase64String(byteImage);
imgBarCode.ImageUrl = + Convert.ToBase64String(byteImage);
}
}
return imgBarCode;
}
推荐答案
这篇关于使用Asp.Net从客户端[在客户端计算机]打印条形码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!