使用代码值生成条形码 [英] Generate Barcode with code value

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

问题描述

我想用其代码值生成条形码图像。目前我的代码只生成条形码,但没有在条形码行中显示值。



目前我在c#中的代码是:



Hi, I want to generate a barcode image with its code value. Presently my code is generating only barcode but it is not showning the value inside the barcode lines.

Presently my code in c# is this :

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Barcode1.aspx.cs" Inherits="Barcode1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    protected void Page_Load(object sender, System.EventArgs e)
    {
        string prodCode = Context.Request.QueryString.Get("code");
        Context.Response.ContentType = "image/gif";
        if (prodCode.Length > 0)
        {
            iTextSharp.text.pdf.Barcode128 code128 = new iTextSharp.text.pdf.Barcode128();
            code128.CodeType = iTextSharp.text.pdf.Barcode.CODABAR;
            code128.ChecksumText = true;
            code128.GenerateChecksum = true;
            code128.StartStopText = true;
            code128.Code = prodCode;

            code128.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White).Save(Context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);




        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    </div>
    </form>
</body>
</html>

推荐答案

看看这个 Stack Overflow 问题是否有任何帮助:使用ItextSharp下文本的条码 [ ^ ]。
See if this Stack Overflow question is of any help: "Barcode with Text Under using ItextSharp"[^].






i猜你已经评论了文章用C#和iTextSharp创建一个code128条码[< a href =http://www.jphellemons.nl/post/Make-a-code128-barcode-with-C-sharp-and-iTextSharp.aspxtarget =_ blanktitle =New Window> ^ ]。



可能是您设置的CodeType错误。如果查看文章,作者将CodeType设置为如下:

Hi,

i guess you have refereed article Make a code128 barcode with C# and iTextSharp[^].

May be the "CodeType" which you are setting is wrong. if look into the article, the author is setting the CodeType as Below:
code128.CodeType = Barcode.CODE128;



尝试使用如上所述。



希望它有效。


try by using like above.

hope it works.


很可能你正在显示生成的条形码图像通过这样的页面使用Image控件,对吗?然后你可以创建一个HTML 1x2表,并在第一行中将条形码图像和底行Code作为文本使用Label或任何你想要的。您可以将图像和文本居中。将条与文本分开的优点是输出质量。如果文本是位图的一部分,打印时它看起来会非常糟糕。但如果使用纯HTML文本,它看起来会很棒。
It's likely you are displaying the barcode image generated by such page by using an Image control, right? Then you could create an HTML 1x2 table and in the first row put the barcode image and the bottom row the "Code" as text using a Label or whatever you want. You can center both the image and the text. The advantage of separating the bar from the text is the output quality. If the text is part of the bitmap, it will looks really bad when printing. But it will looks great if you use pure html text.


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

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