I draw an image with a barcode in C#. I have the following code:

Drawing = Graphics.FromImage(img);

Brush textBrush = new SolidBrush(Color.Black);
drawing.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;
drawing.Clear(Color.White);
drawing.DrawString(text, barcodeFont, textBrush, 0, 0);

the variable text contains:

27346,

with an asterix before and afterwards placed. Because, the barcode should start and stop with an asterix. (I am using barcode)

Unfortunately, the asterisks are not included in the barcode but before and afterwards placed.

enter image description here

What is wrong?

有帮助吗?

解决方案

Are you sure that your barcode font contains characters than can be used to represent an asterisk? If it does, why not append the astrisks to your text string before calling drawstring? If it doesn't, you'll need a different barcode font.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top