Note that there are some explanatory texts on larger screens.

plurals
  1. POHuge Whitespace exists to right after drawing image. Want to get rid of it
    text
    copied!<p>I'm using the following codeproject to build an asp.net website and so far everything is good. My only problem is after the barcode is generated, a huge whitespace exist to the right of the barcode. I've been playing with this and am unable to resolve it. </p> <p>Details below: </p> <p>Link to Code Project Article: <a href="http://www.codeproject.com/KB/aspnet/AspBarCodes.aspx?msg=3543809" rel="nofollow noreferrer">http://www.codeproject.com/KB/aspnet/AspBarCodes.aspx?msg=3543809</a></p> <p>Copy of the Font is here: <a href="http://trussvillemethodist.web01.appliedi-labs.net/IDAutomationHC39M.ttf" rel="nofollow noreferrer">http://trussvillemethodist.web01.appliedi-labs.net/IDAutomationHC39M.ttf</a></p> <pre><code> //Working Path string sWorkPath = ""; sWorkPath = this.Context.Server.MapPath(""); //Fonts PrivateFontCollection fnts = new PrivateFontCollection(); fnts.AddFontFile(sWorkPath + @"\IDAutomationHC39M.ttf"); FontFamily fntfam = new FontFamily("IDAutomationHC39M", fnts); Font oFont = new Font(fntfam, 18); // Get the Requested code sent from the previous page. string strCode = Request["code"].ToString(); //Graphics //I don't know what to set the width to as I can't call the MeasureString without creating the Graphics object. Bitmap oBitmaptemp = new Bitmap(40, 100); Graphics oGraphicstemp = Graphics.FromImage(oBitmaptemp); int w = (int)oGraphicstemp.MeasureString(strCode, oFont).Width + 4; // Create a bitmap object of the width that we calculated and height of 100 Bitmap oBitmap = new Bitmap(w, 100); // then create a Graphic object for the bitmap we just created. Graphics oGraphics = Graphics.FromImage(oBitmap); // Let's create the Point and Brushes for the barcode PointF oPoint = new PointF(2f, 2f); SolidBrush oBrushWrite = new SolidBrush(Color.Black); SolidBrush oBrush = new SolidBrush(Color.White); // Now lets create the actual barcode image // with a rectangle filled with white color oGraphics.FillRectangle(oBrush, 0, 0, w, 100); // We have to put prefix and sufix of an asterisk (*), // in order to be a valid barcode oGraphics.DrawString("*" + strCode + "*", oFont, oBrushWrite, oPoint); // Then we send the Graphics with the actual barcode Response.ContentType = "image/gif"; oBitmap.Save(Response.OutputStream, ImageFormat.Gif); oBitmap.Dispose(); oGraphics.Dispose(); oBrush.Dispose(); oFont.Dispose(); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload