Jacque
Best Answer
NOTE: The .NET Forms Control (WinForms) does not have an "Auto" encoding mode. For the newer .NET versions, IDAutomation recommends using the .NET Generator, which includes the auto mode in Data Matrix and QR Code. This auto mode can reduce the symbol size in many situations.
We tested with a larger data set in WinForms and successfully generated a Data Matrix containing 1,500 characters, which scanned without issue. Regarding your code, we noticed a few minor points that could prevent a scannable barcode from being produced. In the updated example below, we ensured that the encoding mode is set correctly, added the missing backslash in the save path, and changed the output location to a user folder to avoid any administrative permission conflicts. With these adjustments, the code ran successfully and produced a scannable barcode. Give it a try and let us know if you have further questions.
Imports IDAutomation.Windows.Forms.DataMatrixBarcode
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim Cb1 As New DataMatrixBarcode()
' Set barcode properties
Cb1.ApplyTilde = False
Cb1.CaptionAbove = ""
Cb1.CaptionBelow = ""
Cb1.CaptionBottomAlignment = System.Drawing.StringAlignment.Center
Cb1.CaptionBottomColor = System.Drawing.Color.Black
Cb1.CaptionBottomSpace = "0.10"
Cb1.CaptionFontAbove = New System.Drawing.Font("Times New Roman", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
Cb1.CaptionFontBelow = New System.Drawing.Font("Times New Roman", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
Cb1.CaptionTopAlignment = System.Drawing.StringAlignment.Center
Cb1.CaptionTopColor = System.Drawing.Color.Black
Cb1.CaptionTopSpace = "0.10"
Cb1.DataToEncode = "IDAutomation.com, Inc."
Cb1.DoPaint = True
Cb1.EncodingMode = EncodingModes.Base256
Cb1.FitControlToBarcode = True
Cb1.LeftMarginCM = "0.000"
Cb1.Location = New System.Drawing.Point(12, 12)
Cb1.Size = New System.Drawing.Size(150, 150)
Cb1.XDimensionCM = "0.185"
Cb1.XDimensionMILS = "73.0000"
' Add control to the form
Me.Controls.Add(Cb1)
' Save barcode as BMP
Dim codbar As System.Drawing.Image = Cb1.Picture
Dim codbmpOri As New System.Drawing.Bitmap(codbar)
codbmpOri.Save("C:UsersAUserDocumentsdocumenttest.bmp", System.Drawing.Imaging.ImageFormat.Bmp)
End Sub
End Class
Posted 213 day(s) ago
|