public static string ToHtmlParagraphs(this TextGeometryModel model, string imageFileName = null) { var result = new StringBuilder(100000); result.Append(HTMLDebugHeader).Append("\n"); if (imageFileName != null) { result.Append(string.Format(HTMLDebugImageBoxTemplate, model.PageBox.Width, model.PageBox.Height, imageFileName)); } foreach (var textBlock in model.AllTextBlocks()) { var bbox = textBlock.BoundingBox; result.Append(string.Format(HTMLDebugTextBoxTemplate, bbox.XMin, bbox.YMin, bbox.Width, bbox.Height)); foreach (var paragraph in textBlock.Paragraphs()) { bbox = paragraph.BoundingBox; var text = paragraph.AsText(true); result.Append(string.Format(HTMLDebugParagraphBoxWithTextTemplate, bbox.XMin, bbox.YMin, bbox.Width, bbox.Height, text, "")); } } result.Append(HTMLDebugFooter).Append("\n"); return(result.ToString()); }
/// <summary> /// Returns all lines of text in given model /// </summary> /// <param name="model"></param> /// <returns></returns> public static IEnumerable <GMLine> Lines(this TextGeometryModel model) { return(model.AllTextBlocks().SelectMany(textBlock => textBlock.Paragraphs()).SelectMany(para => para.Lines())); }