|
-
May 15th, 2007, 07:28 AM
#1
Thread Starter
Fanatic Member
Printing woes :-(
I am trying to add some print functionality to my application which I thought would be easy but am not having much success.
I need to be able to print images which will include jpg., gif and multi-page tiff files. I was hoping to let windows do all the hard work but for the life of me cant figure it out.
Any Ideas ?
-
May 15th, 2007, 07:34 AM
#2
Re: Printing woes :-(
All .NET printing is done the same way. It's a piece of cake for simple stuff and it's extremely powerful and flexible for complex stuff. Create a PrintDocument object, call its Print method and handle its PrintPage event. In the PrintPage event handler you have the full power of GDI+ to print anything you want. In your case its a single call to e.Graphics.DrawImage.
-
May 15th, 2007, 07:52 AM
#3
Thread Starter
Fanatic Member
Re: Printing woes :-(
You lost me a bit should come as no suprise to you :-)
I am creating a new ImagePrintDocument and I am using the PrintPreviewDialog box and all is well in the world........until I use a multi page tiff file.
It always displays and prints only the first page which I find most distressing :-(.
Basically I have no idea how to loop through the pages collection so it looks like more research is required. I shall get my pea sized brain onto it.
Thanks
-
May 15th, 2007, 06:29 PM
#4
Re: Printing woes :-(
I'm not really very experienced with image manipulation. Do you know how to access the multiple pages of the TIFF file? If so then printing multiple pages is simply a case of setting one property in the PrintPage event handler. Assuming that you can access a TIFF page by index it would look something like this:
vb.net Code:
Private pageIndex As Integer = 0
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
'Get the image to be printed.
Dim imageToPrint As Image = myTiff.Pages(Me.pageIndex)
'Print the image here.
'Increment the page index.
Me.pageIndex += 1
'There are no more pages to print if the index has gone beyond the upper bound.
e.HasMorePages = (Me.pageIndex < myTiff.Pages.Count)
If Not e.HasMorePages Then
'Reset the page index for the next run.
Me.pageIndex = 0
End If
End Sub
Note that that is almost certainly not valid code, but hopefully it illustrates the point.
If you don't know how to get at each page of a TIFF then that's another issue, not really related to printing specifically.
-
May 15th, 2007, 06:33 PM
#5
Re: Printing woes :-(
Just had a quick look at the Image class and it has a SelectActiveFrame method. I'm guessing that you'd use that to select a "current page" in a TIFF image, then accessing the Image itself would always access that page. That's just an educated guess mind you. I'd think that there would be examples on the Web.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|