I created a barcode and displayed it in a picture box and i want to print it.
i can't figure how to do it..

If My.Computer.FileSystem.FileExists("C:\img.jpg") Then
End If

This is untested but it should work.


This does not print to a printer.

Try this instead

Dim WithEvents printDoc As New Printing.PrintDocument()

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    End Sub

    Private Sub PrintImage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles printDoc.PrintPage
        e.Graphics.DrawImage(PictureBox1.Image, e.MarginBounds.Left, e.MarginBounds.Top)
    End Sub

Note: This prints to the default printer and the image is printed in the top left corner at its native size

figured it out yesterday..

just want to share this code

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As   System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        Dim newMargins As System.Drawing.Printing.Margins
        newMargins = New System.Drawing.Printing.Margins(0.2, 0.2, 0.2, 0.2)
        PrintDocument1.DefaultPageSettings.Margins = newMargins
        e.Graphics.DrawImage(barcode, 0, 0)
    End Sub

the I used


Edited 5 Years Ago by aldeene: n/a

This question has already been answered. Start a new discussion instead.