ExportToPdf does not work for RadEditor

5 posts, 0 answers
  1. Tejas
    Tejas avatar
    31 posts
    Member since:
    Mar 2011

    Posted 09 Dec 2011 Link to this post

    Hi,
    I am using RadEditor control on my web page. I'm using HTML file as a template to fill in sections of data from database and then display data to user in Editor. I want to allow user to save this data as PDF file but unfortunately, I'm having trouble to save this data to export to PDF file using ExportToPdf() method of RadEditor.

    Here is a Code:
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td>
                 <telerik:RadEditor ID="fileEditor" ContentFilters="DefaultFilters,PdfExportFilter" Height="500" 
                            Width="685" runat="server" ToolsFile="~/HtmlEditorTools.xml" OnExportContent="fileEditor_ExportContent" >
                        <ExportSettings FileName="abc" OpenInNewWindow="true"></ExportSettings>
                    </telerik:RadEditor>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Button ID="btnSavePDF" runat="server" Text="Save As PDF" OnClick="btnSavePDF_Click" />
                </td>
            </tr>
        </table>
        </form>

    code behind:
     
    protected void btnSavePDF_Click(object sender, EventArgs e)
    {

    fileEditor.ExportToPdf();
    }

    HTML Template:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head>
        <title></title>
    </head>
    <body>
        <h1>Product Service Detail</h1>
        Hi [%=Customer.FirstName%] [%=Customer.LastName%],
            <br />
            I hope you are fine.
            <br />
          Please Note Your Product Services:
        <br />
        [%=ProductServices%]
             
            Thanks,
            <br />
            Best Regards,
            <br />
            [%=ProductManager.FullName%]
             
    </body>
    </html>

    In my code, I fill the data from the database for the sections [%=.....%]. While calling method ExportToPdf() I gets this exception:
    Invalid XHTML. RadEditor content should be correct XHTML in order to export to PDF. Parse error: Unexpected DTD declaration. Line 674, position 13. at line: <body><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    Any help for this ?

    Thanks

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 Dec 2011 Link to this post

    Hello Tejas,

    Check the following demo which implements the same.
    Editor / Export to PDF

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tejas
    Tejas avatar
    31 posts
    Member since:
    Mar 2011

    Posted 12 Dec 2011 Link to this post

    Hi Shinu,

    Thanks for your reply. I have implemented my code following this demo.
    Please copy/paste my HTML to the oneline demo and you will get error.
    I think a problem is a first line of HTML which is a
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


    You may observe the exception I've provided in original post. Any other Idea for this ??

    Thanks
  5. Tejas
    Tejas avatar
    31 posts
    Member since:
    Mar 2011

    Posted 13 Dec 2011 Link to this post

    Hi Shinu,

    Any update on this please ??

    Thanks

    Tejas
  6. Rumen
    Admin
    Rumen avatar
    12851 posts

    Posted 14 Dec 2011 Link to this post

    Hi Tejas,

    The Export to PDF feature of RadEditor cannot be applied when editing full HTML - thus the content cannot contain <html>, <head>, <body> tags. This is a limitation of the ExportToPdf third party tool that RadEditor uses to export its content to PDF.

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017