2017-09-04 19 views
2

IDAutomationHC39Mバーコードが生成されていますが、生成後およびスキャン後に値が取得されません。バーコードをスキャンした後に値が取得されないIDAutomationHC39M

私のコードは、このコードで間違っているものを

public void generateBarcode(int id) 
    { 
     if (plBarCode != null) 
     { 
      string barCode = ""; 

      barCode = "*"+Convert.ToString(id)+"*"; 
      System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image(); 
      using (Bitmap bitMap = new Bitmap(barCode.Length * 70, 70)) 
      { 
       using (Graphics graphics = Graphics.FromImage(bitMap)) 
       { 
        Font oFont = new Font("IDAutomationHC39M", 30); 
        PointF point = new PointF(2f, 2f); 
        SolidBrush blackBrush = new SolidBrush(Color.Black); 
        SolidBrush whiteBrush = new SolidBrush(Color.White); 
        graphics.FillRectangle(whiteBrush, 0, 0, bitMap.Width, bitMap.Height);      
        int w = barCode.Length * 40;      
        Graphics oGraphics = Graphics.FromImage(bitMap);      
        PointF oPoint = new PointF(2f, 2f); 
        SolidBrush oBrushWrite = new SolidBrush(Color.Black); 
        SolidBrush oBrush = new SolidBrush(Color.White);   
        oGraphics.FillRectangle(oBrush, 0, 0, w, 100);      
        oGraphics.DrawString("*" + barCode + "*", oFont, oBrushWrite, oPoint); 

       } 
       using (MemoryStream ms = new MemoryStream()) 
       { 
        bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png); 
        byte[] byteImage = ms.ToArray(); 

        Convert.ToBase64String(byteImage); 
        imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage); 
       } 
       plBarCode.Controls.Add(imgBarCode); 
      } 
     } 

    } 

です。

enter image description here

どのように私は私のコードの任意の助けを生成する必要がありますか?ここで

+0

現在のコードでは、それぞれの側に* 2 * '* 'のバーコードが生成されます。 'oGraphics.DrawString()'関数呼び出しから余分な '' * ''を削除してください。 –

+0

また、*を削除した後も生成されていません。 –

+0

barCode = "**" + Convert.ToString(id)+ "**";このような? –

答えて

0

は、バーコードフォントを使用すると、文字の少量をエンコードしようとしている場合は、ために良いアイデアかもしれ...

http://idautomation.blogspot.in/2011/07/top-5-reasons-why-barcode-font-wont.html

をスキャンしない理由のトップ5つの理由でありますバーコードに最低4文字を読み取るように設定されているので、スキャナが最小限の量をスキャンできることを確認してください。一方、バーコードにエンコードされている文字が多すぎると、大きすぎて正しくスキャンされません。フォントサイズを小さくして再スキャンするとこの問題が解決される可能性があります。

関連する問題