我无法处理条形码的问题。我是在Excel中从我的文件中传递字符串,例如51453125312453。我在我的模型中使用了Spire.Barcode
private void GenerateBarcode()
{
BarcodeSettings st = new Spire.Barcode.BarcodeSettings();
st.Code128SetMode = Spire.Barcode.Code128SetMode.Auto;
//st.Data = Ilosc.ToString("F6") + "*" + Partia;
st.TextFont = new System.Drawing.Font("Arial", 16);
st.ShowTopText = false;
st.ShowTextOnBottom = true;
st.ImageWidth = 100;
Spire.Barcode.BarCodeGenerator bg = new Spire.Barcode.BarCodeGenerator(st);
HeaderBarcode = bg.GenerateImage().ToString();
//bg.GenerateImage();
}还有我的绳子
private string headerBarcode;
public string HeaderBarcode
{
get
{
return headerBarcode;
}
set
{
if (headerBarcode != value)
{
headerBarcode = value;
GenerateBarcode();
NotifyPropertyChanged(nameof(HeaderBarcode));
}
}
}在我的打印预览a有这个System.Drawing.Bitmap而不是条形码。你能帮我把这事做好吗?
发布于 2018-09-24 06:58:32
您在这一行中的错误:
HeaderBarcode = bg.GenerateImage().ToString();GenerateImage() -返回Bitmap,因此当您试图将Bitmap转换为string时,您将得到一个类System.Drawing.Bitmap的名称。
您需要保存为图像并打开它。
bg.GenerateImage().Save("Barcode.png");
System.Diagnostics.Process.Start("Barcode.png");https://stackoverflow.com/questions/52473700
复制相似问题