我有从Visual Studio运行的代码。但是,当我将其放在IIS上时,它不会打印条形码,而只是给我标签上的数字。
我尝试查找示例,但找不到任何内容。这是我第一次使用条形码并从IIS打印。下面是我目前在Visual Studio上可以使用的代码,但是当我从IIS托管的网站打印时仅打印文本。
protected void grdList_RowCommand(object sender,
GridViewCommandEventArgs e)
{
oDL.UpdateCookieExpiry();
try
{
if (e.CommandName == "View")
{
int rowIndex = Convert.ToInt32(e.CommandArgument);
int id =
Convert.ToInt32(grdList.DataKeys[rowIndex].Values[0]);
string url = "/Stock.aspx?ob_RecordID=" + id;
Response.Redirect(url, false);
Context.ApplicationInstance.CompleteRequest();
}
else if (e.CommandName == "Print")
{
int rowIndex = Convert.ToInt32(e.CommandArgument);
int id =
Convert.ToInt32(grdList.DataKeys[rowIndex].Values[0]);
try
{
outerboxbc o = new outerboxbc();
o = oDL.Get_Outerboxbc(id);
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
this.ob_Barcode.Text = o.barcode.bc_Barcode.ToString();
// Set the printer name.
// pd.PrinterSettings.PrinterName = "\\NS5\hpoffice
pd.PrinterSettings.PrinterName = "ZDesigner GK420d (Copy
1)";
pd.Print();
}
catch (Exception ex)
{
Response.Write("Error: " + ex.ToString());
}
}
}
catch (Exception ex)
{
Console.Write("Error: " + ex.Message);
}
}
void pd_PrintPage(object print, PrintPageEventArgs ev)
{
long de_RecordID = Convert.ToInt32(this.de_RecordID.Value);
cDelivery d = new cDelivery();
d = oDL.get_cDelivery(de_RecordID);
System.Drawing.Image img =
System.Drawing.Image.FromFile(@"C:AlphaLogo.png");
int printHeight = 100;
int printWidth = 250;
int leftMargin = 0;
int rightMargin = 0;
ev.Graphics.DrawImage(img, new Rectangle(leftMargin, rightMargin,
printWidth, printHeight));
Font printFont = new Font("3 of 9 Barcode", 24);
Font printFont1 = new Font("Times New Roman", 14, FontStyle.Bold);
SolidBrush br = new SolidBrush(Color.Black);
ev.Graphics.DrawString("*" + this.ob_Barcode.Text + "*", printFont,
br, 10, 130);
ev.Graphics.DrawString(d.de_ProjectNumber, printFont1, br, 110,
170);
}
因此,barcode.text的示例为“ AAC12342313”。当使用Visual Studio运行时,它会打印为条形码,但是从网站运行时,它会显示在标签“ AAC12342313 ”上。