RTE content saving as PDF with unformatted structure and missing sections

Last post 10-15-2015, 9:52 AM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  10-15-2015, 5:14 AM 81118

    RTE content saving as PDF with unformatted structure and missing sections

     I'm loading .html file into RTE editor ,  then Once I click Save as PDF button its saving as PDF 

     

    this is view of RTE editor content

     

     

     

    Once I click save as PDF and open it throuch adobe pdf reader , I'm getting this kind PDF 

     

     

    its a unformatted structure with missing sections , what can I do to get exact view that existing in RTE editor content

     

    this is controller related method

     

       

    1. [HttpGet]  
    2. [ValidateInput(false)]  
    3.   
    4. public ActionResult output_xhtml()  
    5. {  
    6.     PrepairEditor(delegate (Editor editor)  
    7.     {  
    8.         editor.LoadHtml("~/brochuretemplates/myhtml.html");  
    9.     });  
    10.     return View();  
    11. }  
    12.   
    13. [HttpPost]  
    14. [ValidateInput(false)]  
    15. public ActionResult output_xhtml(string m)  
    16. {  
    17.     Editor theeditor = PrepairEditor(delegate (Editor editor)  
    18.     {  
    19.   
    20.     });  
    21.   
    22.     theeditor.SavePDF("~/brochuretemplates/anemeh.pdf");  
    23.   
    24.     return View();  
    25. }  
     

     
    1. [HttpGet]  
    2. [ValidateInput(false)]  
    3.   
    4. public ActionResult output_xhtml()  
    5. {  
    6.     PrepairEditor(delegate (Editor editor)  
    7.     {  
    8.         editor.LoadHtml("~/brochuretemplates/myhtml.html");  
    9.     });  
    10.     return View();  
    11. }  
    12.   
    13. [HttpPost]  
    14. [ValidateInput(false)]  
    15. public ActionResult output_xhtml(string m)  
    16. {  
    17.     Editor theeditor = PrepairEditor(delegate (Editor editor)  
    18.     {  
    19.   
    20.     });  
    21.   
    22.     theeditor.SavePDF("~/brochuretemplates/anemeh.pdf");  
    23.   
    24.     return View();  
    25. }  
    26.   
    27. [ValidateInput(false)]  
    28. protected Editor PrepairEditor(Action<Editor> oninit)  
    29. {  
    30.     Editor editor = new Editor(System.Web.HttpContext.Current, "editor");  
    31.   
    32.     editor.ClientFolder = "~/richtexteditor/";  
    33.     editor.ContentCss = "~/Content/example.css";  
    34.     //editor.ClientFolder = "/Content/richtexteditor/";        
    35.     //editor.ClientFolder = "/Scripts/richtexteditor/";        
    36.   
    37.     editor.Text = "Type here";  
    38.   
    39.     editor.AjaxPostbackUrl = Url.Action("EditorAjaxHandler");  
    40.   
    41.     if (oninit != null) oninit(editor);  
    42.   
    43.     //try to handle the upload/ajax requests        
    44.     bool isajax = editor.MvcInit();  
    45.   
    46.     if (isajax)  
    47.         return editor;  
    48.   
    49.     //load the form data if any        
    50.     if (this.Request.HttpMethod == "POST")  
    51.     {  
    52.         string formdata = this.Request.Form[editor.Name];  
    53.         if (formdata != null)  
    54.             editor.LoadFormData(formdata);  
    55.     }  
    56.   
    57.     //render the editor to ViewBag.Editor        
    58.     ViewBag.Editor = editor.MvcGetString();  
    59.   
    60.     return editor;  
    61. }  

     output_xhtml.cshtml   view page

    1. @{  
    2.     ViewBag.Title = "Create Brochure";  
    3.      
    4. }  
    5.   
    6.   
    7. <!DOCTYPE html>  
    8. <html>  
    9. <head>  
    10.     <title>RichTextEditor - Output XHTML</title>      
    11. </head>  
    12. <body>  
    13.   
    14.     @using (Html.BeginForm())  
    15.     {  
    16.   
    17.             <div>  
    18.                 @Html.Raw(ViewBag.Editor)  
    19.                 <br />  
    20.                 <button id="btn_sumbit" type="submit" class="btn btn-danger submit">Save as PDF</button>                     
    21.             </div>  
    22.           
    23.   
    24.     }  
    25. </body>  
    26. </html>  
    27.   
    28. @section Scripts {  
    29.     @Scripts.Render("~/bundles/jqueryval")  
    30.     @Scripts.Render("~/bundles/jqueryui")  
    31.   
    32. <script type="text/javascript">  
    33.   
    34.     var editor;  
    35.   
    36.     function RichTextEditor_OnLoad(editor) {  
    37.         editoreditor = editor;  
    38.             var content = true;  
    39.             if (!content) {  
    40.                 setTimeout(function () {  
    41.                     editor.SetText("<table>...</table>");  
    42.                 }, 1000);  
    43.                 return;  
    44.             }  
    45.         }  
    46.   
    47. </script>  
    48.   
    49.   
    50. <script type='text/javascript'>  
    51.   
    52.     function RichTextEditor_OnLoad(editor) {  
    53.         editor.SetWidth(1150); //Sets the width.  
    54.         editor.SetHeight(612); //Sets the height.  
    55.     }  
    56.   
    57. </script>  
    58.   
    59. }  

     

    myhtml.html : this is RTE editor content loading html file

     

     

    1.  
    2.  
    3. <!DOCTYPE html>  
    4. <html>  
    5. <head>   
    6. </head>  
    7. <body>  
    8.     <div id="header" style="font-family:'Segoe UI';background-color: black;color: white;text-align: center;padding: 5px;">  
    9.         <h1 style="font-family:'Segoe UI';color: white;text-align: center;">Bank Brochure</h1>  
    10.     </div>  
    11.   
    12.     <div id="nav" style="font-family:'Segoe UI';line-height: 30px;background-color: #eeeeee;height: 300px;width: 100px;float: left;padding: 5px;">  
    13.         London<br>  
    14.         Paris<br>  
    15.         Tokyo<br>  
    16.     </div>  
    17.   
    18.     <div id="section" style="font-family:'Segoe UI';float: left;padding: 10px;color:black">  
    19.         <h2>London</h2>  
    20.         <p>  
    21.             London is the capital city of England. It is the most populous city in the United Kingdom,  
    22.             with a metropolitan area of over 13 million inhabitants.  
    23.         </p>  
    24.         <p>  
    25.             Standing on the River Thames, London has been a major settlement for two millennia,  
    26.             its history going back to its founding by the Romans, who named it Londinium.  
    27.         </p>  
    28.     </div>  
    29.   
    30.     <div id="footer" style="font-family:'Segoe UI';background-color: black;color: white;clear: both;text-align: center;padding: 5px;">  
    31.         Copyright © 2015 Zoo Group , Solution by kelum.  
    32.     </div>  
    33.   
    34.       
    35. </body>  
    36. </html>  
     

  •  10-15-2015, 9:52 AM 81127 in reply to 81118

    Re: RTE content saving as PDF with unformatted structure and missing sections

    Hi,

     

    this due to the style settings of your html content, some of the styles does not support in pdf. for example the "float: left; ".

     

    Regards,

     

    Ken 

View as RSS news feed in XML