使用文本条码使用下iTextSharp的 [英] Barcode with Text Under using ItextSharp

查看:1198
本文介绍了使用文本条码使用下iTextSharp的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用iTextSharp的生成条形码。尽管一切工作,因为我想,我需要像一个附加的图像中舒条形码下方显示该条码的价值。



下面是C#代码我使用:

  Barcode39 barcodeImg =新Barcode39(); 
barcodeImg.Code = barcodeValue.ToString();
barcodeImg.CreateDrawingImage(System.Drawing.Color.Black,System.Drawing.Color.White).Save(流ImageFormat.Png);


解决方案

这是代码,我发现,而搜索网。希望这会解决您的问题:

 字符串prodCode = context.Request.QueryString.Get(准则); 
context.Response.ContentType =图像/ GIF;
如果(prodCode.Length大于0)
{
Barcode128 CODE128 =新Barcode128();
code128.CodeType = Barcode.CODE128;
code128.ChecksumText = TRUE;
code128.GenerateChecksum = TRUE;
code128.StartStopText = TRUE;
code128.Code = prodCode;
System.Drawing.Bitmap BM =新System.Drawing.Bitmap(code128.CreateDrawingImage(System.Drawing.Color.Black,System.Drawing.Color.White));
bm.Save(context.Response.OutputStream,System.Drawing.Imaging.ImageFormat.Gif);
}


I am using iTextSharp in my application to generate a barcode. Though everything is working as I wanted, I need to display the value of the barcode under the barcode like the one showin in the attached image.

Below is the C# code I use:

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

解决方案

This is code I found while searching the net. Hope this solves your problem:

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);            
} 

这篇关于使用文本条码使用下iTextSharp的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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