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

ExportToPdf does not work for RadEditor

4 Answers 136 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Tejas
Top achievements
Rank 1
Tejas asked on 09 Dec 2011, 10:45 PM
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

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Dec 2011, 05:26 AM
Hello Tejas,

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

-Shinu.
0
Tejas
Top achievements
Rank 1
answered on 12 Dec 2011, 03:54 PM
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
0
Tejas
Top achievements
Rank 1
answered on 13 Dec 2011, 08:29 PM
Hi Shinu,

Any update on this please ??

Thanks

Tejas
0
Rumen
Telerik team
answered on 14 Dec 2011, 12:38 PM
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
Tags
Editor
Asked by
Tejas
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Tejas
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or