how can i multiple barcode image in print preview and print it?
here is the code of mine:
Public Class Form1
Dim PrintDoc As Printing.PrintDocument = New Printing.PrintDocument()
Dim pd_PrintDialog As New PrintDialog
Private Sub TextBox1_TextChanged_1(sender As Object, e As EventArgs) Handles txtBarcode.TextChanged
picBarcode.BackgroundImage = Code128(txtBarcode.Text, "A")
Private Sub PrintDocHandler(ByVal sender As Object, ByVal ev As Printing.PrintPageEventArgs)
I wrote some software like this once. I used the width/height of the barcode bitmap and the size of the paper to determin the spacing to get the maximum amount per sheet printed.
I don't have have any source code on hand, but the basic concept was:
'Call your bitmap code128 function and store the bitmap
2)Calculate Width of Page
'If printing 8.5x11 you will have to know the resolution of the printer(200 in my case)
Dim szPaperInPixels As Size = New Size(8.5 * 200, 11 * 200)
3)Calculate Number of bitmaps (W & L of Page)
Dim iBitmapsWide As Integer = szPaperInPixels.Width / (picBarCode.Width + 10) '5 pixels of space on each side.
Dim iBitmapsHigh As Integer = szPaperInPexels.Height / (picBarCode.Height + 10) ' 5 pixels of space.
4)Copy by looping.
'Place your draw code in the loop with the given information
For i = 1 to iBitmapsHigh 'Length
'Check to see what row you are on and add padding accoringly
Dim iPaddingHeight As Integer = 0
If i > 1 Then iPaddingHeight = ((picBarCode.Height + 5) * i)
For j = 1 to iBitmapsWide
Dim iPaddingWidth As Integer = 0
If j > 1 Then iPaddingWidth = ((picBarCode.Width + 5) * j)
'g = Graphics
g.DrawImage(picBarCode, New Point(iPaddingWidth + 5, iPaddingHeight + 5))
Again, I do not have the source code from the original application to verify this.
Thanks for your nice info. But I wonder whether I need the help of some other barcode processors<LINK SNIPPED> or image printing tools? I am almost a green hand on this problem. Forgive my stupid question. Thanks in advance.
For simple 1D barcodes like 3 of 9 or 128, you shouldn't need a barcode generator, just a font. The encoding of the value itself is straightforward with start-stop characters and in the case of code 128, a simple check digit calculation before the stop character. From there it's just a matter of printing text rather than generating an image.
First and foremost what I look for is what barcode symbologies are supported by a library. The usual 1D suspects are generally supported because they're super easy to write. I could write my own code39 barcode reader and writer in less than a day.
2D barcodes are harder because they nearly always include an encoding step that can be pretty involved. Those are where having a good third party library is invaluable. From there the cost of the library, support from the vendor, and robustness of recognition/generation are key points.
I've worked with a lot of these libraries (usually the commercial ones), and it's surprisingly difficult to find one that has good support of barcoding with a good licensing model. Free libraries thusfar have always fallen short in terms of my needs, unfortunately.