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
Thank you Mike - Yes my grid is centered, hence the equal white spacing on right and left
I actually did exactly what you were suggesting - manually adjusted / expanded the widths of the columns and saw the DocumentExporter clone it and fit it into the PDF - but guess what, it still uses the same "canvas" width and keeps the same spacing on right and left - ideally my expectation would be just as what Excel does => recompute font size (float) to take the full available width of A4 page size
My guess is that the document exporter already has a canvas created for the grid layout, which programmatically, I cannot modify. There is no API in ExportArgs to do that - if you look at my image again, and see the page footer, notice how I am able to control the "new canvas" that I added for textual content of the footer - it spans right from the left edge of the page to the right - I just would like the grid layout to also do that
I also think I am missing something, if I can get an handle to the canvas object inside of which the grid layout is cloned/painted - I should be able to play with it a little, I just can find that how..
Hi Ameya,
The way the DocumentExporter works is that it clones the DisplayLayout of the grid and then, depending on the AutoSize property of the exporter, auto-sizes the grid column to their contents. It will then export the grid to the PDF document at that size. If the grid fits on the standard page size, then that's fine. If the grid is too big, the exporter will increase the page width of the section so that the grid fits within one page horizontally.
It seems like in your case, the grid doesn't need the full width of a standard A4 page. So there is extra space. But I thought the extra space is always on the right and for some reason, the extra space here appears on the left. Is there an equal space on the right side of the page? If so, then maybe the grid is centered within the page and that would explain it.
In any case, there is no easy way to make the grid fit to the width of a page in the case where the grid doesn't need the entire width. Those calculations would be pretty tricky, but if you could determine the width you need, you could, in theory, increase the width of each column in the grid before exporting. The ExportedStarting or ExportStarted events would be a good place to do this, because you could change the widths of the columns in the export layout without affecting the on-screen grid.
Hi Dimitar
Actually, I am able to fit the grid to 1 page wide and n pages in height - that works and does not need any new feature development
My problem is slightly different
While my grid layout inside the PDF has fit to 1 page wide, its not wide enough to fill the entire A4 page size in landscape - the grid in the PDF has about 200 floating points margins on left and right (blank space) - even though I have explicitly set the page + section margins to ZERO
Link to the screenshot image: https://drive.google.com/open?id=0B42CvR3rv2CxUjJZRGJwd25aSzA&authuser=0
Thank you!
-
Thank you for posting in our forums.
After looking into this and doing some research, “Fitting the grid to one page in PDF” has been determined to be a new product idea. You can suggest new product ideas for future versions (or vote for existing ones) at <http://ideas.infragistics.com>.
There are many benefits to submitting a product idea:
- Direct communication with our product management team regarding your product idea.
- Notifications whenever new information regarding your idea becomes available.
- Ability to vote on your favorite product ideas to let us know which ones are the most important to you. You will have ten votes for this and can change which ideas you are voting for at any time.
- Allow you to shape the future of our products by requesting new controls and products altogether.
- You and other developers can discuss existing product ideas with members of our Product Management team.
Steps to create your idea:
1. Log into the Infragistics Product Idea site at http://ideas.infragistics.com (creating a new login if needed).
2. Navigate to the product / platform channel of your choice (e.g. WPF, Windows Forms, ASP.NET, HTML5 / Ignite UI, iOS / NucliOS, etc.)
3. Add your product idea and be sure to be specific and provide as much detail as possible.
The Product Idea site puts you in the driver’s seat and allows you to track the progress of your ideas at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you.
Thank you for contacting Infragistics.