浏览代码

Added missing option to style a line

Marcin Ziąbek 4 年之前
父节点
当前提交
17e2727833
共有 3 个文件被更改,包括 93 次插入2 次删除
  1. 86 0
      QuestPDF.Examples/TextExamples.cs
  2. 6 1
      QuestPDF/Fluent/TextExtensions.cs
  3. 1 1
      QuestPDF/QuestPDF.csproj

+ 86 - 0
QuestPDF.Examples/TextExamples.cs

@@ -11,6 +11,92 @@ namespace QuestPDF.Examples
 {
     public class TextExamples
     {
+        [Test]
+        public void SimpleTextBlock()
+        {
+            RenderingTest
+                .Create()
+                .PageSize(500, 300)
+                .FileName()
+                .ProduceImages()
+                .ShowResults()
+                .Render(container =>
+                {
+                    container
+                        .Padding(5)
+                        .Box()
+                        .Border(1)
+                        .Padding(10)
+                        .Text(text =>
+                        {
+                            text.DefaultTextStyle(TextStyle.Default.Size(20));
+                            text.Span("This is a normal text, followed by an ");
+                            text.Span("underlined red text.", TextStyle.Default.Size(20).Color(Colors.Red.Medium).Underline());
+                        });
+                });
+        }
+        
+        [Test]
+        public void ParagraphSpacing()
+        {
+            RenderingTest
+                .Create()
+                .PageSize(500, 300)
+                .FileName()
+                .ProduceImages()
+                .ShowResults()
+                .Render(container =>
+                {
+                    container
+                        .Padding(5)
+                        .Box()
+                        .Border(1)
+                        .Padding(10)
+                        .Text(text =>
+                        {
+                            text.ParagraphSpacing(10);
+    
+                            foreach (var i in Enumerable.Range(1, 3))
+                            {
+                                text.Span($"Paragraph {i}: ", TextStyle.Default.SemiBold());
+                                text.Line(Placeholders.Paragraph());
+                            }
+                        });
+                });
+        }
+        
+        [Test]
+        public void CustomElement()
+        {
+            RenderingTest
+                .Create()
+                .PageSize(500, 200)
+                .FileName()
+                .ProduceImages()
+                .ShowResults()
+                .Render(container =>
+                {
+                    container
+                        .Padding(5)
+                        .Box()
+                        .Border(1)
+                        .Padding(10)
+                        .Text(text =>
+                        {
+                            text.DefaultTextStyle(TextStyle.Default.Size(20));
+                            text.Span("This is a random image aligned to the baseline: ");
+                            
+                            text.Element()
+                                .PaddingBottom(-6)
+                                .Height(24)
+                                .Width(48)
+                                .Image(Placeholders.Image);
+                            
+                            text.Span(".");
+                        });
+                });
+        }
+        
         [Test]
         public void TextElements()
         {

+ 6 - 1
QuestPDF/Fluent/TextExtensions.cs

@@ -75,6 +75,11 @@ namespace QuestPDF.Fluent
                 .ForEach(TextBlocks.Add);
         }
 
+        public void Line(string text, TextStyle? style = null)
+        {
+            Span(text + Environment.NewLine, style);
+        }
+        
         public void Line(string text)
         {
             Span(text + Environment.NewLine);
@@ -144,7 +149,7 @@ namespace QuestPDF.Fluent
                 Element = container
             });
             
-            return container.Box();
+            return container.AlignBottom().Box();
         }
         
         internal void Compose(IContainer container)

+ 1 - 1
QuestPDF/QuestPDF.csproj

@@ -4,7 +4,7 @@
         <Authors>MarcinZiabek</Authors>
         <Company>CodeFlint</Company>
         <PackageId>QuestPDF</PackageId>
-        <Version>2021.10.0</Version>
+        <Version>2021.10.1</Version>
         <PackageDescription>QuestPDF is an open-source, modern and battle-tested library that can help you with generating PDF documents by offering friendly, discoverable and predictable C# fluent API.</PackageDescription>
         <PackageReleaseNotes>Enhanced text rendering capabilities. Improved rendering performance.</PackageReleaseNotes>
         <LangVersion>8</LangVersion>