I'm using ig 2014.2 and I'm working on the first time on printing functionality of a grid content.
I have found a small sample, showing me how to use a print document. The grid content (see below) containes some value-code (T01, T02, ....). At the bottom of each page I should have a legend with description of each value-code. I have to calculate the place needed for the legend. Imagine I can place 4 description on 1 row and my content contains 20 different value-codes, therefore I need 5 lines for the legend (every page same legend). The legend should also be able to contain some color rectangles with description of used backcolors.
T01 Description for T01 T03 Description for T03 KP Descrioption for KP KZ Description for KZ
T02 Description for T02
rect1 Description Backcolor 1
Can I doo this in PageBodyPrinting event? The picture below shows the page-body padding bottom set to 100 (yellow space). Can somebody provide a sample or link to a sample how to write to the page-body. Please tell me if I'm wrong and I should try another approach.
Thank you for your help
Markus
Hello Markus,
Thank you for posting in our forum.
For some reason I do not see any picture attached in your post. Nevertheless if you need to add same text in the bottom area of your print document you may add this information to the page footer. You can also set the appearance of the footer as necessary to your scenario. More about page footer you may find by following the next link http://help.infragistics.com/Help/Doc/WinForms/2015.1/CLR4.0/HTML/Infragistics4.Win.v15.1~Infragistics.Win.Printing.UltraPrintDocument~Footer.html.
Please note if your report is more complex you may use Infragistics Document Engine and write your custom report. More about Document Engine you may find by following the next link http://help.infragistics.com/Doc/WinForms/current/CLR4.0/?page=Win_Infragistics_Document_Engine.html.
Please let me know if you need any additional information.
Thank you for using Infragistics Controls.
Hello,
I have pasted the picture from snippin tool into description box. However, in the small sample I found here (http://es.infragistics.com/community/forums/t/80903.aspx) you see that event handler of PageBodyPrinting-event, some text is written to the page body. After that Handles = true is set, therefore no grid content is printed, even set Handled = false allows not grid content and addition content print togehther.
I have figured out using the PageBodyPrinted-event instead, i can draw some text to my legend rectangle. For testing I have set the PrintDocument.PageBody.Padding.Bottom = 100;
Therefore my legend rectangle ist the padding area:
Rectangle rectLegend = new Rectangle();rectLegend.X = e.RectInsideMargins.X;rectLegend.Y = e.RectInsideMargins.Y + e.RectInsidePadding.Height;rectLegend.Width = e.RectInsideMargins.Width;rectLegend.Height = e.RectInsideMargins.Height - e.RectInsidePadding.Height;
Now, I have to calculate the required Padding.Bottom space (based on number of lines, font) and draw my legend in some line - multicolumn layout splitting the whole legend rectangle into "child" rectangles.
Please let me know is this approach does not come to the end for some reason or if I should try something similar in the footer area. In this project only grid contents are printed in this way. For all other reports, however, another reporting tool is used.
Best regards
Thank you for your feedback.
Yes, you are on the right way. You can use PageBodyPrinting event and add the legend to your printed document. Please check the attached sample project where I have used this approach and let me know if you have any additional questions.
Hello Milko,
thank you for the sample.
There is one unsolved problem / question: I mentioned that I like to have a multi-column legend. Therefore the required Padding.Bootom space is reduced by divide by the number of columns.
My problem is that in the ButtonPrint_Click event I have not found a property for the PageBody-width for calculating the number of columns (numCols = Floor( "PageBodyWidth" / maxItemSize.Width)) and in the PrintDocument_PageBodyPrinting-event the Padding.Bottom properties are read_only.
Do you have a solution for this problem?
Hello Markus,Thank you for your feedback.You can take the available width from DefaultPageSettings property of the UltraGridPrintDocument. DefaultPageSettings has Bounds and Margins properties. The Bounds width will return the entire width of the page and the Margins Left and Right will return the left and right margin respectively. To get the available page width you need to subtract both margins from the entire width. You can use code like this:
private int GetPageWidth(){ int entireWidth = this.ultraGridPrintDocument1.DefaultPageSettings.Bounds.Width; int leftMargin = this.ultraGridPrintDocument1.DefaultPageSettings.Margins.Left; int rightMargin = this.ultraGridPrintDocument1.DefaultPageSettings.Margins.Right; return entireWidth - leftMargin - rightMargin;}