By now you probably know that one of the biggest new features in RadGrid 5.0 is support for export to PDF. For quite some time, RadGrid has supported direct export to Microsoft Word and Excel formats, but the addition of PDF export elevates the Grid's exporting capabilities to unprecedented levels. Using the new export feature couldn't be easier. As with previous export formats, all that is required is a call to a single simple RadGrid method:
When you call this method, all of the data in the Grid is exported to a new PDF that the users can then save to their local file system. The PDF is saved in a format that is compatible with Adobe Acrobat Reader 4.x and higher and by default uses the file name "RadGridExport.pdf". If you do not like this name, you can change it in the new RadGrid ExportSettings section. This section gives you control over a number of PDF and general export parameters, such as:
- FileName: change the file name of the exported file
- ExportOnlyData: indicates if links and other basic HTML will be preserved on export (CSS styling will not be exported)
- PDF Specific Settings:
- Author: sets PDF metadata author value
- Creator: sets PDF metadata creator value
- PaperSize: sets PDF paper size
- PageTitle: sets PDF page title (rendered on top of page)
- Title: sets PDF metadata title value
- Keywords: sets PDF metadata keyword value
- AllowPrinting/Add/Copy/Modify: indicates if users have permission to print/add/copy/modify exported PDF
There are more settings available for controlling RadGrid exports, but the basic point is that you have a fair amount of control over your exported documents. You don't have total control, though, so don't expect RadGrid to provide the same level of formatting that you can find in Telerik Reporting. Exporting data to PDF from RadGrid will not preserve the Grid's skin. Data will be rendered without any of the CSS styling you see in the browser and will use only the default font settings. You cannot control the PDF's font size, color, face, or other formatting settings. You essentially get to set the page size, margins, and metadata and then let RadGrid do the rest. For more advanced exporting, you'll need to check out Telerik Reporting.
Still, if you've been dying to offer PDF export to your users for RadGrid-based data, this is an amazing feature. It works without any trouble right out of the box and doesn't require any special coding or web.config changes. This should be a great feature for anyone looking for a "poor man's" reporting solution or the flexibility to export data in a universally readable format.
For comparison's sake, here's how RadGrid 5.0 exporting compares to other grid products on the market:
*Supports RTF export
As you can see, the new PDF and CSV export formats in Q2 make RadGrid the most flexible ASP.NET grid for exporting available. Check out RadGrid 5.0 for ASP.NET in Q2 2007 and have fun with the new PDF export!
UPDATE/CORRECTION: It turns out that you do have some control over the PDF formatting when exporting from RadGrid. The export command will not render any external stylesheet styles (a.k.a. Skins) to the PDF, but it will render any inline CSS rules applied ot the Grid. That means skins are still out and that you're going to have to do some extra work to style your PDF, but it can be done. Watch for a future post showing you how to add inline styles to RadGrid and format your PDF.