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

Export to pdf is not displaying the records in proper format

1 Answer 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amitkumar
Top achievements
Rank 1
Amitkumar asked on 23 Feb 2010, 06:33 AM
Hi All,

I am using RadGrid, and i am using following functions to export grid data, all export method works fine except export to pdf, it will not display data properlly in pdf file

protected void BtnExcel_Click(object sender, EventArgs e)
        {
            SetExport();
            ViewState["ExportingPDF"] = null;

            switch ((sender as Button).ID)
            {
                case "Excel":
                    foreach (GridItem commandItem in this.rgAgenda.MasterTableView.GetItems(GridItemType.CommandItem))
                    {
                        commandItem.Visible = false;
                    }

                    rgAgenda.MasterTableView.ExportToExcel();
                    break;
                case "CSV":
                    rgAgenda.MasterTableView.ExportToCSV(); break;
                case "Word":
                    rgAgenda.MasterTableView.ExportToWord(); break;
                case "PDF":
                    rgAgenda.ExportSettings.OpenInNewWindow = true;
                    ViewState["ExportingPDF"] = "True";
                    ExportToPDF();
                    break;
            }
        }

        private void SetExport()
        {
            rgAgenda.ExportSettings.ExportOnlyData = true;
            rgAgenda.ExportSettings.IgnorePaging = true;
            rgAgenda.ExportSettings.OpenInNewWindow = false;
            rgAgenda.ExportSettings.FileName = "AppointmentsInGrid";

            // Removing command item from the exported document
            foreach (GridItem commandItem in this.rgAgenda.MasterTableView.GetItems(GridItemType.CommandItem))
            {
                commandItem.Visible = false;
            }
        }

        private void ExportToPDF()
        {
            if (ddlPaperSize.SelectedIndex > 0 && ddlPaperSize.SelectedIndex <= 5)
            {
                rgAgenda.ExportSettings.Pdf.AllowAdd = false;
                rgAgenda.ExportSettings.Pdf.AllowCopy = true;
                rgAgenda.ExportSettings.Pdf.AllowModify = true;
                rgAgenda.ExportSettings.Pdf.AllowPrinting = true;
                rgAgenda.ExportSettings.Pdf.Author = "Anonymous";

                rgAgenda.ExportSettings.Pdf.PageTitle = "Appointments Report";
                rgAgenda.ExportSettings.Pdf.Subject = "PDF Export";
                rgAgenda.ExportSettings.Pdf.Title = "PDF Export";

                rgAgenda.ExportSettings.Pdf.PaperSize = (GridPaperSize)Enum.Parse(typeof(GridPaperSize), ddlPaperSize.SelectedValue);
                rgAgenda.MasterTableView.ExportToPdf();
                ddlPaperSize.ClearSelection();
            }
        }


Thanks & Regards
Amit Prajapati





1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 23 Feb 2010, 02:54 PM
Hello Amit,

I'm not sure that I understand what do you mean. Could you please provide more detailed information about the problem?

Regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Amitkumar
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or