We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Barcode not printing

Hello!

I have this code:

Private Sub BuildCode()
    Dim barcode As String = TextBox1.Text + "%" + TextBox2.Text + "&" + TextBox6.Text + "*"
    'TextBox3.Text = barcode
    SfBarcode1.Text = barcode
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    BMP = New Bitmap(GroupBox1.Width, GroupBox1.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
    'BMP.SetResolution(300, 300)
    GroupBox1.DrawToBitmap(BMP, New Rectangle(0, 0, GroupBox1.Width, GroupBox1.Height))
    Dim pd As New PrintDocument
    Dim pdialog As New PrintDialog
    AddHandler pd.PrintPage, (Sub(s, args)
                                  args.Graphics.DrawImage(BMP, 0, 0)
                                  args.HasMorePages = False
                              End Sub)
    pdialog.ShowDialog()
    pd.PrinterSettings.PrinterName = pdialog.PrinterSettings.PrinterName
    pd.Print()
End Sub

Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
    BuildCode()
End Sub

When I assing value to syncfusion barcode control, it builds fine, it shows the barcode on form, but when I print instead of barcode is nothing. If i assign the value to a textbox control with a Code128 font it prints just fine. 

What could it be?


3 Replies

CM Chinnu Muniyappan Syncfusion Team July 7, 2016 12:24 PM UTC

Hi Cernat, 

Thank you for contacting Syncfusion support. 

We have created a workaround sample for exporting the barcode as image and inserting the image to the group box and print the group box control for your reference, please refer the below code snippet and sample for more details. 

       'initialize the barcode control 
        Dim barcode As SfBarcode = New SfBarcode() 
 
        'set the barcode symbology type 
        barcode.Symbology = BarcodeSymbolType.Code128A 
 
        'set the input text 
        barcode.Text = TextBox1.Text 
        
        'export the barcode control as image 
        PictureBox1.Image = barcode.ToImage(PictureBox1.Size) 
 
Sample link: 

Could you please try this and let us know whether this meet your actual requirement. 

Regards, 
Chinnu 



CC Cernat Catalin July 7, 2016 12:44 PM UTC

Thanks alot for your kind reply, but ToImage is not a member of SfBarcode, the compiler says.

What could be wrong?


CM Chinnu Muniyappan Syncfusion Team July 8, 2016 05:19 AM UTC

Hi Cernat, 

Thank you for your update. 

The barcode to image conversion support is available in our latest versions (14.2.0.26) only, could you please update to our latest versions and get this support. 
   

Regards, 
Chinnu

Loader.
Up arrow icon