Free Support Forum - aspose.com

Noise when printing barcode with aspose.Cells


#1

Hello,

we are testing Aspoce.Cells and Aspose.barcode and we have a little problem of “noise” in the barcode.

This is the “good” barcode printing with high resolution printer :
barcode good 150.jpg (582.6 KB)
The resolution of the barcode is 150.

This is the “bad” barcode printing with label printer (squix 4.3/200p) with resolution max of 203px
barcode bad 50 15.jpg (492.9 KB)
The resolution of the horizontal barcode is 50 and 15 for the vertical.

We can’t get a better result…
Have you an idea for our problem ?
We want to be sure that will work before buy the licence. :slight_smile:

Code :

        Dim STR_xls As String = "C:\programmes\scaldis\xls\Etiquette_Paquet_ISO_PAQ3.xlsm"

        Dim sheet As Worksheet
        Dim activeCell As Cell
        Dim XLSAPP_imp = New Workbook(STR_xls)

        Dim barcode As New MemoryStream
        Dim barcodeVertical As New MemoryStream

        Using generator As New BarCodeGenerator(EncodeTypes.Interleaved2of5, STR_PaqNumber)
            generator.CodeTextStyle.Location = CodeLocation.None
            generator.Resolution = 150
            generator.Save(barcode, BarCodeImageFormat.Jpeg)

            generator.RotationAngle = 90
            generator.Save(barcodeVertical, BarCodeImageFormat.Jpeg)
        End Using

        sheet = XLSAPP_imp.Worksheets().Item("Etiquette_CD")
        activeCell = sheet.Cells("B5")
        activeCell.Value = $"PAQ N° {vbCrLf}{STR_PaqNumber}"
        activeCell = sheet.Cells("B9")
        sheet.Pictures.Add(1, 10, 11, 12, barcodeVertical)
        activeCell = sheet.Cells("K3")
        sheet.Pictures.Add(9, 1, 11, 9, barcode)
        activeCell = sheet.Cells("B8")
        activeCell.Value = STR_PaqNumber

        Dim options As Aspose.Cells.Rendering.ImageOrPrintOptions = New Aspose.Cells.Rendering.ImageOrPrintOptions()
        options.PrintingPage = PrintingPageType.[Default]
        Dim sr As SheetRender = New SheetRender(XLSAPP_imp.Worksheets().Item("Etiquette_CD"), options)
        sr.ToPrinter(Configs.PrinterName)

#2

@Manoha

Can you please specify why you need low resolution?
We recommend to set barcode width and height properties in order to get good quality barcode but restricted in pixels size like as given below:

generator.CodeTextStyle.Location = CodeLocation.None;
generator.AutoSizeMode = AutoSizeMode.Nearest;
generator.BarCodeWidth.Pixels = 150;
generator.BarCodeHeight.Pixels = 50;
generator.Save("simple.jpg", BarCodeImageFormat.Jpeg);

Moreover, we hope that this shall resolve your problem and please feel free to write back to us if you need additional information.


#3

We use a low resolution, only because we don’t find a better solution about the quality of the barcode.

I adapted the code with your advice. It’s better but not perfect.

            generator.CodeTextStyle.Location = CodeLocation.None
            generator.AutoSizeMode = AutoSizeMode.Nearest

            generator.BarCodeWidth.Millimeters = 250
            generator.BarCodeHeight.Millimeters = 60
            generator.Save(barcode, BarCodeImageFormat.Jpeg)

            generator.RotationAngle = 90
            generator.Save(barcodeVertical, BarCodeImageFormat.Jpeg)

The horizontal barcode is perfect but the vertical is not ok…
barcode.jpg (100.7 KB)


#4

@Manoha

We have generated the barcodes with provided values and found no issue in it. Please have a look and share your feedback simple.jpg (15.8 KB)
barcodeVertical.jpg (17.7 KB).

Moreover, it is requested to kindly mention what is lacking in it. You may also try by setting height and width in inches as well.


#5

Yes, generate the picture of barcode is not a problem…

The problem comes when

  • we generate the barcode
  • save it in MemoryStream
  • Insert it in an Excel file generate by Aspose.Cells
  • Print the excel directly by the vb.net code.

#6

@Manoha

It is requested to kindly share your complete code supporting the defined process so that we could investigate either it is the issue of Aspose.BarCode or Aspose.Cells.


#7

the complete code is in the first post of this discussion.

is it enought ?


#8

@Manoha,

Thank you for your feedback.

We will investigate this scenario further using the code provided in the initial message and will update you accordingly.


#9

Hello,

do you have any updates about our problem ?

Regards
Mickaël


#10

@Manoha

We are unable to reproduce this issue using Aspose.BarCode for .NET 18.12 version. Please find the code file vb.zip (653 Bytes) and test it at your end. It is also requested to try to save Barcode image then print it manually not by sending directly to printer and share your feedback with us.


#11

Hello,

Yes, we don’t have any problems when we open the Excel file on the computer.
But when we print with a printer of 203dpi max, the vertical barcode is always bad quality. However, with a printer of 600dpi, the quality is better.

With the actual generation of barcode (using a font instead of picture), the impression’s quality is good.
However, we want to change our solution to avoid the Excel utilisation and this font.

We have also the problem when we print manually the barcode from jpg format.

Do you have any ideas to help us ?


#12

@Manoha

For generating barcode, you do not need Excel and it can be generated independently using our API. You may export it to image format, it totally depends upon your requirement.

Regarding printing barcode, if the generated barcode in JPG format is correct and the issue is with the printer then we may only suggest to change the printer.

Moreover, please elaborate the issue with font in detail and it would be great if you could share sample image.