Browse Source

Added more examples for expected behaviors

Marcin Ziąbek 2 years ago
parent
commit
99fefc7fe7

+ 83 - 0
Source/QuestPDF.Examples/ElementExamples.cs

@@ -843,5 +843,88 @@ namespace QuestPDF.Examples
                         });
                         });
                 });
                 });
         }
         }
+        
+        [Test]
+        public void DividingPageIntoPartsOfEqualSize()
+        {
+            RenderingTest
+                .Create()
+                .ProduceImages()
+                .ShowResults()
+                .PageSize(PageSizes.A4)
+                .Render(container =>
+                {
+                    var labelsVertically = 9;
+                    var labelsHorizontally = 3;
+
+                    container
+                        .Padding(25)
+                        .RotateRight()
+                        .Row(verticalRow =>
+                        {
+                            foreach (var y in Enumerable.Range(1, labelsVertically))
+                            {
+                                verticalRow.RelativeItem().RotateLeft().Row(horizontalRow =>
+                                {
+                                    foreach (var x in Enumerable.Range(1, labelsHorizontally))
+                                    {
+                                        horizontalRow.RelativeItem()
+                                            .Border(1)
+                                            .Background(Placeholders.BackgroundColor())
+                                            .AlignCenter()
+                                            .AlignMiddle()
+                                            .Text($"{x} x {y}")
+                                            .FontSize(20);
+                                    }
+                                });
+                            }
+                        });
+                });
+        }
+        
+        [Test]
+        public void DividingPageIntoPartsOfExpectedSize()
+        {
+            RenderingTest
+                .Create()
+                .ProduceImages()
+                .ShowResults()
+                .PageSize(PageSizes.A4)
+                .Render(container =>
+                {
+                    var labelsVertically = 9;
+                    var labelsHorizontally = 3;
+
+                    var labelWidth = 150;
+                    var labelHeight = 100;
+
+                    container
+                        .Padding(25)
+                        .Table(table =>
+                        {
+                            table.ColumnsDefinition(columns =>
+                            {
+                                foreach (var i in Enumerable.Range(0, labelsHorizontally))
+                                    columns.ConstantColumn(labelWidth);
+                            });
+                            
+                            foreach (var y in Enumerable.Range(1, labelsVertically))
+                            {
+                                foreach (var x in Enumerable.Range(1, labelsHorizontally))
+                                {
+                                    table.Cell()
+                                        .Width(labelWidth)
+                                        .Height(labelHeight)
+                                        .Border(1)
+                                        .Background(Placeholders.BackgroundColor())
+                                        .AlignCenter()
+                                        .AlignMiddle()
+                                        .Text($"{x} x {y}")
+                                        .FontSize(20);
+                                }
+                            }
+                        });
+                });
+        }
     }
     }
 }
 }

+ 23 - 0
Source/QuestPDF.Examples/TextExamples.cs

@@ -1039,5 +1039,28 @@ namespace QuestPDF.Examples
                     });
                     });
                 });
                 });
         }
         }
+         
+         [Test]
+         public void TextShouldInheritAlignment()
+         {
+             RenderingTest
+                 .Create()
+                 .ProduceImages()
+                 .ShowResults()
+                 .PageSize(PageSizes.A4)
+                 .Render(container =>
+                 {
+                     var text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
+                     
+                     container.Padding(20).Width(400).Column(column =>
+                     {
+                         column.Spacing(20);
+
+                         column.Item().Background(Colors.Grey.Lighten3).AlignLeft().Text(text);
+                         column.Item().Background(Colors.Grey.Lighten3).AlignCenter().Text(text);
+                         column.Item().Background(Colors.Grey.Lighten3).AlignRight().Text(text);
+                     });
+                 });
+         }
     }
     }
 }
 }