Frage

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?

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top