Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top