Fixed layout rendering

This commit is contained in:
Marcin Ziąbek
2021-09-13 00:55:21 +02:00
parent 070b6a20bd
commit 6c4da7285a
2 changed files with 18 additions and 5 deletions
+11 -3
View File
@@ -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.");
}
}
}
}
+7 -2
View File
@@ -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);
}