I created a barcode as an image in my ASP.NET MVC app.
BarcodeLib.Barcode barcode = new BarcodeLib.Barcode()
{
IncludeLabel = false,
Alignment = AlignmentPositions.LEFT,
Width = element.BarcodeWidth,
Height = element.BarcodeHeight,
RotateFlipType = RotateFlipType.RotateNoneFlipNone,
BackColor = Color.Transparent,
ForeColor = Color.Black,
ImageFormat = System.Drawing.Imaging.ImageFormat.Png
};
This will create a barcode with the BarcodeLib.
How do I convert it to an XImage of PDFsharp?
Image img = barcode.Encode(TYPE.CODE128, "123456789");
gfx.DrawImage(xImage, 0, 0, 100, 100);
Solved it this way:
Image img = barcode.Encode(TYPE.CODE128, Name); // this is the image
MemoryStream strm = new MemoryStream();
img.Save(strm, System.Drawing.Imaging.ImageFormat.Png);
XImage xfoto = XImage.FromStream(strm);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With