生成条形码asp.net c# [英] generate Barcode asp.net c#

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

问题描述

线性代码128 =  new  Linear(); 

// 要编码的条形码数据
code128.Data = txttag.Text;
// 条形码符号类型。代码128支持类型:CODE128,CODE128A,CODE128B,CODE128C。
code128.Type = BarcodeType.CODE128;
// 为Code-128应用校验和数字
code128.AddCheckSum = < span class =code-keyword> true ;

/ *
*条码图像相关设置
* /

// 库中所有大小相关设置的微观单位。
code128.UOM = UnitOfMeasure.PIXEL;
// 条形模块宽度(X),默认为1像素;
code128.X = -5;
// 条形模块高度(Y),默认为60像素;
code128.Y = 15 ;

// 条形码图片左,右,上,下边距。默认值为0.
code128.LeftMargin = 0 ;
code128.RightMargin = 0 ;
code128.TopMargin = 0 ;
code128.BottomMargin = 0 ;
// dpi中的图像分辨率,默认为72 dpi。
code128。分辨率= 72 ;
// 创建条形码方向。
// 4个选项是:面向左,面向右,面向底部,面向顶部
code128.Rotate = Rotate.Rotate0;

/ *
*线性条形码人类可读的文字样式
* /

// 在条形码下显示人类可读的文字
code128.ShowText = true ;
// 在条形码数据末尾显示校验和数字。
code128。 ShowCheckSumChar = true ;
// 人类可读的文字字体大小,字体系列和样式
code128。 TextFont = new 字体( Arial ,9f,FontStyle.Regular);
// 条形码和文本之间的空格。默认值为6像素。
code128.TextMargin = 3 ;

// 生成Code-128并将条形码编码为gif格式
code128.Format = System.Drawing.Imaging.ImageFormat.Png;
code128.drawBarcode( D:\\ + txttag.Text + < span class =code-string> 。png);

// DataSet ds = Objcl.AddTag(txttag.Text,Convert.ToByte(code128) .drawBarcode()),20);
}





i已经使用此代码但我有输出图像但不需要我只需要在文本中p

解决方案

条形码不是文本。它们是图形图像,旨在是机器可读的,而不是人类可以阅读的文本。如果你想要文本,那么使用条形码代表的文章编号:人们可以阅读。


如果你已经在磁盘中有条形码图像,那么你可以在你的aspx页面中显示它们使用IMG标签,然后使用javascrip window.print()打印它们

当然,这依赖于浏览器的打印功能,并且将向用户显示打印对话框。如果您想避免显示打印对话框,那么您需要等外部工具的帮助,但它不是免费的,遗憾的是

Linear code128 = new Linear();

// Barcode data to encode
code128.Data = txttag.Text;
// Barcode symbology type. Code 128 supports types: CODE128, CODE128A, CODE128B, CODE128C.
code128.Type = BarcodeType.CODE128;
// Apply checksum digit for Code-128
code128.AddCheckSum = true;

/*
* Barcode Image Related Settings
*/
// Unit of meature for all size related setting in the library. 
code128.UOM = UnitOfMeasure.PIXEL;
// Bar module width (X), default is 1 pixel;
code128.X = -5;
// Bar module height (Y), default is 60 pixel;
code128.Y = 15;

// Barcode image left, right, top, bottom margins. Defaults are 0.
code128.LeftMargin = 0;
code128.RightMargin = 0;
code128.TopMargin = 0;
code128.BottomMargin = 0;
// Image resolution in dpi, default is 72 dpi.
code128.Resolution = 72;
// Created barcode orientation.
//4 options are: facing left, facing right, facing bottom, and facing top
code128.Rotate = Rotate.Rotate0;

/*
* Linear barcodes human readable text styles
*/
// Display human readable text under the barcode
code128.ShowText = true;
// Display checksum digit at the end of barcode data.
code128.ShowCheckSumChar = true;
// Human readable text font size, font family and style
code128.TextFont = new Font("Arial", 9f, FontStyle.Regular);
// Space between barcode and text. Default is 6 pixel.
code128.TextMargin = 3;

// Generate Code-128 and encode barcode to gif format
code128.Format = System.Drawing.Imaging.ImageFormat.Png;
code128.drawBarcode("D:\\" + txttag.Text + ".png");

//   DataSet ds = Objcl.AddTag(txttag.Text, Convert.ToByte(code128.drawBarcode()), 20);
}



i have already use this code but i am got output image but not needed i have only need in text p

解决方案

Barcodes are not text. They are graphic images which are intended to be machine readable, not text which a human can read. If you want text, then use the Article Number that the barcode represents: people can read that.


If you already have the barcode images in disk, then you can display them in your aspx page using IMG tag and then get them printed using javascrip window.print()
Of course, that relies on browser's printing functionality and a print dialog will be displayed to the user. If you want to avoid the print dialog to be displayed, then you'll need the help from an external tool like this but it's not free, sadly.


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

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