This is a migrated thread and some comments may be shown as answers.

Pdf Export autosizing?

4 Answers 27 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 1
Joel asked on 18 Aug 2014, 11:08 PM
I'm exploring the PDF Export example, and the PDF created looks good except for the grid being too wide for the normal page and runs off the edge. I see PageSize options, but I'm not sure how to measure the grid, control the grid width, or otherwise control the output.

Ideally, I'd love to set landscape mode, and either shrink the grid to the page width or have different columns on alternating pages. I'm just getting started with the Pdf export; what kind of ExportSettings & Pdf options should I be looking for to accomplish this?

I'd also be very happy to have the page size set to a non-standard page width so the grid fits. Is there an autosize option like this?

public void ExportPdf_Click(object sender, EventArgs args)
{
    RadGrid1.ExportSettings.Pdf.BorderType = GridPdfSettings.GridPdfBorderType.AllBorders;
    RadGrid1.MasterTableView.ExportToPdf();
}

4 Answers, 1 is accepted

Sort by
0
Joel
Top achievements
Rank 1
answered on 18 Aug 2014, 11:12 PM
And my mistake - it is automatically exported in landscape mode (very nice!), the grid is just wider than that, even. 
0
Princy
Top achievements
Rank 1
answered on 19 Aug 2014, 03:57 AM
Hi Joel,

You can set the Pdf PageWidth and PageHeight when exporting. Take a look at this article to know how to set page orientation.

C#:
RadGrid1.ExportSettings.Pdf.PageHeight = Unit.Parse("162mm");
RadGrid1.ExportSettings.Pdf.PageWidth = Unit.Parse("600mm");
RadGrid1.MasterTableView.ExportToPdf();

Thanks,
Princy
0
Joel
Top achievements
Rank 1
answered on 20 Aug 2014, 09:52 PM
The article makes sense and I can set the paper size to a custom value, thank you.

I'm not sure how wide I need to set it for a given grid - is there a grid width value that I can translate to an appropriate PDF width? I tried:

   RadGrid1.ExportSettings.Pdf.PageWidth = RadGrid1.Width;

And the PDF page was too wide - but that's better than not wide enough. Is that a correct width assignment to make, or is there something funny going on there? I am hiding a few columns in the grid, maybe that explains the difference?
0
Princy
Top achievements
Rank 1
answered on 21 Aug 2014, 05:54 AM
Hi Joel,

You can set the appropriate width you need for the RadGrid and then set that to the Pdf - PageWidth.

ASPX:
<telerik:RadGrid ID="rgrdSample" runat="server" Width="1000px". .>

C#:
rgrdSample.ExportSettings.Pdf.PageWidth = rgrdSample.Width;
rgrdSample.MasterTableView.ExportToPdf();

Thanks,
Princy
Tags
Grid
Asked by
Joel
Top achievements
Rank 1
Answers by
Joel
Top achievements
Rank 1
Princy
Top achievements
Rank 1
Share this question
or