"what should i put in the place of path and imgPath"
public void CreateBarcode(string data) {
imgPath = string.Format("{0}{1}.png", path, data);
Bitmap barcode = new Bitmap(1, 1);
Font threeOfNine = new Font("IDAutomationHC39M", 60,
System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point);
Graphics graphics = Graphics.FromImage(barcode);
SizeF dataSize = graphics.MeasureString(data, threeOfNine);
barcode = new Bitmap(barcode, dataSize.ToSize());
graphics = Graphics.FromImage(barcode);
graphics.Clear(Color.White);
graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;
graphics.DrawString(data, threeOfNine, new SolidBrush(Color.Black), 0, 0);
graphics.Flush();
threeOfNine.Dispose();
graphics.Dispose();
barcode.Save(imgPath);
}
I assume that you got this code from a website, and haven't bothered too much to look at what it does.
That code fragment creates a barcode in an Image class instance, and saves it to a file - from your description you don't want to do that, you just want to print the barcode.
So, there are two ways to do this:
1) Remove all references to path, and instead of Saving the bitmap, return it to your application as an Image and print that directly onto your print context, or PrintDocument.
2) Use some of that code to print the barcode directly onto your print context or PrintDocument.
The latter will give you better results, as the barcode will be printed at a suitable resolution for teh actual print job, instead of being printed initially to a "random" bitmap resolution, then redrawn to the actual print resolution, which will introduce both artefacts and errors which will degrade the readability of the final barcode.