View previous topic :: View next topic |
Author |
Message |
Sherif Abdeen Guest
|
Posted: Mon Jan 23, 2006 8:52 am Post subject: Print selected pages only |
|
|
Dear,
I tried to use printdialog class inorder to allow user printing his selection of pages using the from and To page properties values. But during printing, these values are neglected and still printing all document pages.
How could solve this problem?
Thanks |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Jan 24, 2006 12:01 am Post subject: |
|
|
This sounds like a general .NET printing issues - since VirtualTreePrintDocument inherits directly from PrintDocument. We will do some research and get back to you. _________________ Infralution Support |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Fri Jan 27, 2006 6:21 am Post subject: |
|
|
After quite a bit of research we have established that this is indeed a deficiency in the .NET framework. Really the task of handling only printing selected pages should have been done by the base PrintDocument class - instead it is left up to the application programmer to handle printing of selected pages.
Below is some code that will handle the printing of selected pages by deriving a new class from VirtualTreePrintDocument and overriding the OnPrintPage method. We will incorporate this into our base VirtualTreePrintDocument class in the next release.
Code: | Public Class TreePrintDocument
Inherits VirtualTreePrintDocument
Public Sub New(ByVal sTree As VirtualTree)
MyBase.New(sTree)
End Sub
Protected Overrides Sub OnPrintPage(ByVal e As System.Drawing.Printing.PrintPageEventArgs)
If Me.PrinterSettings.PrintRange = Printing.PrintRange.SomePages Then
' fake graphics context to handle printing to pages before the
' selected range
'
Dim sGraphics As Graphics = Graphics.FromImage(New Bitmap(1, 1))
While CurrentPage + 1 < Me.PrinterSettings.FromPage
Dim sArgs As New Printing.PrintPageEventArgs(sGraphics, e.MarginBounds, e.PageBounds, e.PageSettings)
MyBase.OnPrintPage(sArgs)
If Not sArgs.HasMorePages Then
Return
End If
End While
MyBase.OnPrintPage(e)
If CurrentPage + 1 >= Me.PrinterSettings.ToPage Then
e.HasMorePages = False
End If
Else
MyBase.OnPrintPage(e)
End If
End Sub
End Class |
Note that the CurrentPage property of VirtualTreePrintDocument is currently zero based - hence the correction by one when comparing with the ToPage and FromPage. We will change the CurrentPage to be one based to eliminate this incompatibility in the next release. _________________ Infralution Support |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Feb 01, 2006 5:51 am Post subject: |
|
|
Version 2.4.0 of Virtual Tree has now been released and includes inbuilt support for prining selected pages. _________________ Infralution Support |
|
Back to top |
|
|
|