Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Trying to print tif files to printer on button click

Posted on 2009-02-18
13
Medium Priority
?
544 Views
Last Modified: 2012-08-14
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
            SRConn.Open()
        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
 
        'localhost
        psi.FileName = "D:\Inetpub\wwwroot\IEnergy_Dev\Contracts_Signed\"
 
 
        ''test
        'psi.FileName = "D:\Inetpub\Test_IEnergy\Contracts_Signed\"
 
        ''production
        'psi.FileName = "D:\Inetpub\iEnergyPricing.com\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\iEnergyPricing.com\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")
            Diagnostics.Process.Start(psi)
            ''Dim starter As New Diagnostics.ProcessStartInfo(pathToExecutable, "/t " + sReport + " " + SPrinter + "")
            'starter.FileName = pathToExecutable + "/t " + sReport + " " + SPrinter
            'Process.StartInfo = starter
            'Process.Start()
            ''try and close the process with 20 seconds delay
            'System.Threading.Thread.Sleep(30000)
 
            'Process.CloseMainWindow()
            '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
 
            'localhost
            psi.FileName = "D:\Inetpub\wwwroot\IEnergy_Dev\Contracts_Signed\"
 
            ''test
            'psi.FileName = "D:\Inetpub\Test_IEnergy\Contracts_Signed\"
 
            ''production
            'psi.FileName = "D:\Inetpub\iEnergyPricing.com\Contracts_Signed\"
            i = i + 1
        Loop
 
        'Process.Close()
        'Process.Dispose()
        'Process = Nothing
        psi = Nothing
 
        If SRConn.State <> Data.ConnectionState.Closed Then
            SRConn.Close()
        End If
 
        Response.Write("<script language = 'jscript'>")
        Response.Write("alert('Previous day's contracts printed!')")
        Response.Write("</script>")
 
    End Sub

Open in new window

0
Comment
Question by:utlonghornjulie
  • 7
  • 6
13 Comments
 
LVL 15

Expert Comment

by:aibusinesssolutions
ID: 23676398
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.
0
 
LVL 3

Author Comment

by:utlonghornjulie
ID: 23676418
Windows Picture and Fax Viewer
0
 
LVL 15

Expert Comment

by:aibusinesssolutions
ID: 23676504
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"
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:utlonghornjulie
ID: 23676626
I think the program is Microsoft Office Document Imaging, not Windows Picture and Fax Viewer.
0
 
LVL 15

Expert Comment

by:aibusinesssolutions
ID: 23676646
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.
0
 
LVL 3

Author Comment

by:utlonghornjulie
ID: 23676663
How can I do that?
0
 
LVL 15

Expert Comment

by:aibusinesssolutions
ID: 23676677
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.
0
 
LVL 3

Author Comment

by:utlonghornjulie
ID: 23676713
What programs have a print function?
0
 
LVL 15

Expert Comment

by:aibusinesssolutions
ID: 23676718
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.
0
 
LVL 3

Author Comment

by:utlonghornjulie
ID: 23676759
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.
0
 
LVL 15

Expert Comment

by:aibusinesssolutions
ID: 23676790
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?
0
 
LVL 3

Author Comment

by:utlonghornjulie
ID: 23682186
The Photo Printing Wizard dialog box pops up.
0
 
LVL 15

Accepted Solution

by:
aibusinesssolutions earned 2000 total points
ID: 23682693
You can try installing this software on the server, it is freeware and allows you to view and print just about any image format.  http://www.irfanview.com/
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses
Course of the Month15 days, 3 hours left to enroll

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question