To reproduce: please refer to the attached sample project and gif file Workaround: GridViewSpreadExport spreadExporter = new GridViewSpreadExport(this.radGridView1); spreadExporter.ExportFormat = SpreadExportFormat.Pdf; spreadExporter.ExportVisualSettings = true; SpreadExportRenderer exportRenderer = new SpreadExportRenderer(); spreadExporter.RunExport(exportFile, exportRenderer); Process.Start(exportFile);
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Workaround 2 is not working if the grid have Horizzontal scrollbar and marign are considered only one time.
This is better in my opinion:
float pageWidth = (float)Telerik.WinControls.Export.GridExportUtils.DipToMm(this.radGridView1.Columns.Sum(c => c.Width)) + (gridViewPdfExport.PageMargins.Horizontal * 2);
The export direction is from RadGridView to PdfDocument. Row heights and column widths are calculated in RadGridView and GridViewPdfExport takes the same values. When the FitToPageWidth property is true(its default value is true) all column widths from the grid are scaled to fit in the page width of GridViewPdfExport. In some cases when the width of RadGridView is bigger than the width of GridViewPdfExport Page, text may not fit and will be clipped. In the current case, the width of RadGridView is 1099px, but the width of the exported page with margins subtracted is 650px. When the last column is scaled down there is not enough space for the text and it is clipped. There are three possible solutions in this case: 1. Set FitToPageWidth to false; 2. Calculate the Page Width of GridViewPdfExport according to the width of RadGridView and page Margins. - exporter.PageSize = new SizeF((float)Telerik.WinControls.Export.GridExportUtils.DipToMm(this.radGridView1.Width) + exporter.PageMargins.Horizontal, exporter.PageSize.Height); 3. Set the width of RadGridView the same as the width of the page of GridViewPdfExport and subtract horizontal margins. - this.radGridView1.Width = (int)Telerik.WinControls.Export.GridExportUtils.MmToDip(exporter.PageSize.Width - exporter.PageMargins.Horizontal); // remove Anchor and Dock of grid before this step