Hi thank you very much for your help up to now , because of your help I able to save to PDF once I click a button.
but there is an issue, once I click the button its saving ""Type here" text only ,
this is the view of it.
it doesn't extracting currntly edited content from the RTE , I think its saving "Type here" text because of this code line
- editor.Text = "Type here";
inside the PrepairEditor() method . How to extract currently edited content ?
Here my relavant , BrochureController.cs file methods
- [ValidateInput(false)]
- public ActionResult output_xhtml()
- {
- PrepairEditor(delegate (Editor editor)
- {
- editor.LoadHtml("~/brochuretemplates/myhtml.html");
- });
- return View();
- }
-
- [HttpPost]
- [ValidateInput(false)]
- public ActionResult output_xhtml(string m)
- {
- Editor theeditor = PrepairEditor(delegate (Editor editor)
- {
-
- });
-
- theeditor.SavePDF(m);
-
- return View();
- }
-
- protected Editor PrepairEditor(Action<Editor> oninit)
- {
- Editor editor = new Editor(System.Web.HttpContext.Current, "editor");
-
- editor.ClientFolder = "/richtexteditor/";
- editor.ContentCss = "/Content/example.css";
-
-
-
- editor.Text = "Type here";
-
- editor.AjaxPostbackUrl = Url.Action("EditorAjaxHandler");
-
- if (oninit != null) oninit(editor);
-
-
- bool isajax = editor.MvcInit();
-
- if (isajax)
- return editor;
-
-
- if (this.Request.HttpMethod == "POST")
- {
- string formdata = this.Request.Form[editor.Name];
- if (formdata != null)
- editor.LoadFormData(formdata);
- }
-
-
- ViewBag.Editor = editor.MvcGetString();
-
- return editor;
- }
-
-
-
- [ValidateInput(false)]
- public ActionResult EditorAjaxHandler()
- {
- PrepairEditor(delegate (Editor editor)
- {
-
- });
- return new EmptyResult();
- }
Here the output_xhtml.cshtml file
- @{
- ViewBag.Title = "Index";
- Layout = "~/Views/Shared/_Layout.cshtml";
- }
-
- <h4> Edit the Brochure </h4>
-
-
- <form>
- <div> @Html.Raw(ViewBag.Editor) </div>
- </form>
-
- <div style="margin-top:10px">
- <button id="MyButton" type="button" class="btn btn-danger submit">Save as PDF</button>
- </div>
-
- @section Scripts {
- @Scripts.Render("~/bundles/jqueryval")
- @Scripts.Render("~/bundles/jqueryui")
-
- <script>
-
- $('#MyButton').click(function () {
-
- var model = { m: "~/brochuretemplates/anemeh.pdf" };
-
- $.ajax({
- url: '@Url.Action("output_xhtml", "Brochure")',
- contentType: 'application/json; charset=utf-8',
- type: 'POST',
- dataType: 'html',
- data: JSON.stringify(model)
- })
- .success(function(result) {
- });
- });
-
- </script>
-
-
-
- <script type='text/javascript'>
- function RichTextEditor_OnLoad(editor)
- {
- editor.SetWidth(1150);
- editor.SetHeight(612);
- }
- </script>
- }