Browse Source

DocumentationExamples: added custom spacing examples for Row and Column

Marcin Ziąbek 10 months ago
parent
commit
8419a8033e

+ 35 - 11
Source/QuestPDF.DocumentationExamples/ColumnExamples.cs

@@ -14,13 +14,11 @@ public class ColumnExamples
             {
                 document.Page(page =>
                 {
-                    page.MinSize(new PageSize(0, 0));
-                    page.MaxSize(new PageSize(1000, 1000));
-                    page.DefaultTextStyle(x => x.FontSize(20));
+                    page.MinSize(new PageSize(250, 0));
+                    page.MaxSize(new PageSize(250, 1000));
+                    page.Margin(25);
                     
                     page.Content()
-                        .Width(250)
-                        .Padding(25)
                         .Column(column =>
                         {
                             column.Item().Background(Colors.Grey.Medium).Height(50);
@@ -33,20 +31,18 @@ public class ColumnExamples
     }
     
     [Test]
-    public void ManyExample()
+    public void SpacingExample()
     {
         Document
             .Create(document =>
             {
                 document.Page(page =>
                 {
-                    page.MinSize(new PageSize(0, 0));
-                    page.MaxSize(new PageSize(1000, 1000));
-                    page.DefaultTextStyle(x => x.FontSize(20));
+                    page.MinSize(new PageSize(250, 0));
+                    page.MaxSize(new PageSize(250, 1000));
+                    page.Margin(25);
                     
                     page.Content()
-                        .Width(250)
-                        .Padding(25)
                         .Column(column =>
                         {
                             column.Spacing(25);
@@ -59,4 +55,32 @@ public class ColumnExamples
             })
             .GenerateImages(x => "column-spacing.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
     }
+    
+    [Test]
+    public void CustomSpacingExample()
+    {
+        Document
+            .Create(document =>
+            {
+                document.Page(page =>
+                {
+                    page.MinSize(new PageSize(250, 0));
+                    page.MaxSize(new PageSize(250, 1000));
+                    page.Margin(25);
+
+                    page.Content()
+                        .Column(column =>
+                        {
+                            column.Item().Background(Colors.Grey.Darken1).Height(50);
+                            column.Item().Height(10);
+                            column.Item().Background(Colors.Grey.Medium).Height(50);
+                            column.Item().Height(20);
+                            column.Item().Background(Colors.Grey.Lighten1).Height(50);
+                            column.Item().Height(30);
+                            column.Item().Background(Colors.Grey.Lighten2).Height(50);
+                        });
+                });
+            })
+            .GenerateImages(x => "column-spacing-custom.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
+    }
 }

+ 24 - 21
Source/QuestPDF.DocumentationExamples/RowExamples.cs

@@ -16,7 +16,7 @@ public class RowExamples
                 {
                     page.MinSize(new PageSize(0, 0));
                     page.MaxSize(new PageSize(1000, 1000));
-                    page.DefaultTextStyle(x => x.FontSize(20));
+                    page.Margin(25);
 
                     page.Content()
                         .Padding(25)
@@ -44,57 +44,60 @@ public class RowExamples
     }
     
     [Test]
-    public void AutoItem()
+    public void SpacingExample()
     {
-        // TODO: improve and update documentation
-        
         Document
             .Create(document =>
             {
                 document.Page(page =>
                 {
                     page.MinSize(new PageSize(0, 0));
-                    page.MaxSize(new PageSize(500, 300));
-                    page.DefaultTextStyle(x => x.FontSize(20));
+                    page.MaxSize(new PageSize(1000, 1000));
+                    page.Margin(25);
 
                     page.Content()
                         .Padding(25)
+                        .Width(220)
+                        .Height(50)
                         .Row(row =>
                         {
-                            row.AutoItem().Text("Auto column");
-                            row.RelativeItem().Text(Placeholders.LoremIpsum());
+                            row.Spacing(10);
+        
+                            row.RelativeItem(2).Background(Colors.Grey.Medium);
+                            row.RelativeItem(3).Background(Colors.Grey.Lighten1);
+                            row.RelativeItem(5).Background(Colors.Grey.Lighten2);
                         });
                 });
             })
-            .GeneratePdf();
+            .GenerateImages(x => "row-spacing.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
     }
     
     [Test]
-    public void SpacingExample()
+    public void CustomSpacingExample()
     {
         Document
             .Create(document =>
             {
                 document.Page(page =>
                 {
-                    page.MinSize(new PageSize(0, 0));
-                    page.MaxSize(new PageSize(1000, 1000));
-                    page.DefaultTextStyle(x => x.FontSize(20));
+                    page.MinSize(new PageSize(250, 0));
+                    page.MaxSize(new PageSize(250, 1000));
+                    page.Margin(25);
 
                     page.Content()
-                        .Padding(25)
-                        .Width(220)
                         .Height(50)
                         .Row(row =>
                         {
-                            row.Spacing(10);
-        
-                            row.RelativeItem(2).Background(Colors.Grey.Medium);
-                            row.RelativeItem(3).Background(Colors.Grey.Lighten1);
-                            row.RelativeItem(5).Background(Colors.Grey.Lighten2);
+                            row.RelativeItem().Background(Colors.Grey.Darken1);
+                            row.ConstantItem(10);
+                            row.RelativeItem().Background(Colors.Grey.Medium);
+                            row.ConstantItem(20);
+                            row.RelativeItem().Background(Colors.Grey.Lighten1);
+                            row.ConstantItem(30);
+                            row.RelativeItem().Background(Colors.Grey.Lighten2);
                         });
                 });
             })
-            .GenerateImages(x => "row-spacing.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
+            .GenerateImages(x => "row-spacing-custom.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
     }
 }