I have been trying to make the grid export to PDF in a WYSIWYG manner
I have been "almost" successful with very less code
void ultraGridDocumentExporter1_ExportStarted(object sender, Infragistics.Win.UltraWinGrid.DocumentExport.ExportStartedEventArgs e){e.Section.PageSize = PageSizes.A4;e.Section.PageMargins = new Infragistics.Documents.Reports.Report.Margins(PageMargins.Narrow.Left, PageMargins.Narrow.Right,PageMargins.Narrow.Top, PageMargins.Narrow.Bottom);e.Section.PagePaddings = new Paddings(0);e.Section.PageOrientation = Infragistics.Documents.Reports.Report.PageOrientation.Landscape;e.Section.PageAlignment = Infragistics.Documents.Reports.Report.ContentAlignment.Center;}
I get the fonts, column widths, row height correctly as seen in the grid inside of windows forms container
But the grid layout inside of PDF document does not occupy (stretch or shrink) the entire whitespace available on the PDF document (see red blocks in the attached PDF screenshot) - what am I not doing right?
Thanks!
Screenshot: https://doc-0s-44-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/8p6fggpi7eli97l0n6cojs6v6nrda7je/1423749600000/12612333493395018583/*/0B42CvR3rv2CxUjJZRGJwd25aSzA
Thanks, u help me...
Thanks Mike - I see what you mean - I can live with this, I now adjust the last column width, in a manner that it tries to fully occupy the width of the page
Thank you!
-
Hi Ameya,
Okay... the UltraGridDocumentExporter does not use a Canvas. It adds a Tree to the section and populates the nodes of that tree with various objects like grids and tables in order to duplicate the structure of the on-screen grid. So that's cleared up. :)
Since your latest response says that sizing the columns doesn't have any effect, I looked at the source code for the exporter to determine exactly when the autosizing of the columns takes place. And it turns out that this happens BEFORE the ExportStarted event fires. So the Autosizing should not interfere with any changes you make inside either the ExportStarted event.
So, just to be extra sure, I tried it out. I am attaching my sample here so you can try it and see if you get the same results.
The sample has a simple grid with 3 columns. Click the Export button and the grid exports to PDF in landscape mode and the columns are pretty small. The entire grid takes up maybe 1/5th the width of the page.
Close the PDF document, click the checkbox, and click Export again and now the grid takes up most of the page because the columns are made larger.
Hi Mike
In order to add any custom object to the PDF document - the only way that seemed to work for me was to do
e.Section.AddCanvas - which returns ICanvas object
I am able to set position, and dimensions on this ICanvas object (notice the footer in my image attached earlier)
This led me to believe that the grid layout inside of the PDF also has some kind of a container / canvas - which I cannot obtain the handle to
After your response, I tried setting the column width in either of the events but there is no change in the output
Just to go over my problem again
- the total width of the grid inside the PDF is much less than the total width offered by the A4 sized PDF in landscape mode
- the width of the columns changes as controlled in the code and it reflects in the PDF, but the total width of the grid inside of the PDF remains unchanged
..and hence the title of my post "How do I make the grid layout occupy entire whitespace available on exported PDF document"
I'm not sure I follow you. What do you mean by "Canvas?" Our documents engine has a canvas object, but the WinGridDocumentExporter doesn't use it. It's for custom drawing.
The only thing that matters here is the size of the columns and bands in the export layout (which is passed in to the ExportStarting / ExportStarted events) and the PageSize on the section.
From what you write here, it sounds like you might be changing the column widths too early. Which event did you use? I think the exporter auto-sizes the columns after ExportStarting, but before ExportStarted. So you probably need to use ExportStarted - or turn off AutoSizing.