diff --git a/QuestPDF.Examples/TextExamples.cs b/QuestPDF.Examples/TextExamples.cs index d306188..029915f 100644 --- a/QuestPDF.Examples/TextExamples.cs +++ b/QuestPDF.Examples/TextExamples.cs @@ -89,9 +89,34 @@ namespace QuestPDF.Examples }); } - T MyFunc(T arg) + [Test] + public void PageNumber() { - return arg; + RenderingTest + .Create() + .PageSize(500, 400) + .FileName() + .ProduceImages() + .ShowResults() + .Render(container => + { + container + .Padding(10) + .Box() + .Border(1) + .Padding(10) + .Text(text => + { + text.DefaultTextStyle(TextStyle.Default); + text.AlignLeft(); + text.ParagraphSpacing(10); + + text.Span("This is page number "); + text.CurrentPageNumber(); + text.Span(" out of "); + text.TotalPages(); + }); + }); } } } \ No newline at end of file diff --git a/QuestPDF/Elements/Text/Items/TextBlockSpan.cs b/QuestPDF/Elements/Text/Items/TextBlockSpan.cs index 7396ea2..289279f 100644 --- a/QuestPDF/Elements/Text/Items/TextBlockSpan.cs +++ b/QuestPDF/Elements/Text/Items/TextBlockSpan.cs @@ -32,10 +32,13 @@ namespace QuestPDF.Elements.Text.Items var fontMetrics = Style.ToFontMetrics(); var startIndex = request.StartIndex; - - while (startIndex + 1 < Text.Length && Text[startIndex] == space) - startIndex++; - + + if (request.IsFirstLineElement) + { + while (startIndex + 1 < Text.Length && Text[startIndex] == space) + startIndex++; + } + if (Text.Length == 0) { return new TextMeasurementResult