条形码是从控制器传递并显示在视图上的字符串:
@shelfEdge.Barcode
如何让它以条形码格式显示,只需下载条形码字体并将其添加到类中?
欢迎任何想法
更新 我使用了Andrei Schneider的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
但这会引发错误:
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??