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")
End Sub

Private Sub PrintDocHandler(ByVal sender As Object, ByVal ev As Printing.PrintPageEventArgs)

    ev.Graphics.DrawImage(picBarcode.BackgroundImage, nud_MarginH.Value, nud_MarginW.Value, nud_MarginWBrcode.Value, nud_MarginHBrcode.Value)

End Sub

Private Sub Preview_Click(sender As Object, e As EventArgs) Handles Preview.Click

    AddHandler PrintDoc.PrintPage, AddressOf PrintDocHandler
    pd_PrintDialog.PrinterSettings.Copies = nud_Count.Value
    PrintPreviewDialog1.WindowState = FormWindowState.Maximized
    PrintPreviewDialog1.Document = PrintDoc
    PrintPreviewDialog1.PrintPreviewControl.Zoom = 1
    PrintPreviewDialog1.PrintPreviewControl.AutoZoom = False

end sub

End Class

the code is work but it's only print one.

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:

1)Get Bitmap

'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.

But the logic is pretty straight forward.

I hope this helps!

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.

I know there are a lotta free online barcode generators but still I wanna know, barcode font,control,plugin,addin and library can all generate barcode? What's the difference among them all?

What's the difference among them all?

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.