- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我已经创建了一个代码来在条形码打印机上打印条形码,但现在试图将文本框中产品的价格添加到打印中
这是我的代码
private void frmAddProduct_Load(object sender, EventArgs e)
{
string barcode = txtCode.Text;
Bitmap bitm = new Bitmap(barcode.Length * 40, 110);
using (Graphics graphic = Graphics.FromImage(bitm))
{
Font newfont = new Font("IDAutomationHC39M", 14);
PointF point = new PointF(2f, 2f);
SolidBrush black = new SolidBrush(Color.Black);
SolidBrush white = new SolidBrush(Color.White);
graphic.FillRectangle(white, 0, 0, bitm.Width, bitm.Height);
graphic.DrawString("*" + barcode + "*", newfont, black, point);
}
using (MemoryStream Mmst = new MemoryStream())
{
bitm.Save("ms", ImageFormat.Jpeg);
pictureBox1.Image = bitm;
pictureBox1.Width = bitm.Width;
pictureBox1.Height = bitm.Height;
}
}
private void btnCodePrint_Click(object sender, EventArgs e)
{
short numCopies = 0;
numCopies = Convert.ToInt16(txtCodeNo.Text);
PrintDialog pd = new PrintDialog();
pd.PrinterSettings = new PrinterSettings();
if (DialogResult.OK == pd.ShowDialog(this))
{
PrintDocument pdoc = new PrintDocument();
pdoc.PrintPage += new PrintPageEventHandler(pqr);
pdoc.PrinterSettings.Copies = numCopies;
pdoc.Print();
}
}
这就是我目前遇到的问题,我想将文本框中的价格添加到所附图像中条形码上方或下方的条形码中,但我似乎无法找到一种方法来完成这项工作,我所做的一切尝试使条形码不起作用
编辑
我试过了,但价格显示在条形码上方
string barcode = txtCode.Text;
string price = txtPprice.Text;
Bitmap bitm = new Bitmap(barcode.Length * 40, 110);
using (Graphics graphic = Graphics.FromImage(bitm))
{
Font newfont = new Font("IDAutomationHC39M", 14);
Font newfont2 = new Font("Arial", 14);
PointF point = new PointF(2f, 2f);
SolidBrush black = new SolidBrush(Color.Black);
SolidBrush white = new SolidBrush(Color.White);
graphic.FillRectangle(white, 0, 0, bitm.Width, bitm.Height);
graphic.DrawString("*" + price + "*", newfont2, black, point);
graphic.DrawString("*" + barcode + "*", newfont, black, point);
最佳答案
这是你的问题,point
实际上是你绘制条形码的点,你也用它来绘制你的价格。您需要创建一个新点,即不同的坐标
...
// a new point for your price
PointF pointPrice = new PointF(20f, 20f);
// Draw your price
graphic.DrawString("*" + price + "*", newfont2, black, pointPrice);
// Draw your barcode
graphic.DrawString("*" + barcode + "*", newfont, black, point);
只需使用 pointPrice
的值来确定您想要的放置位置
祝你好运
关于c# - 将价格添加到条形码生成的序列号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50340872/
我有一个正在动态生成的条形码,并希望传递给 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
我是一名优秀的程序员,十分优秀!