public static List <IElement> ParseToList(string html) { MyHTMLWorker hTMLWorker = new MyHTMLWorker(null); hTMLWorker.document = hTMLWorker; hTMLWorker.objectList = new List <IElement>(); hTMLWorker.Parse(new StringReader(html)); return(hTMLWorker.objectList); }
private void AddContent(string html, Section section) { html = RegisterFonts(html); html = ValidateHtmlInput(html); //var elements = XMLWorkerHelper.ParseToElementList(html, ""); var elements = MyHTMLWorker.ParseToList(html); foreach (IElement element in elements) { if (element.IsContent()) { foreach (Chunk chunk in element.Chunks) { if (chunk.IsContent() && !chunk.IsEmpty() && (chunk.Attributes != null) && !chunk.Attributes.ContainsKey(Chunk.IMAGE)) { if (chunk.Font == null) { chunk.Font = CreateFont(m_BaseFontName, m_BaseFontSize); } else { string fontName = chunk.Font.Familyname; if (m_ApplyBaseFontToAllContent || (fontName == "unknown")) { fontName = m_BaseFontName; } chunk.Font = CreateFont(fontName, chunk.Font.Size, chunk.Font.Style, chunk.Font.Color); } //if (!chunk.Attributes.ContainsKey(Chunk.LINEHEIGHT)) { chunk.setLineHeight(chunk.Font.Size * 1.1f); } } } } section.Add(element); } }