How can I print a TIF file programmatically?

I have been banging my head against the wall for over two weeks now trying to find a way to programmatically print TIF files, without the need to for user interaction. The catch to this is that the files are well data logs, which turn out to be very large TIF files that, when printed, will span multiple pages.

Right now the company is using a Neuralaser printer in conjunction with a NeuraView application that is able to print the images out across multiple pages for them, but it takes the user opening up each TIF file and using the print command.
I have tried a few third party components, and they do not accomplish what I need. I have tried to use the Win32 API (OpenPrinter, WritePrinter, ClosePrinter, ETC), but all I get back are errors when I try to open the file as a bitstream and feed it to the WritePrinter API. I can't find any good documentation on how I would even begin to accomplish my goal. I need some help and direction, if anyone could please help me out.

[988 byte] By [AnthonyH] at [2007-12-28]
# 1
Have you looked at the System.Drawing.Printing.PrintDocument class?

Attach to the PrintDocument.Print page and use the supplied graphics to draw the image.



Shared Sub document_PrintPage(sender As Object, e As System.Drawing.Printing.PrintPageEventArgs)
Dim image As Image = Image.FromFile("Myimage.tif")
Try
e.Graphics.DrawImage(image)
Finally
image.Dispose()
End Try
End Sub

DavidM.Kean at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
Hate to ask, but can you be a little more specific when you say attach to the PrintDocument.Print page? I'm writing this application as an executable that will run server side, so there is no user interface to speak of. How does the document_PrintPage event fire?
AnthonyH at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3

Sorry I meant attach to the PrintDocument.PrintPage event.

Try something like this:


Imports System.Drawing
Imports System.Drawing.Printing

Public Class PrintImage

Public Sub PrintImage()

Dim document As New PrintDocument()

AddHandler document.PrintPage, AddressOf DocumentPrintPage

document.Print();

End Sub

Sub DocumentPrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Dim image As Image = System.Drawing.Image.FromFile("Myimage.tif")
Try
e.Graphics.DrawImage(image, New Point(0, 0))
Finally
image.Dispose()
End Try
End Sub
End Class


DavidM.Kean at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4

Hello,

I tried that code and it worked great, but I need to go a step further. how do I get it to loop so that every tif file in a specific folder is printed. better yet how do I get the program to print every tif file in the order they are listed on an existing Excel sheet.

This would be a GREAT help, thank you,

jordan

jsena at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 5
This is question related to tiff file but for splitting a tiff pages into seperate tiff files. Do we have support in .NET libraries to split pages in a tiff file. I think Java has this library to do this functionality. Please let me know if someone has any idea about this.
BhupathiVenkatesh at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...