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
Click the Windows "Start" button and type "visual studio" in the command text box. Press "Enter" to open the Visual Studio VB.NET software.
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.
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.
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"), _ p.Graphics.VisibleClipBounds)
Replace "c:\myfile.jpg" with your own image file path and name.
Print the graphic. Use the following code to print the JPG file:
AddHandler PrintGraphicControl.PrintPage, AddressOf Me.GraphicPrint
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for