2014-04-11 33 views
-2

條形碼是由控制器通過並顯示在視圖中的字符串:如何產生鑑於條形碼

@shelfEdge.Barcode 

我如何得到這個條形碼格式顯示,僅下載條形碼字體的事並將其添加到課堂?

任何想法表示歡迎

UPDATE 伊夫使用後在Free Barcode API for .NET從安德烈·施耐德...

BarcodeLib.Barcode barcode = new BarcodeLib.Barcode() 
    { 
     IncludeLabel = true, 
     Alignment = AlignmentPositions.CENTER, 
     Width = 300, 
     Height = 100, 
     RotateFlipType = RotateFlipType.RotateNoneFlipNone, 
     BackColor = Color.White, 
     ForeColor = Color.Black, 
    }; 

    model.BarcodeImage = barcode.Encode(TYPE.CODE128B, "123456789"); 

然後在視圖@Model.BarcodeImage

但是,這將引發errro:

Compiler Error Message: CS0012: The type 'System.Drawing.Image' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. 

Source Error: 




Line 54:        </td> 
Line 55:        <td width="30%"> 
Line 56:         @Model.BarcodeImage 
Line 57:        </td> 
Line 58:       </tr> 

和我有引用system.drawing項目??

+1

您需要使用第三方組件(ComponentOne的,閱讀Aspose等) – Mahmoodvcs

+0

你可以嘗試用syncfusion條碼 – SivaRajini

+0

感謝您的回覆球員,請參閱編輯....誰投了-1請解釋你的理由? – John

回答

2

您需要生成條形碼作爲圖像,然後像往常一樣在頁面上呈現圖像。看到這個免費的圖書館:

http://barcoderender.codeplex.com/

+0

感謝您的回覆,請參閱編輯 – John

+1

@John你讀過他的新錯誤嗎?這是另一個問題 - 一個根本。運行到「組件到底是什麼,爲什麼我需要將它添加到引用中,如果我想使用它?」 – TomTom

+0

@John錯誤是不言自明的,只需在項目中添加一個對System.Drawing的引用,它就會變成gonne。 – Oscar

0
@ViewBag.mostrar = "data:image/jpg;base64," + 
Convert.ToBase64String((byte[])model.BarcodeImage); 

我希望比這個幫助你