View previous topic :: View next topic |
Author |
Message |
Sherif Abdeen Guest
|
Posted: Mon Jan 16, 2006 3:26 pm Post subject: Add PageNumber for printed document |
|
|
Dear ,
I used the the TreePrintDocument object for printing my virtual tree data.
it is working fine, but there no page number and Page Title for the printed pages.
Is there a way to add these features to the printed pages?
Thanks & Best Regards |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Jan 17, 2006 7:47 am Post subject: |
|
|
To print page numbers and titles etc you will need to derive your own class from VirtualTreePrintDocument and override the OnPrintPage method. Call the base.OnPrintPage method first to print the standard information then add your own title and page numbers (you can use the CurrentPage property to get the current page number).
If you want to adjust the area that the base method prints the standard information to (to make room for your title) then you can override the GetAdjustedMarginsBounds method to return the area you want it to print to. _________________ Infralution Support |
|
Back to top |
|
|
Sherif Abdeen Guest
|
Posted: Wed Jan 18, 2006 8:45 am Post subject: Add PageNumber for printed document |
|
|
Dear,
I started to write code depeneding on your instructions as follows:
*********************************************
Public Class print_class
Inherits Infralution.Controls.VirtualTree.VirtualTreePrintDocument
Protected Overrides Sub OnPrintPage(ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Dim pageno As Integer
Call MyBase.OnPrintPage(e)
pageno = MyBase.CurrentPage
End Sub
End Class
*************************************************
Could you help in complete this code to add the page number and tilte on the printed page
Thanks & Best Regards |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Jan 18, 2006 11:04 pm Post subject: |
|
|
Try something like:
Code: |
Public Class print_class
Inherits Infralution.Controls.VirtualTree.VirtualTreePrintDocument
Protected Overrides Sub OnPrintPage(ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Call MyBase.OnPrintPage(e)
Dim title as String = String.Format("My Title - Page No: {0}", CurrentPage)
e.Graphics.DrawString(title, Tree.Font, Brushes.Black, e.MarginsBounds.Left, e.MarginBounds.Top - Tree.Font.Height)
End Sub
End Class
|
_________________ Infralution Support |
|
Back to top |
|
|
S Guest
|
Posted: Sun Jan 22, 2006 9:29 am Post subject: |
|
|
Dear,
Thanks for your assistance. I am about to buy license very soon.
Is there a property to get the total number of printed pages?
Best Regards |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Jan 23, 2006 4:25 am Post subject: |
|
|
No this is a bit of a problem with .NET printing in general. To calculate the total number of printed pages you would have to first completely execute a print document - which will obviously double the printing time. _________________ Infralution Support |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Feb 01, 2006 5:52 am Post subject: |
|
|
Version 2.4.0 of Virtual Tree has now been released. It includes support for printing headers and footers including page numbers. _________________ Infralution Support |
|
Back to top |
|
|
|