Export To pdf using Radeditior with css applied

3 posts, 0 answers
  1. Rijo
    Rijo avatar
    2 posts
    Member since:
    Feb 2012

    Posted 23 Feb 2012 Link to this post

    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. Rumen
    Admin
    Rumen avatar
    14351 posts

    Posted 27 Feb 2012 Link to this post

    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.
  3. Rijo
    Rijo avatar
    2 posts
    Member since:
    Feb 2012

    Posted 28 Feb 2012 Link to this post

    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
Back to Top