Hello,
I have a problem using de TextParagraph/Textbuilder objects. If i’m adding two paragraphs i have a weird behaviour. If i add two paragraphs sometimes i get two sections with on paragraph on each, sometimes i get 1 section, 1 paragraph, 1 line with the 2 words in the resulting PDF.
Why when i add a paragraph it does not simply add a paragraph ? There is some kind of intelligence that i don’t understand.
Here the code :
public void BugAspose() { var docPdf = new Document(); var pdfPage = docPdf.Pages.Add(); var paragraph1 = new TextParagraph(); var line1 = new TextFragment(); var textFragment = new TextFragment("Lorem"); textFragment.TextState.Invisible = true; textFragment.Rectangle.LLX = 0; textFragment.Rectangle.LLY = 0; textFragment.Rectangle.URX = 34; textFragment.Rectangle.URY = 12; foreach (var segment in textFragment.Segments) { line1.Segments.Add(segment); } paragraph1.AppendLine(line1); new TextBuilder(pdfPage).AppendParagraph(paragraph1); var paragraph2 = new TextParagraph(); var line2 = new TextFragment(); var textFragment2 = new TextFragment("Ipsum"); textFragment2.TextState.Invisible = true; textFragment2.Rectangle.LLX = 0; textFragment2.Rectangle.LLY = 50; textFragment2.Rectangle.URX = 34; textFragment2.Rectangle.URY = 62; foreach (var segment in textFragment2.Segments) { line2.Segments.Add(segment); } paragraph2.AppendLine(line2); new TextBuilder(pdfPage).AppendParagraph(paragraph2); ParagraphAbsorber pdfMarkup = new ParagraphAbsorber(); pdfMarkup.Visit(pdfPage); var paragraphs = pdfMarkup.PageMarkups.First().Sections.SelectMany(s => s.Paragraphs).ToArray(); Assert.Equal(2, paragraphs.Count()); }