PDF Export

2 posts, 0 answers
  1. Ranjith
    Ranjith avatar
    6 posts
    Member since:
    Jan 2014

    Posted 01 Jan 2014 Link to this post

    Hi,

    I am trying to export PDF from my RadGrid and its exporting successfully. But i am facing some design issues in the exported PDF file.

    1. All the text are coming with Hyperlinks in the exported PDF.
    2. Set the Forecolor and width, which are not getting reflected in the exported PDF.

    Below is my c# code 

    protected void btnExportToPDF_Click(object sender, ImageClickEventArgs e)
            {
                ApplyStylesToPDFExport(RadGrid1.MasterTableView);
                RadGrid1.ExportSettings.OpenInNewWindow = true;
                RadGrid1.ExportSettings.IgnorePaging = true;
                RadGrid1.ExportSettings.FileName = "Test";
                RadGrid1.MasterTableView.ExportToPdf();
            }
     
    private void ApplyStylesToPDFExport(GridTableView view)
            {
                GridItem headerItem = view.GetItems(GridItemType.Header)[0];
                foreach (TableCell cell in headerItem.Cells)
                {
            switch (cell.Text)
                    {
                        case "A":
                            cell.Width = Unit.Pixel(5); // Tried like this. Not reflecting
                            break;
                        case "B":
                            cell.Style["width"] = "15px"// Tried like this. Not reflecting
                            break;
            }
                    cell.Style["font-family"] = "Verdana";
                    cell.Style["font-bold"] = "true";
                    cell.Style["text-align"] = "left";
                    cell.Style["vertical-align"] = "middle";
                    cell.Style["font-size"] = "8px";
                    cell.ForeColor = System.Drawing.Color.Black; // Tried like this. Not reflecting
     
                }
                GridItem[] dataItems = view.GetItems(GridItemType.Item);
                foreach (GridItem item in dataItems)
                {
                    foreach (TableCell cell in item.Cells)
                    {
                        cell.Style["font-family"] = "Verdana";
                        cell.Style["text-align"] = "left";
                        cell.Style["vertical-align"] = "left";
                        cell.Style["font-size"] = "6px";
                        cell.Style["text-decoration"] = "none"// Tried like this. Not reflecting
     
                        cell.Style["ForeColor"] = "#000";
                    }
                }
                dataItems = view.GetItems(GridItemType.AlternatingItem);
                foreach (GridItem item in dataItems)
                {
                    foreach (TableCell cell in item.Cells)
                    {
                        cell.Style["font-family"] = "Verdana";
                        cell.Style["text-align"] = "left";
                        cell.Style["vertical-align"] = "middle";
                        cell.Style["font-size"] = "6px";
                        cell.Style["text-decoration"] = "none";
                        cell.ForeColor = System.Drawing.Color.Black;
                    }
                }
            }

    Please advise.

    Thanks
    Ranjith
  2. Kostadin
    Admin
    Kostadin avatar
    1733 posts

    Posted 06 Jan 2014 Link to this post

    Hello Ranjith,

    I have already answered you in the following forum thread. I would ask you to continue our conversation there and close this one.
    Please note that opening multiple forum threads with the same issue makes tracking the tickets history very hard. In this regard, I suggest you to stick to the first thread. This will enable us to respond more quickly and efficiently to your posts.

    Regards,
    Kostadin
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top