Trying to print tif files to printer on button click

I am trying to print several files on a button click. The files are of type pdf and tif. The pdf files print correctly. The tif files are not being printed at all.
Protected Sub btnPrintContracts_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPrintContracts.Click
        Dim SRConn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("StikeData").ConnectionString)
        If SRConn.State <> Data.ConnectionState.Open Then
        End If
        Dim SQL_GetContracts As String = "SELECT LEFT(custname, 20) + '_' + enrollcustomer.OfferID + '.' + " _
        & " ContractType AS ContractFileName " _
        & " FROM dbo.EnrollCustomer " _
        & " INNER JOIN Pricing_Market.dbo.tbl_Ercot_Calendar " _
        & " ON CONVERT(VARCHAR(10), '2/19/2009', 101) = Pricing_Market.dbo.tbl_Ercot_Calendar.ercdate " _
        & " INNER JOIN dbo.tbl_Offer_1_Price " _
        & " ON enrollcustomer.dealcapid = tbl_offer_1_price.dealcapid " _
        & " WHERE CONVERT(varchar(10), approvedts, 101) = CASE WHEN " _
        & " Pricing_Market.dbo.tbl_Ercot_Calendar.Monday = 1 " _
        & " THEN (SELECT TOP 1 Pricing_Market.dbo.tbl_Ercot_Calendar.ercdate " _
        & " FROM Pricing_Market.dbo.tbl_Ercot_Calendar " _
        & " WHERE Pricing_market.dbo.tbl_Ercot_Calendar.Firday = 1 " _
        & " AND Pricing_Market.dbo.tbl_Ercot_Calendar.ercdate < CONVERT(VARCHAR(10), '2/19/2009', 101) " _
        & " ORDER BY ErcDate desc) " _
        & " ELSE DATEADD(DAY, -1, CONVERT(VARCHAR(10), '2/19/2009', 101)) End "
        Dim SRCommand As New System.Data.SqlClient.SqlCommand()
        SRCommand.Connection = SRConn
        SRCommand.CommandText = SQL_GetContracts
        Dim da As New System.Data.SqlClient.SqlDataAdapter(SRCommand)
        Dim dsContractList As New System.Data.DataSet()
        da.Fill(dsContractList, "ContractList")
        Dim psi As New ProcessStartInfo
        psi.UseShellExecute = True
        psi.Verb = "print"
        psi.WindowStyle = ProcessWindowStyle.Hidden
        psi.FileName = "D:\Inetpub\wwwroot\IEnergy_Dev\Contracts_Signed\"
        'psi.FileName = "D:\Inetpub\Test_IEnergy\Contracts_Signed\"
        'psi.FileName = "D:\Inetpub\\Contracts_Signed\"
        'Dim pathToExecutable As String = "AcroRd32.exe"
        'Dim SPrinter = "Canon iR400 PCL 5e on GMCI01 (from GMDAL1306) in session 3" 'Name Of printer
        'Dim sReport = "D:\Inetpub\\Contracts_Signed\"
        'Dim starter As New Diagnostics.ProcessStartInfo()
        'Dim Process As New Diagnostics.Process()
        Dim i As Integer = 0
        Do Until i = dsContractList.Tables(0).Rows.Count
            psi.FileName = psi.FileName + dsContractList.Tables(0).Rows(i).Item("ContractFileName")
            ''Dim starter As New Diagnostics.ProcessStartInfo(pathToExecutable, "/t " + sReport + " " + SPrinter + "")
            'starter.FileName = pathToExecutable + "/t " + sReport + " " + SPrinter
            'Process.StartInfo = starter
            ''try and close the process with 20 seconds delay
            'Dim iLoop As Int16 = 0
            ''check the process has exited or not
            'If Process.HasExited = False Then
            '    'if not then loop for 100 time to try and close the processwith 10 seconds delay
            '    While Not Process.HasExited
            '        System.Threading.Thread.Sleep(10000)
            '        Process.CloseMainWindow()
            '        iLoop = CShort(iLoop + 1)
            '        If iLoop >= 100 Then
            '            Exit While
            '        End If
            '    End While
            'End If
            psi.FileName = "D:\Inetpub\wwwroot\IEnergy_Dev\Contracts_Signed\"
            'psi.FileName = "D:\Inetpub\Test_IEnergy\Contracts_Signed\"
            'psi.FileName = "D:\Inetpub\\Contracts_Signed\"
            i = i + 1
        'Process = Nothing
        psi = Nothing
        If SRConn.State <> Data.ConnectionState.Closed Then
        End If
        Response.Write("<script language = 'jscript'>")
        Response.Write("alert('Previous day's contracts printed!')")
    End Sub

Open in new window

Who is Participating?
You can try installing this software on the server, it is freeware and allows you to view and print just about any image format.
Well, Adobe Acrobat reader accepts the Print verb, and will print PDF files.

My question is, what is your default program for opening TIF files?  All it does is open the default program when you use Process.Start(), and that program may not accept a print verb.
utlonghornjulieAuthor Commented:
Windows Picture and Fax Viewer
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

It looks like the Windows Picture and Fax viewer does not support the "print" verb, but it does have a "PrintTo" verb, you will have to check to see if the file extensions is .tif, if so use "PrintTo"
utlonghornjulieAuthor Commented:
I think the program is Microsoft Office Document Imaging, not Windows Picture and Fax Viewer.
You could see if you have another program you can open the tiff with, like MS Paint or something, and then set that as the default program, then try printing.
utlonghornjulieAuthor Commented:
How can I do that?
Hold in the left Shift key, and right click on a Tiff file, you should see an "Open With..." command in the menu.  Click on that, then pick a different program, and make sure the checkbox is checked that says "always use this program".

Also, you will need to do this on the server that you are hosting the website, which is probably an intranet server if you are printing reports.
utlonghornjulieAuthor Commented:
What programs have a print function?
MS paint does, on Windows Vista anyways, I don't know what OS you are on.  You'll just have to try a couple of different programs that are able to open TIFF files.  If all else fails you can download a free TIFF viewer from somewhere that allows printing.
utlonghornjulieAuthor Commented:
The server that the files are sitting on runs on Windows Server 2003 Standard X64 Edition with SP2. I tried all the programs, and nothing is working.
If you right click on the TIFF file on the server, do you see a Print command in the menu?  Does clicking that do anything?
utlonghornjulieAuthor Commented:
The Photo Printing Wizard dialog box pops up.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.