0

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

3
Contributors
4
Replies
12
Views
5 Years
Discussion Span
Last Post by aldeene
-1
PictureBox1.Image.Save("C:\img.jpg")
If My.Computer.FileSystem.FileExists("C:\img.jpg") Then
   Print("C:\img.jpg")
End If

This is untested but it should work.

0

Print("C:\img.jpg")

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
        printDoc.Print()
    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

-1

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

PrintDocument1.Print()

Edited by aldeene: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.