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

PDF Export

1 Answer 27 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ranjith
Top achievements
Rank 1
Ranjith asked on 02 Jan 2014, 03:40 AM
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

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 06 Jan 2014, 01:25 PM
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.
Tags
General Discussions
Asked by
Ranjith
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or