How to Print a JPG in VB.Net

Written by jim campbell
  • Share
  • Tweet
  • Share
  • Email

VB.NET includes a printer class so you can print graphics files such as a JPG file. You use the "PrintGraphicControl" class to send the JPG image to the printer. The printer class handles any device management, and the PrintGraphicControl handles any graphics that need rendering to the printer device.

Skill level:

Other People Are Reading


  1. 1

    Click the Windows "Start" button and type "visual studio" in the command text box. Press "Enter" to open the Visual Studio VB.NET software.

  2. 2

    Click "File," and then click "Open Project." In the dialogue window, double-click the VB.NET project file you want to use to print the graphic.

  3. 3

    Right-click the form in Solution Explorer that contains the image you want to print. If an image isn't defined yet, you can use any code file to open the JPG image.

  4. 4

    Double-click the image you want to print. If you don't have an image file open already, add the following code to your file:

    Private Sub GraphicPrint(ByVal sender As Object, ByVal p As PrintPageEventArgs)

    p.Graphics.DrawImage(Image.FromFile("c:\myfile.jpg"), _

    End Sub

    Replace "c:\myfile.jpg" with your own image file path and name.

  5. 5

    Print the graphic. Use the following code to print the JPG file:

    AddHandler PrintGraphicControl.PrintPage, AddressOf Me.GraphicPrint


Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.