public virtual void AddLine(PdfPageDetails page, Dictionary <PdfFontDetails, int> fontRef, PdfTextLineDetails line, StringBuilder sb) { sb.Append($@" <div class=""line"" style=""") .Append("right:").Append((int)line.Right) .Append("px;left:").Append((int)line.Left) .Append("px;top:").Append((int)(line.Top)) .Append("px;width:").Append((int)(line.Width)) .Append("px;bottom:").Append((int)(page.Height - line.Bottom)) .Append("px\" >"); PdfLinkResult link = null; foreach (var text in line.Texts) { if (text.LinkParent != null) { if (text.LinkParent != link) { AddLink(link = text.LinkParent, fontRef, sb); } continue; } AddText(text, fontRef, sb); } sb.Append(@"</div>"); }
protected virtual void AddLink(PdfLinkResult link, Dictionary <PdfFontDetails, int> fontRef, StringBuilder sb) { sb.Append($@"<a href=""").Append(link.Link).Append("\">"); foreach (var text in link.Children) { AddText(text, fontRef, sb); } sb.Append(@"</a>"); }
private IList <PdfTextResult> MergeTextInLine() { var result = new LinkedList <PdfTextResult> { }; LinkedListNode <PdfTextResult> firstNode = null; PdfTextBlock lastBlock = null; PdfTextResult text = null; PdfLinkResult link = null; for (var index = 0; index < blocks.Count; index++) { var current = blocks[index]; bool currentRTL = RightToLeftManager.Instance.AssignNeutral(pageContext.PageRTL, current, blocks, index); bool opositeDirection = pageContext.PageRTL != currentRTL; // bool digitLtr = current.IsDigit && last?.IsDigit==true; if (lastBlock != null && Equals(lastBlock.StrokeColore, current.StrokeColore) && lastBlock.FontSize == current.FontSize && lastBlock.Font == current.Font && lastBlock.Link == current.Link && lastBlock.IsRightToLeft == current.IsRightToLeft) { if (opositeDirection) //&&!digitLtr) { text.Value = current.Value + text.Value; } else { text.Value += current.Value; } } else { // var stateRtl = // RightToLeftManager.Instance.PageElemtRtl(pageRTL, currentRightToLeft); // && !digitLtr); SeperateRtlLtr(opositeDirection, pageContext.PageRTL, current, lastBlock, text); text = new PdfTextResult { FontSize = current.FontSize, Font = current.Font, StrokeColore = current.StrokeColore, Value = current.Value, }; pageContext.LinkManager.AssignLink(current, text, ref link); AddNewText(opositeDirection, result, text, ref firstNode); } lastBlock = current; } return(result.ToArray()); }
public void AssignLink(PdfTextBlock current, PdfTextResult text, ref PdfLinkResult link) { if (current.Link != null) { if (!string.Equals(link?.Link, current.Link)) { if (link != null && Log.DebugSupported) { Log.Debug("link:" + link); } link = new PdfLinkResult { Link = current.Link }; } link.Children.Add(text); text.LinkParent = link; } }