From 2c11491d4e8ef6b6de30f2f93af36b3d59d5ec25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zi=C4=85bek?= Date: Tue, 14 Sep 2021 02:02:45 +0200 Subject: [PATCH] Library update --- QuestPDF.Examples/QuestPDF.Examples.csproj | 2 +- QuestPDF.Examples/TextExamples.cs | 35 +++++++++++++++++-- .../QuestPDF.ReportSample.csproj | 2 +- QuestPDF.UnitTests/QuestPDF.UnitTests.csproj | 2 +- .../Elements/Text/Calculation/TextLine.cs | 12 +++++-- QuestPDF/Fluent/TextExtensions.cs | 2 +- QuestPDF/QuestPDF.csproj | 2 +- 7 files changed, 48 insertions(+), 9 deletions(-) diff --git a/QuestPDF.Examples/QuestPDF.Examples.csproj b/QuestPDF.Examples/QuestPDF.Examples.csproj index 020a696..cfc382a 100644 --- a/QuestPDF.Examples/QuestPDF.Examples.csproj +++ b/QuestPDF.Examples/QuestPDF.Examples.csproj @@ -9,7 +9,7 @@ - + diff --git a/QuestPDF.Examples/TextExamples.cs b/QuestPDF.Examples/TextExamples.cs index 8e80216..e3d78b8 100644 --- a/QuestPDF.Examples/TextExamples.cs +++ b/QuestPDF.Examples/TextExamples.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Text; using NUnit.Framework; using QuestPDF.Examples.Engine; using QuestPDF.Fluent; @@ -34,9 +35,39 @@ namespace QuestPDF.Examples text.AlignLeft(); text.ParagraphSpacing(10); - text.Span(Placeholders.LoremIpsum()); + text.Line(Placeholders.LoremIpsum()); - text.Line($"This is target text that does not show up. {DateTime.UtcNow:T} > This is a short sentence that will be wrapped into second line hopefully, right? <"); + text.Span($"This is target text that does not show up. {DateTime.UtcNow:T} > This is a short sentence that will be wrapped into second line hopefully, right? <", TextStyle.Default.Underlined()); + }); + }); + } + + [Test] + public void TextStack() + { + RenderingTest + .Create() + .PageSize(PageSizes.A4) + .FileName() + .ProducePdf() + .ShowResults() + .Render(container => + { + container + .Padding(20) + .Padding(10) + .Box() + .Border(1) + .Padding(5) + .Padding(10) + .Text(text => + { + text.DefaultTextStyle(TextStyle.Default); + text.AlignLeft(); + text.ParagraphSpacing(10); + + foreach (var i in Enumerable.Range(1, 100)) + text.Line($"{i}: {Placeholders.Paragraph()}"); }); }); } diff --git a/QuestPDF.ReportSample/QuestPDF.ReportSample.csproj b/QuestPDF.ReportSample/QuestPDF.ReportSample.csproj index 3c49859..d0cbe3e 100644 --- a/QuestPDF.ReportSample/QuestPDF.ReportSample.csproj +++ b/QuestPDF.ReportSample/QuestPDF.ReportSample.csproj @@ -12,7 +12,7 @@ - + diff --git a/QuestPDF.UnitTests/QuestPDF.UnitTests.csproj b/QuestPDF.UnitTests/QuestPDF.UnitTests.csproj index 213f6f3..d9dc74a 100644 --- a/QuestPDF.UnitTests/QuestPDF.UnitTests.csproj +++ b/QuestPDF.UnitTests/QuestPDF.UnitTests.csproj @@ -11,7 +11,7 @@ - + diff --git a/QuestPDF/Elements/Text/Calculation/TextLine.cs b/QuestPDF/Elements/Text/Calculation/TextLine.cs index 518a7a6..a4a3eb6 100644 --- a/QuestPDF/Elements/Text/Calculation/TextLine.cs +++ b/QuestPDF/Elements/Text/Calculation/TextLine.cs @@ -15,10 +15,18 @@ namespace QuestPDF.Elements.Text.Calculation public float Ascent { get; private set; } public float Descent { get; private set; } - public float Width { get; private set; } - + public float Width { get; private set; } + public static TextLine From(ICollection elements) { + if (elements.Count == 0) + { + return new TextLine + { + Elements = elements + }; + } + var textHeight = elements.Max(x => x.Measurement.Height); var lineHeight = elements.Max(x => x.Measurement.LineHeight * x.Measurement.Height); diff --git a/QuestPDF/Fluent/TextExtensions.cs b/QuestPDF/Fluent/TextExtensions.cs index b9b5b0d..16bc59f 100644 --- a/QuestPDF/Fluent/TextExtensions.cs +++ b/QuestPDF/Fluent/TextExtensions.cs @@ -77,7 +77,7 @@ namespace QuestPDF.Fluent public void Line(string text) { - Span(Environment.NewLine + text); + Span(text + Environment.NewLine); } public void EmptyLine() diff --git a/QuestPDF/QuestPDF.csproj b/QuestPDF/QuestPDF.csproj index 607be80..6722dc4 100644 --- a/QuestPDF/QuestPDF.csproj +++ b/QuestPDF/QuestPDF.csproj @@ -22,7 +22,7 @@ - +