protected override void WriteToFile()
 {
     using (var pdfStream = File.Open(OutputFileLocation, FileMode.Create))
     {
         var htmlFormatProvider = new HtmlFormatProvider();
         htmlFormatProvider.Export(Document, pdfStream);
     }
 }
        private void Show(object obj)
        {
            RadFlowDocument document = this.CreateDocument();
            HtmlFormatProvider formatProvider = new HtmlFormatProvider();
            string html = formatProvider.Export(document);

            WebBrowser browser = new WebBrowser();
            browser.NavigateToString(html);

            Window window = new Window() { Width = 1000, Height = 350 };
            window.Content = browser;
            window.Show();
        }
Beispiel #3
0
        public ActionResult SaveEdit(int id, string titleUa, string titleEn, string body, string bodyEn, string detailUrl, string videoUrl, string pic)
        {
            string             bodyHtml     = HttpUtility.HtmlDecode(body);
            string             bodyHtmlEn   = HttpUtility.HtmlDecode(bodyEn);
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadFlowDocument    document     = htmlProvider.Import(bodyHtml);
            RadFlowDocument    documentEn   = htmlProvider.Import(bodyHtmlEn);

            using (Context db = new Context())
            {
                var news = db.Newses.FirstOrDefault(x => x.NewsId == id);
                if (news != null)
                {
                    news.Title     = titleUa;
                    news.TitleEn   = titleEn;
                    news.DateNews  = DateTime.Now;
                    news.Body      = htmlProvider.Export(document);
                    news.BodyEn    = htmlProvider.Export(documentEn);
                    news.DetailUrl = detailUrl;
                    news.Video     = videoUrl;
                    news.Picture   = pic;
                    db.SaveChanges();
                }
            }

            return(RedirectToAction("Index"));
        }
Beispiel #4
0
        //***************************************************
        //*********Prehistory and Rules**********************
        private void cmbSavePrehistory_Click(object sender, EventArgs e)
        {
            string prehistoryText = htmlProvider.Export(rtbPrehistory.Document);

            prehistory.updateTextFromUI(prehistoryText);
            prehistory.saveTextToFile();
        }
Beispiel #5
0
        public ActionResult SaveNew(string bodyContentUA, string bodyContentEN, string fileNamePhoto, string mainName, string mainNameEn,
                                    string phone1, string phone2, string phone3, string email, string fbUrl, string googleUrl, string twUrl, string instUrl, string city, string cityEn)
        {
            string             bodyHtml     = HttpUtility.HtmlDecode(bodyContentUA);
            string             bodyHtmlEn   = HttpUtility.HtmlDecode(bodyContentEN);
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadFlowDocument    document     = htmlProvider.Import(bodyHtml);
            RadFlowDocument    documentEn   = htmlProvider.Import(bodyHtmlEn);

            using (Context db = new Context())
            {
                db.TeamMembers.Add(new TeamMember
                {
                    City          = city,
                    CityEn        = cityEn,
                    Description   = htmlProvider.Export(document),
                    DescriptionEn = htmlProvider.Export(documentEn),
                    Email         = email,
                    Fb            = fbUrl,
                    Inst          = instUrl,
                    Google        = googleUrl,
                    Name          = mainName,
                    NameEn        = mainNameEn,
                    Phone1        = phone1,
                    Phone2        = phone2,
                    Phone3        = phone3,
                    Tw            = twUrl,
                    Photo         = fileNamePhoto,
                });
                db.SaveChanges();
            }
            return(null);
        }
Beispiel #6
0
        public ActionResult Save(string titleUa, string titleEn, string body, string bodyEn, string detailUrl, string videoUrl, string pic)
        {
            string             bodyHtml     = HttpUtility.HtmlDecode(body);
            string             bodyHtmlEn   = HttpUtility.HtmlDecode(bodyEn);
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadFlowDocument    document     = htmlProvider.Import(bodyHtml);
            RadFlowDocument    documentEn   = htmlProvider.Import(bodyHtmlEn);

            using (Context db = new Context())
            {
                db.Newses.Add(new News
                {
                    Title     = titleUa,
                    TitleEn   = titleEn,
                    DateNews  = DateTime.Now,
                    Body      = htmlProvider.Export(document),
                    BodyEn    = htmlProvider.Export(documentEn),
                    DetailUrl = detailUrl,
                    Video     = videoUrl,
                    Picture   = pic
                });
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Beispiel #7
0
        public ActionResult SaveEdit(int id, string bodyContentUA, string bodyContentEN, string fileNamePhoto, string mainName, string mainNameEn,
                                     string phone1, string phone2, string phone3, string email, string fbUrl, string googleUrl, string twUrl, string instUrl, string city, string cityEn)
        {
            string             bodyHtml     = HttpUtility.HtmlDecode(bodyContentUA);
            string             bodyHtmlEn   = HttpUtility.HtmlDecode(bodyContentEN);
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadFlowDocument    document     = htmlProvider.Import(bodyHtml);
            RadFlowDocument    documentEn   = htmlProvider.Import(bodyHtmlEn);
            var curMamber = context.TeamMembers.FirstOrDefault(x => x.Id == id);

            if (curMamber != null)
            {
                curMamber.City          = city;
                curMamber.CityEn        = cityEn;
                curMamber.Description   = htmlProvider.Export(document);
                curMamber.DescriptionEn = htmlProvider.Export(documentEn);
                curMamber.Email         = email;
                curMamber.Fb            = fbUrl;
                curMamber.Inst          = instUrl;
                curMamber.Google        = googleUrl;
                curMamber.Name          = mainName;
                curMamber.NameEn        = mainNameEn;
                curMamber.Phone1        = phone1;
                curMamber.Phone2        = phone2;
                curMamber.Phone3        = phone3;
                curMamber.Tw            = twUrl;
                curMamber.Photo         = fileNamePhoto;

                context.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Beispiel #8
0
        private static string OpenDocumentCore(Stream inputStream, DocumentType documentType)
        {
            var importProvider = CreateFormatProvider(documentType);
            var exportProvider = new HtmlFormatProvider();
            var flowDocument   = importProvider.Import(inputStream);

            //// Remove large left and hanging indentations of paragraphs in lists when importing from RTF
            foreach (Paragraph paragraph in flowDocument.EnumerateChildrenOfType <Paragraph>())
            {
                if (paragraph.ListId > -1)
                {
                    Telerik.Windows.Documents.Flow.Model.Lists.List list = flowDocument.Lists.GetList(paragraph.ListId);
                    if (paragraph.Indentation.HangingIndent == list.Levels[0].ParagraphProperties.HangingIndent.LocalValue)
                    {
                        paragraph.Indentation.HangingIndent = Paragraph.HangingIndentPropertyDefinition.DefaultValue.Value;
                        paragraph.Indentation.LeftIndent    = Paragraph.LeftIndentPropertyDefinition.DefaultValue.Value;
                    }

                    if (paragraph.Indentation.FirstLineIndent == list.Levels[0].ParagraphProperties.FirstLineIndent.LocalValue)
                    {
                        paragraph.Indentation.FirstLineIndent = Paragraph.FirstLineIndentPropertyDefinition.DefaultValue.Value;
                    }
                }
            }

            return(exportProvider.Export(flowDocument));
        }
Beispiel #9
0
        /// <summary>
        /// Import a file from disk and convert it to an HTML string for use in the Editor
        /// </summary>
        /// <returns>An HTML string that is just the contents of the body tag so the editor can work with them. Returns null to denote an error.</returns>
        public string GetHtmlString()
        {
            try
            {
                // read the file - in this sample a hardcoded path
                string          path     = Path.Combine(Environment.WebRootPath, "JohnGrisham.docx");
                RadFlowDocument document = ReadFile(path);

                // convert the file to HTML
                HtmlFormatProvider provider = new HtmlFormatProvider();
                provider.ExportSettings.StylesExportMode    = StylesExportMode.Inline;
                provider.ExportSettings.DocumentExportLevel = DocumentExportLevel.Fragment;
                string html = provider.Export(document);

                // get only the <body> contents
                int    bodyStart = html.IndexOf("<body>") + "<body>".Length;
                int    bodyEnd   = html.IndexOf("</body>");
                string body      = html.Substring(bodyStart, bodyEnd - bodyStart);

                return(body);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        private static string OpenDocumentCore(Stream inputStream, DocumentType documentType)
        {
            var importProvider = CreateFormatProvider(documentType);
            var exportProvider = new HtmlFormatProvider();
            var flowDocument   = importProvider.Import(inputStream);

            return(exportProvider.Export(flowDocument));
        }
Beispiel #11
0
 private void ExportToString()
 {
     #region radwordsprocessing-formats-and-conversion-html-htmlformatprovider_3
     RadFlowDocument    document = CreateRadFlowDocument();
     HtmlFormatProvider provider = new HtmlFormatProvider();
     string             html     = provider.Export(document);
     #endregion
 }
Beispiel #12
0
        private void SaveDocument(RadFlowDocument document)
        {
            HtmlFormatProvider formatProvider = new HtmlFormatProvider();

            using (var stream = File.OpenWrite("Sample Document.html"))
            {
                formatProvider.Export(document, stream);
            }
        }
Beispiel #13
0
        public ActionResult SaveNew(string bodyContentUA, string bodyContentEN, string fileNameBLogo, string fileNamePhoto, string mainName, string mainNameEn, string address,
                                    string addressEn, string phone1, string phone2, string phone3, string email, string siteUrl, string fbUrl, string googleUrl, string twUrl, string instUrl, string mapUrl,
                                    int category, string videoUrl, string city, string cityEn)
        {
            string             bodyHtml     = HttpUtility.HtmlDecode(bodyContentUA);
            string             bodyHtmlEn   = HttpUtility.HtmlDecode(bodyContentEN);
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadFlowDocument    document     = htmlProvider.Import(bodyHtml);
            RadFlowDocument    documentEn   = htmlProvider.Import(bodyHtmlEn);

            using (Context db = new Context())
            {
                var cat = db.CategoryBusnesses.FirstOrDefault(x => x.IdCategory == category);
                db.Businesses.Add(new Business
                {
                    Address       = address,
                    AddressEn     = addressEn,
                    City          = city,
                    CityEn        = cityEn,
                    DateAdd       = DateTime.Now,
                    Description   = htmlProvider.Export(document),
                    DescriptionEn = htmlProvider.Export(documentEn),
                    Email         = email,
                    Fb            = fbUrl,
                    Inst          = instUrl,
                    Google        = googleUrl,
                    MainName      = mainName,
                    MainNameEn    = mainNameEn,
                    Phone1        = phone1,
                    Phone2        = phone2,
                    Phone3        = phone3,
                    Site          = siteUrl,
                    Map           = mapUrl,
                    Tw            = twUrl,
                    Video         = videoUrl,
                    Logo          = fileNameBLogo,
                    Photo         = fileNamePhoto,
                    Category      = cat
                });
                db.SaveChanges();
            }
            return(null);
        }
Beispiel #14
0
        public ActionResult Save(int id, string bodyContentUA, string bodyContentEN, string fileNameBLogo, string fileNamePhoto, string mainName, string mainNameEn, string address,
                                 string addressEn, string phone1, string phone2, string phone3, string email, string siteUrl, string fbUrl, string googleUrl, string twUrl, string instUrl, string mapUrl,
                                 int category, string videoUrl, string city, string cityEn)
        {
            string             bodyHtml     = HttpUtility.HtmlDecode(bodyContentUA);
            string             bodyHtmlEn   = HttpUtility.HtmlDecode(bodyContentEN);
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadFlowDocument    document     = htmlProvider.Import(bodyHtml);
            RadFlowDocument    documentEn   = htmlProvider.Import(bodyHtmlEn);
            var curBuisnes = db.Businesses.FirstOrDefault(x => x.BusinessId == id);

            if (curBuisnes != null)
            {
                var cat = db.CategoryBusnesses.FirstOrDefault(x => x.IdCategory == category);
                curBuisnes.Address       = address;
                curBuisnes.AddressEn     = addressEn;
                curBuisnes.City          = city;
                curBuisnes.CityEn        = cityEn;
                curBuisnes.Description   = htmlProvider.Export(document);
                curBuisnes.DescriptionEn = htmlProvider.Export(documentEn);
                curBuisnes.Email         = email;
                curBuisnes.Fb            = fbUrl;
                curBuisnes.Inst          = instUrl;
                curBuisnes.Google        = googleUrl;
                curBuisnes.MainName      = mainName;
                curBuisnes.MainNameEn    = mainNameEn;
                curBuisnes.Phone1        = phone1;
                curBuisnes.Phone2        = phone2;
                curBuisnes.Phone3        = phone3;
                curBuisnes.Site          = siteUrl;
                curBuisnes.Map           = mapUrl;
                curBuisnes.Tw            = twUrl;
                curBuisnes.Video         = videoUrl;
                curBuisnes.Logo          = fileNameBLogo;
                curBuisnes.Photo         = fileNamePhoto;
                curBuisnes.Category      = cat;

                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Beispiel #15
0
 private void ExportToFile()
 {
     #region radwordsprocessing-formats-and-conversion-html-htmlformatprovider_2
     HtmlFormatProvider provider = new HtmlFormatProvider();
     using (Stream output = File.Create("Sample.html"))
     {
         RadFlowDocument document = CreateRadFlowDocument();
         provider.Export(document, output);
     }
     #endregion
 }
Beispiel #16
0
        public ActionResult Save(int id, string bodyContentUA, string bodyContentEN, string phone1, string phone2, string phone3, string email)
        {
            string             bodyHtml     = HttpUtility.HtmlDecode(bodyContentUA);
            string             bodyHtmlEn   = HttpUtility.HtmlDecode(bodyContentEN);
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadFlowDocument    document     = htmlProvider.Import(bodyHtml);
            RadFlowDocument    documentEn   = htmlProvider.Import(bodyHtmlEn);
            var cur = db.AboutUses.FirstOrDefault(x => x.Id == id);

            if (cur != null)
            {
                cur.Description   = htmlProvider.Export(document);
                cur.DescriptionEn = htmlProvider.Export(documentEn);
                cur.Email         = email;
                cur.Phone1        = phone1;
                cur.Phone2        = phone2;
                cur.Phone3        = phone3;
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Beispiel #17
0
        public ActionResult SaveNew(string bodyContentUA, string bodyContentEN, string fileNameBLogo, string address,
                                    string addressEn, string phone1, string phone2, string phone3, string siteUrl, string fbUrl, string googleUrl, string twUrl, string instUrl, string mapUrl,
                                    string city, string cityEn, string name, string nameEn, string email)
        {
            string             bodyHtml     = HttpUtility.HtmlDecode(bodyContentUA);
            string             bodyHtmlEn   = HttpUtility.HtmlDecode(bodyContentEN);
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadFlowDocument    document     = htmlProvider.Import(bodyHtml);
            RadFlowDocument    documentEn   = htmlProvider.Import(bodyHtmlEn);

            using (Context db = new Context())
            {
                db.Jobses.Add(new Jobs
                {
                    Address           = address,
                    AddressEn         = addressEn,
                    City              = city,
                    CityEn            = cityEn,
                    DateAdd           = DateTime.Now,
                    DescriptionJobs   = htmlProvider.Export(document),
                    DescriptionEnJobs = htmlProvider.Export(documentEn),
                    Fb          = fbUrl,
                    Inst        = instUrl,
                    Google      = googleUrl,
                    Phone1      = phone1,
                    Phone2      = phone2,
                    Phone3      = phone3,
                    Site        = siteUrl,
                    Map         = mapUrl,
                    Tw          = twUrl,
                    LogoJobs    = fileNameBLogo,
                    TitleJobs   = name,
                    TitleEuJobs = nameEn,
                    EmailJobs   = email
                });
                db.SaveChanges();
            }
            return(null);
        }
        public override void Export(RadDocument document, Stream output)
        {
            //export as HTML
            using (output)
            {
                htmlProvider.Export(document, output);
            }
            //using Aspose.HTML to convert html to markdown
            var documentap = new HTMLDocument(outPath + "\\hide.html");
            var path       = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            documentap.Save(Path.GetFullPath(outPath + "\\MarkDownFile.md"), HTMLSaveFormat.Markdown);
        }
Beispiel #19
0
        public ActionResult Save(int id, string bodyContentUA, string bodyContentEN, string fileNameBLogo, string address,
                                 string addressEn, string phone1, string phone2, string phone3, string siteUrl, string fbUrl, string googleUrl, string twUrl, string instUrl, string mapUrl,
                                 string city, string cityEn, string name, string nameEn, string email)
        {
            string             bodyHtml     = HttpUtility.HtmlDecode(bodyContentUA);
            string             bodyHtmlEn   = HttpUtility.HtmlDecode(bodyContentEN);
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadFlowDocument    document     = htmlProvider.Import(bodyHtml);
            RadFlowDocument    documentEn   = htmlProvider.Import(bodyHtmlEn);
            var curJob = db.Jobses.FirstOrDefault(x => x.JobsId == id);

            if (curJob != null)
            {
                curJob.Address         = address;
                curJob.AddressEn       = addressEn;
                curJob.City            = city;
                curJob.TitleJobs       = name;
                curJob.TitleEuJobs     = nameEn;
                curJob.CityEn          = cityEn;
                curJob.DescriptionJobs = htmlProvider.Export(document);
                curJob.DescriptionJobs = htmlProvider.Export(documentEn);
                curJob.Fb        = fbUrl;
                curJob.Inst      = instUrl;
                curJob.Google    = googleUrl;
                curJob.Phone1    = phone1;
                curJob.Phone2    = phone2;
                curJob.Phone3    = phone3;
                curJob.Site      = siteUrl;
                curJob.Map       = mapUrl;
                curJob.Tw        = twUrl;
                curJob.LogoJobs  = fileNameBLogo;
                curJob.EmailJobs = email;

                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
        private void SaveDocument(RadFlowDocument document)
        {
            HtmlFormatProvider formatProvider = new HtmlFormatProvider();

            string path = "Sample Document.html";

            using (var stream = File.OpenWrite(path))
            {
                formatProvider.Export(document, stream);
            }

            Console.Write("Document generated.");
            Process.Start(path);
        }
        private void Show(object obj)
        {
            RadFlowDocument    document       = this.CreateDocument();
            HtmlFormatProvider formatProvider = new HtmlFormatProvider();
            string             html           = formatProvider.Export(document);

            WebBrowser browser = new WebBrowser();

            browser.NavigateToString(html);

            Window window = new Window()
            {
                Width = 1000, Height = 350
            };

            window.Content = browser;
            window.Show();
        }
        public string GetRawText()
        {
            var description = HtmlFormatProvider.Export(RadRichTextBox.Document);

            //if (_descriptionWidth > 0)
            //{
            //    //custom sizing provided
            //    return string.Format(@"<div id=""GlymaNodeDescriptionDiv"" width=""{0}"" height=""{1}"" style=""width:{0}px;height:{1}px;"">{2}</div>", _descriptionWidth, _descriptionHeight, description);
            //}
            if (string.IsNullOrWhiteSpace(description))
            {
                //no content, return empty
                return(string.Empty);
            }
            return(description);
            ////no custom sizing but want to mark it up as coming from the RichTextEdit rather than the advanced
            //return string.Format(@"<div id=""GlymaNodeDescriptionDiv"">{0}</div>", description);
        }
Beispiel #23
0
        public static void SaveDocument(RadFlowDocument document, string selectedFormat)
        {
            HtmlFormatProvider formatProvider = new HtmlFormatProvider();

            SaveFileDialog dialog = new SaveFileDialog();

            dialog.Filter = String.Format("{0} files|*{1}|All files (*.*)|*.*",
                                          selectedFormat,
                                          formatProvider.SupportedExtensions.First());
            dialog.FilterIndex = 1;

            if (dialog.ShowDialog() == true)
            {
                using (var stream = dialog.OpenFile())
                {
                    formatProvider.Export(document, stream);
                }
            }
        }
        /// <summary>
        /// This method is provided for when populating the HtmlEditor in Advanced (Raw) mode, it doesn't insert the GlymaNodeDescription DIV around the content
        /// </summary>
        /// <returns></returns>
        public string GetRawTextForAdvancedMode()
        {
            var description = HtmlFormatProvider.Export(RadRichTextBox.Document);

            if (description.Length > 8000)
            {
                SuperMessageBoxService.ShowError("Save Description Failed", "Sorry, your description is too long.");
                description = NodeProperties.Description;
            }
            if (string.IsNullOrWhiteSpace(description))
            {
                //no content, return empty
                return(string.Empty);
            }
            else
            {
                return(description);
            }
        }
Beispiel #25
0
        public ActionResult ImportDocx()
        {
            RadFlowDocument    flowDocument;
            DocxFormatProvider docxProvider = new DocxFormatProvider();

            using (Stream input = System.IO.File.OpenRead(Server.MapPath("~/App_Data/Sample.docx")))
            {
                flowDocument = docxProvider.Import(input);
            }

            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();

            htmlProvider.ExportSettings.DocumentExportLevel = DocumentExportLevel.Fragment;
            htmlProvider.ExportSettings.StylesExportMode    = StylesExportMode.Inline;

            string html = htmlProvider.Export(flowDocument);

            return(Content(html));
        }
        private void SaveDocument(RadFlowDocument document)
        {
            HtmlFormatProvider formatProvider = new HtmlFormatProvider();

            string path = "Sample Document.html";

            using (FileStream stream = File.OpenWrite(path))
            {
                formatProvider.Export(document, stream);
            }

            Console.Write("Document generated.");

            ProcessStartInfo psi = new ProcessStartInfo()
            {
                FileName        = path,
                UseShellExecute = true
            };

            Process.Start(psi);
        }
Beispiel #27
0
        public ActionResult UploadResumeDoc(HttpPostedFileBase customDocument)
        {
            ResultModel result = new ResultModel();
            IFormatProvider <RadFlowDocument> fileFormatProvider = null;
            RadFlowDocument document = null;
            string          mimeType = String.Empty;

            fileFormatProvider = new HtmlFormatProvider();
            if (customDocument != null && Regex.IsMatch(Path.GetExtension(customDocument.FileName), ".docx|.rtf|.html|.txt"))
            {
                document = fileFormatProvider.Import(customDocument.InputStream);
                HtmlFormatProvider provider = new HtmlFormatProvider();
                string             html     = provider.Export(document);
                UserResumeDocModel sd       = new UserResumeDocModel()
                {
                    UserID = SessionItems.CurrentUser.Id, DocText = html
                };
                result = sd.SaveOrUpDate();
                if (result.BooleanResult)
                {
                    result.BooleanResult = true;
                    result.StringResult  = "Upload Successfully!";
                }
                else
                {
                    result.BooleanResult = false;
                    result.StringResult  = "Upload fail! Please try again!";
                }
            }
            else
            {
                //invalid files
                result.BooleanResult = false;
                result.StringResult  = "Invalid document! Please try again.";
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        private string ExportAnnotationRangeFragment(RadDocument document, string semanticRangeName)
        {
            RecipeRangeStart semanticRangestart = null;
            RecipeRangeEnd semanticRangeEnd = null;
            foreach (RecipeRangeStart rangeStart in document.GetAnnotationMarkersOfType<RecipeRangeStart>())
            {
                if (rangeStart.Name == semanticRangeName)
                {
                    semanticRangestart = rangeStart;
                    semanticRangeEnd = (RecipeRangeEnd)rangeStart.End;
                }
            }

            if (semanticRangestart != null && semanticRangeEnd != null)
            {
                DocumentPosition startPosition = new DocumentPosition(document);
                startPosition.MoveToInline((InlineLayoutBox)semanticRangestart.FirstLayoutBox, 0);

                DocumentPosition endPosition = new DocumentPosition(document);
                endPosition.MoveToInline((InlineLayoutBox)semanticRangeEnd.FirstLayoutBox, 0);

                DocumentSelection selection = new DocumentSelection(document);
                selection.SetSelectionStart(startPosition);
                selection.AddSelectionEnd(endPosition);

                DocumentFragment fragment = new DocumentFragment(selection);
                RadDocument fragmentDocument = fragment.ToDocument();

                HtmlFormatProvider htmlFormatProvider = new HtmlFormatProvider();
                htmlFormatProvider.ExportSettings = new HtmlExportSettings();
                htmlFormatProvider.ExportSettings.DocumentExportLevel = DocumentExportLevel.Fragment;
                htmlFormatProvider.ExportSettings.StylesExportMode = StylesExportMode.Inline;
                htmlFormatProvider.ExportSettings.StyleRepositoryExportMode = StyleRepositoryExportMode.DontExportStyles;

                return htmlFormatProvider.Export(fragmentDocument);
            }

            return string.Empty;
        }
Beispiel #29
-1
        public static void SaveDocument(RadFlowDocument document, string selectedFormat)
        {
            HtmlFormatProvider formatProvider = new HtmlFormatProvider();

            SaveFileDialog dialog = new SaveFileDialog();
            dialog.Filter = String.Format("{0} files|*{1}|All files (*.*)|*.*",
                selectedFormat,
                formatProvider.SupportedExtensions.First());
            dialog.FilterIndex = 1;

            if (dialog.ShowDialog() == true)
            {
                using (var stream = dialog.OpenFile())
                {
                    formatProvider.Export(document, stream);
                }
            }
        }