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

Export To pdf using Radeditior with css applied

2 Answers 80 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Rijo
Top achievements
Rank 1
Rijo asked on 23 Feb 2012, 11:50 AM
Hi guys
I m stuck with an issue where i am trying to apply css to Rad editor control and it is applying the css to the content part.
But when i try to use exporttoPDF() the css is not working on the PDF generated.
This is the sample code :
//For Export to Pdf functionality and applying CSS to Radeditor1
 protected void Button1_Click(object sender, EventArgs e)
        {
         
            StringWriter sw = new StringWriter();
            HtmlTextWriter w = new HtmlTextWriter(sw);
            dvPrintSection.RenderControl(w);
            string s = sw.GetStringBuilder().ToString();

            RadEditor1.CssFiles.Add("Site.css"); // location of my css
            
            RadEditor1.Content = s.Replace("&nbsp", "");

            string aa = RadEditor1.CssFiles[0].Value.ToString();
        }

//i have used Radeditor like below in aspx
<telerik:RadEditor ID="RadEditor1" runat="server"
        ContentFilters="PdfExportFilter, DefaultFilters" Skin="Office2007" >
        <ExportSettings Pdf-PageTopMargin="15px" Pdf-PageLeftMargin="20px"  Pdf-PageRightMargin="20px"
         OpenInNewWindow="true" Pdf-PageHeight="21cm" Pdf-PageWidth="29cm">
<Pdf PageWidth="29cm" PageHeight="21cm" PageTopMargin="15px" PageLeftMargin="20px" PageRightMargin="20px"></Pdf>
        </ExportSettings>
         <Content>
<table class="test" >
<colgroup></col></colgroup>
<tbody>
<tr>
<td>
TEst data to be printed with class applied
</td>
</tr>
         </tbody>
</table>
</Content>
        </telerik:RadEditor>

2 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 27 Feb 2012, 03:58 PM
Hello,

The third party HTMLtoPDF converter that RadEditor uses to export the HTML content to PDF does not offer support for external CSS files and it does not render the classes specified in the class attributes of the HTML elements. It is possible currently to export only inline style attributes.

Best regards,
Rumen
the Telerik team
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 their blog feed now.
0
Rijo
Top achievements
Rank 1
answered on 28 Feb 2012, 11:40 AM
Hi Rumen,

Thanks for the response.. yes it was not workin and i had to find a way to provide the designer with a way to work with ease..
So i have implemented the inline based on a XML which stores all the Classes and its values..
thanks & Regards

RIjo Rajan
Tags
Editor
Asked by
Rijo
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Rijo
Top achievements
Rank 1
Share this question
or