- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 asp.net 页面中显示条形码。已经下载带有示例代码的 zen 条形码渲染器。我尝试了 sample ,它对我来说工作正常。一旦我在我的代码中尝试,条形码标签显示为空。我检查了示例代码,我没有发现任何区别,只有数据传输不同。这是我试过的。
<barcode:BarcodeLabel ID="BarcodeLabel1" runat="server" BarcodeEncoding="Code39NC" LabelVerticalAlign="Bottom" Text="12345"></barcode:BarcodeLabel>
if (!IsPostBack)
{
List<string> symbologyDataSource = new List<string>(
Enum.GetNames(typeof(BarcodeSymbology)));
symbologyDataSource.Remove("Unknown");
barcodeSymbology.DataSource = symbologyDataSource;
barcodeSymbology.DataBind();
}
这是函数
BarcodeSymbology symbology = BarcodeSymbology.Unknown;
if (barcodeSymbology.SelectedIndex != 0)
{
symbology = (BarcodeSymbology)1;
}
symbology = (BarcodeSymbology)1;
string text = hidID.Value.ToString();
string scaleText = "1";
int scale;
if (!int.TryParse(scaleText, out scale))
{
if (symbology == BarcodeSymbology.CodeQr)
{
scale = 3;
}
else
{
scale = 1;
}
}
else if (scale < 1)
{
scale = 1;
}
if (!string.IsNullOrEmpty(text) && symbology != BarcodeSymbology.Unknown)
{
barcodeRender.BarcodeEncoding = symbology;
barcodeRender.Scale = 1;
barcodeRender.Text = text;
}
符号系统从下拉列表中设置为 Code39NC。比例为 1,文本来自其他形式,该值也正在传递。 bacodelable 仍然只显示值(value)而不是条形码图片。
最佳答案
这里有两个使用 ZXing
的代码示例创建一个 (QR) 条形码作为图像和 base64 编码的字符串。这两个选项都可以与 <img />
一起使用标记以在页面中嵌入条形码。
这不是 ASP.NET 控件。它是一个从文本创建条形码的库。
// First Text to QR Code as an image
public byte[] ToQRAsGif(string content)
{
var barcodeWriter = new BarcodeWriter
{
Format = BarcodeFormat.QR_CODE,
Options = new EncodingOptions
{
Height = this._h,
Width = this._w,
Margin = 2
}
};
using (var bitmap = barcodeWriter.Write(content))
using (var stream = new MemoryStream())
{
bitmap.Save(stream, ImageFormat.Gif);
stream.Position = 0;
return stream.GetBuffer();
}
}
// From Text to QR Code as base64 string
public string ToQRAsBase64String(string content)
{
var barcodeWriter = new BarcodeWriter
{
Format = BarcodeFormat.QR_CODE,
Options = new EncodingOptions
{
Height = _h,
Width = _w,
Margin = 2
}
};
using (var bitmap = barcodeWriter.Write(content))
using (var stream = new MemoryStream())
{
bitmap.Save(stream, ImageFormat.Gif);
return String.Format("data:image/gif;base64,{0}", Convert.ToBase64String(stream.ToArray()));
}
}
希望对您有所帮助!快乐编码。
更新:这是他们在 codeplex 上的产品页面的链接:https://zxingnet.codeplex.com/
关于c# - 在 ASP.NET Web 窗体中呈现条形码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36291377/
我有一个正在动态生成的条形码,并希望传递给 gsp,该 gsp 稍后将变成 pdf。我不需要出于自己的任何目的保留条形码,只想将图像从 Controller 传递到 gsp。 有没有办法渲染作为变量传
我正在研究苹果“passkit”框架。我已经制作了 lolipop 优惠券,正如它在 guide 中所说的那样. - 创建证书(Apple Dev 网站)我已经编译了.pkpass。 现在我必须使用动
我有这样的代码 $('.testbarcode').barcode('1234567', "code128"); 当我设置样式时它是折线,那么我如何才能将此条码的宽度设置得
我正在将 Visual Basic 应用程序转换为 Python Django。目前,它具有条形码功能来处理商店的销售。这可以用 python django 实现吗? 最佳答案 如果您对条形码功能的定
我正在尝试按照此示例使用条形码 API https://github.com/googlesamples/android-vision/tree/master/visionSamples/barcod
这是我到目前为止所得到的: def encodeFive(zip): zero = "||:::" one = ":::||" two = "::|:|" t
我正在尝试创建具有本文所示格式的条形码:http://www.thebookdesigner.com/2009/10/self-publishing-basics-deciphering-the-bo
我需要一些关于如何从 bmp 文件中获取 12 位条形码的指导,我完全不知道如何处理这个问题。我首先将图像读入 bitmam,我该如何继续? 例子:下图的条码是081034489030。我如何获得这些
谁能告诉我从哪里开始编码以便从 C# 中的 OPOS(Datalogic Magellan 设备)加权和条形码扫描中获取数据?例如,在这种情况下我应该使用什么库和什么函数。我一无所知,因为我已经花了很
使用 zxing,我设法将 Code39 条形码保存为 PNG,但它只显示条形,没有数字。我怎样才能在一个 PNG 中包含条形码和编号? KI 最佳答案 您无法使用 zxing 添加号码。您可以做一些
我正在尝试将扫描的条形码用作 SQL 查询中的变量。我正在使用 Google ML Kit Quick Start项目。我有一个使用 jtds1.3.1 制作的连接和查询功能。我只是无法获得要在查询中
我尝试让程序从下面的代码中读取 EAN13,但它不起作用 func metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metada
我必须读取 PDF 文件中的数据矩阵代码,我正在研究其可能性,对此我有一些疑问: 1.- 我与 Itext 合作,我正在寻找有关使用此库读取此 QR 条形码的可能性的信息,但我没有相关结果,这可能吗?
文档和头文件不包含任何与支持 3D 条形码相关的信息。但是,明确提到 AVMetadataMachineReadableCodeObject 支持一维和二维条码。因此,有人知道 AVFoundatio
我一直在寻找解决方案,到目前为止,我认为对我的项目来说最好的解决方案是使用免费的 Code 39 字体。但是,我已经尝试打印一些样本,但我的条形码扫描仪无法读取它们。 我进行了更多研究,偶然发现了 t
生成 3 of 9 很容易条形码使用 Font() Font f = new Font("Free 3 of 9", 80); this.Font = f; Label l = new Label()
愚蠢的我,我以为只要用条形码字体写一些文本,就会让扫描仪读取它。看来我错了。 所以在阅读了一些关于 code128 条形码的文档之后,我了解到: 条形码以(103、104 或 105 取决于类型)开头
我想在 WPF 应用程序中区分(条形码)扫描仪和键盘输入。 我需要的是每当我的扫描仪提供数据时发生的事件。 在我的应用程序中有一个特殊的字段,它将填充来自扫描仪的输入。因此,如果用户关注其他领域,我不
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
是否可以将 ZPL 和二进制数据用于 aztec 条形码? 我尝试使用BluetoothConnection写入发送以UTF8和字节数据编码的字符串连接数组/ String zplStart; byt
我是一名优秀的程序员,十分优秀!