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

[Solved] How to get RedEditor Exportpdf content.

1 Answer 152 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Hrushikesh Mokashi
Top achievements
Rank 1
Hrushikesh Mokashi asked on 10 Aug 2009, 06:33 AM
Hi All,

I am using RadControl Q1 2009.
I am using RadEditor control.

I have the following questions

1)How can i get the pdf content to save the pdf in database ?
2)How can i get the exportpdf content ?
3)While exporting it is not showing the table from editor, how can i export all the content from editor ?

4) It is possible to show the pdf and asp button on same aspx page?
 5) The event OnExportContent="RadEditor1_ExportContent"  not present with q1 2009 version?


Thanks,








1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 12 Aug 2009, 11:55 AM
Hi Hrushikesh,

To save the generated PDF content from RadEditor in Database, you should use the OnExportContent event. This event was implemented in version 2009.1.527 of Telerik.Web.UI.dll and is not supported in the previous versions.

For your convenience I prepared and attached here an example demonstrating how to export the editor's content as PDF on the server using the new OnExportContent event property of RadEditor. The demo is based on the following blog post:
How To: Export grid to PDF file and show the result using the window.

Please, note that there some limitations in the export to pdf functionality: for example to export a TABLE element, you should add COLGROUP and COL tags for each table row and set table width. You can do that programmatically using the following custom content filter:

<telerik:RadEditor ID="RadEditor1" runat="server" OnClientLoad="OnClientLoad" > 
 <ImageManager ViewPaths="~/Images" UploadPaths="~/Images" /> 
 <ExportSettings OpenInNewWindow="true" /> 
    <Content> 
    </Content> 
</telerik:RadEditor>   
<script type="text/javascript"
    var editorObject; 
    function OnClientLoad(editor, args) 
    { 
       editor.get_filtersManager().add(new MyFilter()); 
       editorObject = editor; 
    } 
     
    MyFilter = function() 
    { 
       MyFilter.initializeBase(this); 
       this.set_isDom(true); 
       this.set_enabled(true); 
       this.set_name("RadEditor filter"); 
       this.set_description("RadEditor filter description"); 
    } 
    MyFilter.prototype = 
    { 
    //Table neeed 1) COLGOUPS!, 2) width! 
     
       getHtmlContent : function(content) 
       { 
         var newContent = content; 
         var tables = newContent.getElementsByTagName("TABLE"); 
         var colCount = null
         var editorDocument = editorObject.get_document(); 
          
         for (var i=0; i < tables.length; i++) 
         { 
                var table = tables[i]; 
                 
                table.style.width = "0px"
                 
                //If there are colgroups - skip table 
                var groups = table.getElementsByTagName("colgroup"); 
                if (groups.length > 0) continue;//! 
                 
                 
                colCount  = table.rows[0].cells.length;                                                    
               // create colgroup 
               var newColGroup = editorDocument.createElement("colgroup"); 
                
               // create cols 
               var newCol; 
               for(var j=0; j<colCount; j++) 
               { 
                  // create cols 
                  newCol = editorDocument.createElement("col"); 
                  newColGroup.appendChild(newCol); 
                   
               } 
                
               //table.appendChild(newColGroup) 
               table.insertBefore(newColGroup, table.firstChild); 
         } 
         //newContent = newContent.toUpperCase(); 
         return newContent; 
       } 
    } 
     
    MyFilter.registerClass('MyFilter', Telerik.Web.UI.Editor.Filter); 
    </script> 



Regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Editor
Asked by
Hrushikesh Mokashi
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or