Export to PDF/DOC

10 posts, 1 answers
  1. possible
    possible avatar
    77 posts
    Member since:
    Oct 2006

    Posted 23 Feb 2009 Link to this post

    Hi,

    I want to export content from RadEditor to PDF/DOC file and save it on server. Now this is not possible becouse:
    a) I can only initate request that will allow user to save file by using ExportToPdf function, will be great to have another function for example: GetContent(Format.PDF) and receive Stream or byte[] content.
    b) PDF export is very limited (no tables, header, footer etc).. do you have any timelines for making export more powerful?

    At the moment only solution is to use 3rd party libraries, please think about that.

    Best regards
  2. Answer
    Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 26 Feb 2009 Link to this post

    Hi,

    Thank you for your feature request about the GetContent(Format.PDF) function. I logged it in our ToDo list for future consideration.

    Currently, you can export a table element by providing for each <td> tag a <col> tag to the TABLE element, e.g.

     <table width="100px">  
            <colgroup>  
                <col />  
            </colgroup>  
            <tbody>  
                <tr>  
                    <td>  
                        TEST  
                    </td>  
                </tr>  
            </tbody>  
        </table>  

    Unfortunately, I cannot provide an exact estimate date when the PDF export feature will be enhanced, because our ToDo list for Q1 2009 is pretty much set.

    Sincerely,
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nicolaï
    Nicolaï avatar
    160 posts
    Member since:
    Apr 2008

    Posted 22 Apr 2009 Link to this post

    Any news on this..?
    I would have needed this badly right now... Have also sent a support ticket...

    Added some:
        <colgroup>  
        <col />  
        </colgroup>
    .. and 1 table started appearing...

    But after adding more
        <colgroup>  
        <col />  
        </colgroup>

    I now get an alert saying "Format error: not a PDF document or corrupted.", when the pdf opens..

    edit
    : fixed above by adding more colgroup...  But it creates a lot of additional chars when you want to save to a db...
    Also, image transparency would be nice... Gif became black background.. Gonna try photoshopping it into correct background...

    edit again:

    Cannot get the pdf export working as expected... Margins, positions not respected,
    I set  Pdf-PageRightMargin="30" and still one table goes all the way out... Some images appear completely out of place...
    Anyone else having problems with pdf export?

  5. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 24 Apr 2009 Link to this post

    Hi Nicolai,

    Thank you for reporting these problems. We are currently collecting all bug reports that apply to the ExportToPDF functionality of RadEditor and we will try to fix them for the next major release of RadEditor (if the time permits).

    Sincerely yours,
    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.
  6. Diederik
    Diederik avatar
    12 posts
    Member since:
    Feb 2009

    Posted 27 Aug 2009 Link to this post

    Hi,

    Is there any news on the timeframe for the table & header/footer features?

    Thanks in advance,
    Diederik
  7. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 01 Sep 2009 Link to this post

    Hi Diederik,

    In order 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> 

    The header and footer features are not supported because the generated HTML content does not have height and it is not possible to break it in different pages.

    Here is some additional information on the new feature that we implement in version 2009.1.527:
    You can now save the generated PDF content from RadEditor in Database or another resource, file, using 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.


    Sincerely,
    Rumen
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. Siddharth Macwan
    Siddharth Macwan avatar
    11 posts
    Member since:
    Oct 2009

    Posted 31 Aug 2010 Link to this post

    Hi,

    the following code produce the proper result in RadEditor with respect to higlighting the background of text but the<span style="background-color: #ffc000;"> seems to have no efffect when exported to PDF. I am using the default filters, Export To PDF Filter and ConvertToShtmlFilter. Please find attached the images for Editor View and the PDF View with the following code



    <table style="width: 0px;border: #8064a2 1px solid;">
        <colgroup><col width="300" /></colgroup>
        <tbody>
            <tr>
                <td style="border: #c00000 1px solid;">Siddharth <strong style="font-weight: bold;">Macwan</strong> </td>
            </tr>
            <tr>
                <td style="border: #c00000 1px solid;">Sandeep <span style="background-color: #ffc000;">Kumar</span></td>
            </tr>
        </tbody>
    </table>

    Thanks

    Sid
  9. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 01 Sep 2010 Link to this post

    Hi Siddharth,

    The observed behavior is a limitation of the third party export to PDF tool that RadEditor uses to export the produced XHTML content to PDF.
    You can print only the background-color attribute of block elements such as <p>,<div>, etc.

    <div style="background-color: #ffff00;">Hello World</div>


    All the best,
    Rumen
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Siddharth Macwan
    Siddharth Macwan avatar
    11 posts
    Member since:
    Oct 2009

    Posted 01 Sep 2010 Link to this post

    I tried Div but then it is giving a line break in PDF even I add a style  " dispplay:inline;" to the Div...
    So even " dispplay:inline;" to the Div...doesnot seem working for PDF export...User can not highlight any word and export to PDF in this case...



    <table style="width: 0px;border: #8064a2 1px solid;">
        <colgroup><col width="300" /></colgroup>
        <tbody>
            <tr>
                <td style="border: #c00000 1px solid;">Siddharth <strong style="font-weight: bold;">Macwan</strong> </td>
            </tr>
            <tr>
                <td style="border: #c00000 1px solid;">Sandeep <div style="background-color: #ffc000;display:inline;">Kumar</div></td>
            </tr>
        </tbody>
    </table>

    it produce the out put in PDF as

    Sandip
    Kumar

    instead of
    Sandip Kumar

    Thanks

    Sid



  11. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 06 Sep 2010 Link to this post

    Hi Sid,

    RadEditor is using a third-party tool named Fo.NET to provide HTMLtoPDF conversion. As I already noted the export to pdf library has limited WYSIWYG abilities and the required feature is not offered out-of-the box.
    I understand the problem, but you should choose between using highlighted div tags or span tags without background colors.

    Since the Fo.NET is an open source library, you can download it and try to fix the problem yourself.
    Another approach is to search in Google for another third party HTML to PDF converter, which offers better HTML to PDF export abilities. You can use the following KB article as a base to integrate such a third party converter with RadEditor: Converting RadEditor HTML to PDF format.

    Best regards,
    Rumen
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017