diff --git a/QuestPDF/Drawing/DocumentGenerator.cs b/QuestPDF/Drawing/DocumentGenerator.cs index bf14df2..49067b9 100644 --- a/QuestPDF/Drawing/DocumentGenerator.cs +++ b/QuestPDF/Drawing/DocumentGenerator.cs @@ -55,8 +55,11 @@ namespace QuestPDF.Drawing pageContext.SetPageNumber(currentPage); var spacePlan = content.Measure(Size.Max) as Size; - if (spacePlan == null) - break; + if (spacePlan == null) + { + canvas.EndDocument(); + ThrowLayoutException(); + } try { @@ -74,7 +77,7 @@ namespace QuestPDF.Drawing if (currentPage >= documentMetadata.DocumentLayoutExceptionThreshold) { canvas.EndDocument(); - throw new DocumentLayoutException("Composed layout generates infinite document."); + ThrowLayoutException(); } if (spacePlan is FullRender) @@ -84,6 +87,11 @@ namespace QuestPDF.Drawing } canvas.EndDocument(); + + void ThrowLayoutException() + { + throw new DocumentLayoutException("Composed layout generates infinite document."); + } } } } \ No newline at end of file diff --git a/QuestPDF/Fluent/TextExtensions.cs b/QuestPDF/Fluent/TextExtensions.cs index 3c076f9..c4eff42 100644 --- a/QuestPDF/Fluent/TextExtensions.cs +++ b/QuestPDF/Fluent/TextExtensions.cs @@ -53,7 +53,7 @@ namespace QuestPDF.Fluent style ??= DefaultStyle; var items = text - .Split(new[] { Environment.NewLine }, StringSplitOptions.None) + .Split(new[] { '\n' }, StringSplitOptions.None) .Select(x => new TextBlockSpan { Text = x, @@ -73,7 +73,12 @@ namespace QuestPDF.Fluent .ForEach(TextBlocks.Add); } - public void NewLine() + public void Line(string text) + { + Span(Environment.NewLine + text); + } + + public void EmptyLine() { Span(Environment.NewLine); }