protected override void Dispose(bool disposing) { base.Dispose(disposing); if (_htmlConversionHelper != null) { ((IDisposable)_htmlConversionHelper).Dispose(); _htmlConversionHelper = null; } }
/// <summary> /// Stand-alone function to expand any placeholders inside /// a given HTML fragment. /// </summary> public static string ExpandImageFolderPathPlaceHolder( string html, string externalImagesFolderPath) { if (string.IsNullOrEmpty(html) || !html.Contains(ImagesFolderPathPlaceHolder)) { return html; } else { using (var ch = new HtmlConversionHelper()) { return ch.ConvertSetHtml( html, externalImagesFolderPath, ImagesFolderPathPlaceHolder); } } }
/// <summary> /// Stand-alone function to expand any placeholders inside /// a given HTML fragment. /// </summary> public static string ExpandImageFolderPathPlaceHolder( string html, string externalImagesFolderPath) { if (string.IsNullOrEmpty(html) || !html.Contains(ImagesFolderPathPlaceHolder)) { return(html); } else { using (var ch = new HtmlConversionHelper()) { return(ch.ConvertSetHtml( html, externalImagesFolderPath, ImagesFolderPathPlaceHolder)); } } }
private void TestForm_Load(object sender, EventArgs e) { // WebBrowserHelper.SafeSwitchToHighestInternetExplorerVersionAsync(); const string html = @"<P>Mit Bild:</P> <P><IMG src=""http://pseudo-image-folder-path/d0906191-5a75-4568-97d4-924ee727426d""></P> <P>Yes!</P>" ; var images = HtmlConversionHelper.GetContainedImageFileNames(html); foreach (var image in images) { Console.WriteLine(image); } htmlEditUserControl1.HtmlEditControl.WantCloseDialogWithOK += delegate { MessageBox.Show("Close."); }; }
private static string checkImages( ICollection <HtmlConversionHelper.ImageInfo> originalNames, string html, string url) { if (originalNames != null && originalNames.Count > 0) { // ReSharper disable once LoopCanBeConvertedToQuery foreach (var s in originalNames) { if (!s.Source.StartsWith(@"http") && !s.Source.StartsWith(@"https")) { html = html.Replace( s.Source, HtmlConversionHelper.GetPathFromFile(s.Source, new Uri(url))); } } } return(html); }
private void constructCoreHtmlEditControlTextAndImage() { _htmlConversionHelper = new HtmlConversionHelper(); }
private void constructCoreHtmlEditControlTextAndImage() { _htmlConversionHelper = new HtmlConversionHelper(); TargetForLinks = @"_blank"; }
private void handlePaste( PasteMode pasteMode) { if (Document != null) { var doc = (HTMLDocument)Document.DomDocument; if (IsControlSelection) { doc.execCommand(@"Delete", false, null); } string html; if (Clipboard.ContainsImage() && // 2014-08-19, Uwe Keim: Excel hat HTML _und_ Bild, deshalb hier prüfen, sonst // wird Excel auch als Bild eingefügt. !Clipboard.ContainsText(TextDataFormat.Html)) { var image = Clipboard.GetImage(); var file = Path.Combine(_tmpFolderPath, _objectID.ToString(CultureInfo.InvariantCulture)); if (image != null) { image.Save(file, image.RawFormat); } _objectID++; if (Configuration.AllowEmbeddedImages) { var data = File.ReadAllBytes(file); var imageContent = Convert.ToBase64String(data, 0, data.Length); File.Delete(file); html = string.Format(@"<img src=""data:image;base64,{0}"" />", imageContent); } else { html = string.Format(@"<img src=""{0}"" id=""Img{1}"" />", file, DateTime.Now.Ticks); } } else { if (pasteMode != PasteMode.Text && Clipboard.ContainsText(TextDataFormat.Html)) { // only body from fragment html = HtmlClipboardHelper.GetHtmlFromClipboard().GetBodyFromHtmlCode().CheckCompleteHtmlTable(); // images save or load from web html = checkImages( HtmlConversionHelper.FindImgs(html), html, HtmlClipboardHelper.GetSourceUrlFromClipboard()); if (pasteMode == PasteMode.MsWord) { html = html.CleanMsWordHtml(); } } else if (Clipboard.ContainsText(TextDataFormat.UnicodeText)) { html = Clipboard.GetText(TextDataFormat.UnicodeText); if (pasteMode == PasteMode.Text) { html = html.GetOnlyTextFromHtmlCode(); } html = PathHelper.HtmlEncode(html); html = HtmlStringHelper.AddNewLineToText(html); } else if (Clipboard.ContainsText(TextDataFormat.Text)) { html = Clipboard.GetText(TextDataFormat.Text); if (pasteMode == PasteMode.Text) { html = html.GetOnlyTextFromHtmlCode(); } html = PathHelper.HtmlEncode(html); html = HtmlStringHelper.AddNewLineToText(html); } else { html = string.Empty; } } var selection = doc.selection; var range = (IHTMLTxtRange)selection.createRange(); range.pasteHTML(html); } }