Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print an external image file?

Status
Not open for further replies.

tman72

Technical User
Jan 22, 2003
116
US
I have an application I wrote myself for finding scanned images and would like to be able to print these images from vb .net. (Long story short we are trying to go to electronic record keeping and store the hardcopy paper records off site due to limited space for keeping the originals) They are in tif format. Is this possible and how would I go about it? I have been able to load the image into a control on my form, and view it, but I don't know where to go to get to the point where I can print the image. I have searched the help files and other sites but they have only left me more confused. I am using VB .NET 2003.
 
yes you can and it is very easy

look for the printdocument and the graphics object.

add a printdocument and a printdialog
then create an image an call it Print_Image and then try this code
the drawimage method can also contain a width and height for when it goes of page.
Code:
Private Shared Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
            On Error GoTo errortrap

            e.Graphics.DrawImage(Print_Image, intx, inty)

            Exit Sub

errortrap:
            Resume Next
        End Sub

and this

Code:
printdialog1 = New PrintDialog
            printdialog1.Document = PrintDocument1

            Dim r As DialogResult = printdialog1.ShowDialog

            If r = DialogResult.OK Then
                PrintDocument1.DefaultPageSettings.Landscape = True
                PrintDocument1.Print()
            End If



Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Ok, not having any luck trying to create an image as you said I should do. Does it matter if my images that I want to view are in .TIF format?

Thanks for your help thus far.

Todd
 
nope, tiff is one of the formats .net knows. BTW if it can be seen in a picturebox it can be printed.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Thanks for the help. The way I was loading the file was causing problems, but I got that straightened out and was able to get it working.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top