I am using Spire.Barcode in my projects (Winforms and WPF C#) and my main purpose is to create barcode and print the output in Barcode printer - (I have two: Zebra 105SL and SATO CL4NX).
How I do it:
First I tried to create an image and print it (using file path),
after I receive not a desirable result, I change my logic and put the barcode image as background, and then print the window.
These two ways gives me the same result,
and both Zebra and SATO prints with very low quality and pixelated labels.
I'm sure it is not a problem about the printer device because if I use BarTender (for example) it's fine.
My BarcodeSetting object look like that:
- Code: Select all
//WPF application
BarcodeSetting barcodeSettings = new BarcodeSettings();
barcodeSettings.Data = myString;
barcodeSettings.Data2D = myString;
barcodeSettings.Type = BarCodeType.Code128; // (or Code39 - same issue);
barcodeSettings.TextFont = new Font("Arial", 10, FontStyle.Regular);
barcodeSettings.BarHeight = 15;
barcodeSettings.ShowText = true;
barcodeSettings.ShowCheckSumChar = false;
barcodeSettings.ForColor = Color.FromName("Black");
barcodeSettings.DpiX = 975;
barcodeSettings.DpiY = 273;
barcodeSettings.ShowTextOnBottom = true;
BarCodeGenerator generator = new BarcodeGenerator(BarcodeSettings);
using(Image barcode = generator.GenerateImage())
{
using(MemoryStream stream = new MemoryStream())
{
//Save barcode as a stream and make it as wpf window background
barcode.Save(stream, ImageFormat,Jpeg);
stream.Seek(0, SeekOrigin.Begin);
BitmapImage source = new BitmapImage();
source.BeginInit();
source.CacheOption = BitmapCacheOption.OnLoad;
source.StreamSource = stream;
source.EndInit();
myWindow.ImageSource = source;
PrintDialog pd = new PrintDialog();
pd.PrintQueue.DefaultPrintTicket.PageMediaSize = new PageMediaSize(264,37);
pd.PrintQueue = new PrintQueue(new PrintServer(), "SATO CL4NX (305 dpi)");
pd.PrintVisual(Window, string.empty);
}
}
I also tried
* Not saving into stream but save to localhost and using the file path to load image as background
* Without to define DpiX and DpiY
* Winforms and WPF
* Save as file and send the path to the printer
* Zebra 105SL 300DPI and SATO CL4NX 305dpi
everything is the same: pixelated barcode label.
Any idea?
Thanks alot