Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Print selected pages only

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
Sherif Abdeen
Guest





PostPosted: Mon Jan 23, 2006 8:52 am    Post subject: Print selected pages only Reply with quote

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

PostPosted: Tue Jan 24, 2006 12:01 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Fri Jan 27, 2006 6:21 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Feb 01, 2006 5:51 am    Post subject: Reply with quote

Version 2.4.0 of Virtual Tree has now been released and includes inbuilt support for prining selected pages.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group