带文本的条形码使用ItextSharp

aca*_*dia 9 c# barcode itextsharp

我在我的应用程序中使用iTextSharp来生成条形码.虽然一切都按照我的意愿运行,但我需要在条形码下显示条形码的值,如附图中的一个showin. 样本条形码

下面是我使用的C#代码:

Barcode39 barcodeImg = new Barcode39();
barcodeImg.Code = barcodeValue.ToString();
barcodeImg.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White).Save(stream, ImageFormat.Png);
Run Code Online (Sandbox Code Playgroud)

Pra*_*ant 6

这是我在搜索网络时发现的代码.希望这能解决您的问题:

string prodCode = context.Request.QueryString.Get("code");
context.Response.ContentType = "image/gif";
if (prodCode.Length > 0)
{
  Barcode128 code128          = new Barcode128();
  code128.CodeType            = Barcode.CODE128;
  code128.ChecksumText        = true;
  code128.GenerateChecksum    = true;
  code128.StartStopText       = true;
  code128.Code                = prodCode;
  System.Drawing.Bitmap bm    = new System.Drawing.Bitmap(code128.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White));
  bm.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);            
} 
Run Code Online (Sandbox Code Playgroud)

  • 大声笑!该片段看起来就像我博客上的那个!http://www.jphellemons.nl/post/Make-a-code128-barcode-with-C-sharp-and-iTextSharp.aspx (5认同)