Showing posts with label image. Show all posts
Showing posts with label image. Show all posts

Thursday, 29 July 2021

Print from Picturebox VB.NET

Visual Studio 2019

 

 

 To print an Image from a picturebox try the following method( used for printing QR Codes in this instance)

 

Once the picturebox has been loaded and if required saved ad the ref to a  print document  highlighted


 Private Sub qrcodeGen(msg As String)


        Dim qrCode As New QRCodeEncoder
        qrCode.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE
        qrCode.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L
        Me.PictureBox1.Image = qrCode.Encode(msg, System.Text.Encoding.UTF8)
        PictureBox1.Image.Save("The path to save")

        PrintDocument1.Print()


    End Sub

 

then add the following 

Private Sub PrintDocument1_PrintPage(sender As Object, e As PrintPageEventArgs) Handles PrintDocument1.PrintPage


        e.Graphics.DrawImage(PictureBox1.Image, 0, 0)


    End Sub


The image in the picturebox should now print.

 

 

Multi Point USB Charger

  USB Plug Charger, 4-Port USB Fast Charger Plug with 33W Intelligent Quick Charge 3.0 Wall Charger, Multi USBPower Adapter UK Fast Charging...