Hi Mike,
we are still porting a grid implementation with Farpoint to Infragistics UltraGrid. Currently we have problems using the print functionality.
Our reports should have a header and a footer with simple text statically for all pages of the report. In between of the header and footer, we calculated a region for the grids and plots to be printed. The problem is: without printing the grid into the report all is fine, for tests we printed a simple rect and header and footer and all is placed correctly on the pages.
But when printing the grid the headers are spread so that they are too broad for the page and do not fit any more. Also the footers, which are no more visible because they are located outside of the page.
Our implementation is the following:
Why is the complete layout of the page changing, when the grid is printed into the section? Margins are different, footers are no longer visible. Moreover we did not find a way to configure the Grid so that it is shown in good readable scale (it is too small even if there is a lot of space on the page). Do you have a sample for this and a documentation how to use Report, Section and UltraGridDocumentExporter?
Thanks
Wolfgang & Alex
Hi,
When you print the grid into a section, the width of the section may be adjusted so that the entire width of the grid can fit across one page. This will only happen if the grid is wider than the page, but it sounds like that's what happening here.
The exporter also makes assumption about the size of the headers and footers based on what you specified on the exporter's properties. So if you are creating a section, building the header and/or footer and then exporting the grid into that section, the exporter may not be able to properly determine the height of the headers/footers and that will throw off the whole export operation.
Hi Mike, hi Hristo,
please find attached the problem description with source code in a separate mail.
Alex
Hello,
Please send your files to support@infragisitcs.com and refer this forum thread. Or if you prefer I could open a support ticket for you in our issue taking system where you will be able to upload your files.
I am waiting for your feedback.
did you get my email?
I attached the documentation (sample print out, source code and documentation) here also.
regards,
Thank you for the provided sample.
After further research of your code I found that you have PrintHelper class where you are generating report pages and then draw report page into PrintDocument page. So after the Report generate its pages you should align Report’s page with the printDocument page, and in your sample you are aligning Report’s pages based on the available printable area of PrintDocument’s page (the point based on which you make translation is wrong). However you have missed that Report’s pages have margins, so when you draw Report’s pages PrintDocument’s page, you actually gets margins from Report and from PrintDocument, that is why your headers appear on wrong place. Also you should take in account that Report’s page size is different from the PrintDocument page size, so you should scale Report’s page graphic object to fit the size of the PrintDocument’s page size. (In your sample you actually have code which does this, but it is commented.). So ultimately rectangle of the PrintDocument’s page is shifted, and its bottom right edge is drawn outside of the PrintDocument’s page rectangle, and your footers is missing and some part of the grid is cut
Please let me know if you have any further questions or if I am missing something.
Hi Hristo,
thanks for your answer. It is still unclear, how to calculate the borders / margins. Using the values directly from PrintPageEventArgs e did not help. Could you please give us some code? It would be very helpful, if you would change the sample code in the parts which are wrong. Also it would be helpful to have a documentation which describes how these objects should be used in collaboration.
Hello Alex,
PrintDocument graphics object works in pixel units and Report works with points units, so first you should translate and apply PageSEttings to the UltraDocumentExporter, also you should keep the ration of PrintDocument margins/PageSize and Report margins/PageWidth. There is no documentation about usage of Infragistics Documents.Reports in such scenario, since it is not designed to be used in such scenario. If you want to print UltraGrid, you should use UltraGridPrintDocument:
http://help.infragistics.com/doc/WinForms/2014.1/CLR4.0/?page=WinGridPrintDocument_Understanding_WinGridPrintDocument.html
I’ve modified your sample to apply Margins from the PageSettings of the PrintDocument, and I hope that this will hleps you. Please feel free to modify this sample based on your custom needs.
I hope that this will helps you.
thank you for your sample - it worked for the one grid. But if we put a plot on the report it is scaled completely wrong. Please have a look at the code arttached and let me know what is wrong. Thanks!
Please open a support ticket or let me know how I can arttach a zip file with code
this is the sample
did you find an error in the code sample? Please let me know, if you need further information.
Hello ,
If you want to print more than one page and you directly draw onto the PrintDocument as in your case you should set e.HasMorePages to true in order next page to be generated
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument(v=vs.110).aspx
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.onprintpage(v=vs.110).aspx
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printpageeventargs.hasmorepages(v=vs.110).aspx
so in your case your char is plot over the grid since no one has generate new page for it.
So in this case you have at least two option:
To add your image into the section of the report
Generate new page for the PrintDocument and draw directly onto the graphic object of the page
I’ve implemented the first approach in your sample, adding the image into the section on a new page. For the report image objects could have relative, absolute and auto size, so since I want the image to fill entire page I’ve used relative size.
Please feel free to modify this sample based on your custom needs.
I am just checking about the progress of this issue. Let me know if Hristo's suggestions worked for you or if you need our further assistance.
Thank you for using Infragistics Components.