Browse Source

Added more examples

MarcinZiabek 3 years ago
parent
commit
b47a8ac409

+ 10 - 2
QuestPDF.Examples/DynamicFibonacci.cs

@@ -75,12 +75,13 @@ namespace QuestPDF.Examples
                 .Create()
                 .Create()
                 .ShowResults()
                 .ShowResults()
                 .MaxPages(100)
                 .MaxPages(100)
-                .ProducePdf()
+                .ProduceImages()
                 .RenderDocument(container =>
                 .RenderDocument(container =>
                 {
                 {
                     container.Page(page =>
                     container.Page(page =>
                     {
                     {
                         page.Size(PageSizes.A6);
                         page.Size(PageSizes.A6);
+                        page.PageColor(Colors.White);
                         page.Margin(1, Unit.Centimetre);
                         page.Margin(1, Unit.Centimetre);
                         page.DefaultTextStyle(x => x.FontSize(18));
                         page.DefaultTextStyle(x => x.FontSize(18));
 
 
@@ -88,9 +89,16 @@ namespace QuestPDF.Examples
                         
                         
                         page.Content().Column(column =>
                         page.Content().Column(column =>
                         {
                         {
-                            foreach (var i in Enumerable.Range(0, 100))
+                            foreach (var i in Enumerable.Range(0, 50))
                                 column.Item().PaddingTop(25).Background(Colors.Grey.Lighten2).Height(50);
                                 column.Item().PaddingTop(25).Background(Colors.Grey.Lighten2).Height(50);
                         });
                         });
+                        
+                        page.Footer().AlignCenter().Text(text =>
+                        {
+                            text.CurrentPageNumber();
+                            text.Span(" / ");
+                            text.TotalPages();
+                        });
                     });
                     });
                 });
                 });
         }
         }

+ 11 - 1
QuestPDF.Examples/DynamicProgressHeader.cs

@@ -43,13 +43,14 @@ namespace QuestPDF.Examples
                 .Create()
                 .Create()
                 .ShowResults()
                 .ShowResults()
                 .MaxPages(100)
                 .MaxPages(100)
-                .ProducePdf()
+                .ProduceImages()
                 .RenderDocument(container =>
                 .RenderDocument(container =>
                 {
                 {
                     container.Page(page =>
                     container.Page(page =>
                     {
                     {
                         page.Size(PageSizes.A6);
                         page.Size(PageSizes.A6);
                         page.Margin(1, Unit.Centimetre);
                         page.Margin(1, Unit.Centimetre);
+                        page.PageColor(Colors.White);
                         page.DefaultTextStyle(x => x.FontSize(20));
                         page.DefaultTextStyle(x => x.FontSize(20));
 
 
                         page.Header().Dynamic(new ProgressHeader());
                         page.Header().Dynamic(new ProgressHeader());
@@ -59,6 +60,15 @@ namespace QuestPDF.Examples
                             foreach (var i in Enumerable.Range(0, 100))
                             foreach (var i in Enumerable.Range(0, 100))
                                 column.Item().PaddingTop(25).Background(Colors.Grey.Lighten2).Height(50);
                                 column.Item().PaddingTop(25).Background(Colors.Grey.Lighten2).Height(50);
                         });
                         });
+
+                        page.Footer().AlignCenter().Text(text =>
+                        {
+                            text.DefaultTextStyle(x => x.FontSize(20));
+                            
+                            text.CurrentPageNumber();
+                            text.Span(" / ");
+                            text.TotalPages();
+                        });
                     });
                     });
                 });
                 });
         }
         }

+ 6 - 3
QuestPDF.Examples/DynamicSimpleTableExample.cs

@@ -88,7 +88,8 @@ namespace QuestPDF.Examples
                             footer
                             footer
                                 .Cell().ColumnSpan(5)
                                 .Cell().ColumnSpan(5)
                                 .AlignRight()
                                 .AlignRight()
-                                .Text($"Subtotal: {total}$", TextStyle.Default.Size(14).SemiBold());
+                                .PaddingTop(10)
+                                .Text($"Subtotal: {total}$", TextStyle.Default.Bold());
                         });
                         });
                         
                         
                         foreach (var index in Enumerable.Range(State.ShownItemsCount, itemsToDisplay))
                         foreach (var index in Enumerable.Range(State.ShownItemsCount, itemsToDisplay))
@@ -123,13 +124,15 @@ namespace QuestPDF.Examples
                 .Create()
                 .Create()
                 .PageSize(PageSizes.A5)
                 .PageSize(PageSizes.A5)
                 .ShowResults()
                 .ShowResults()
+                .ProduceImages()
                 .Render(container =>
                 .Render(container =>
                 {
                 {
-                    var items = Enumerable.Range(0, 25).Select(x => new OrderItem()).ToList();
+                    var items = Enumerable.Range(0, 15).Select(x => new OrderItem()).ToList();
                     
                     
                     container
                     container
                         .Background(Colors.White)
                         .Background(Colors.White)
                         .Padding(25)
                         .Padding(25)
+                        .DefaultTextStyle(x => x.FontSize(16))
                         .Decoration(decoration =>
                         .Decoration(decoration =>
                         {
                         {
                             decoration
                             decoration
@@ -137,7 +140,7 @@ namespace QuestPDF.Examples
                                 .PaddingBottom(5)
                                 .PaddingBottom(5)
                                 .Text(text =>
                                 .Text(text =>
                                 {
                                 {
-                                    text.DefaultTextStyle(TextStyle.Default.SemiBold().FontColor(Colors.Blue.Darken2).FontSize(16));
+                                    text.DefaultTextStyle(TextStyle.Default.SemiBold().FontColor(Colors.Blue.Darken2));
                                     text.Span("Page ");
                                     text.Span("Page ");
                                     text.CurrentPageNumber();
                                     text.CurrentPageNumber();
                                     text.Span(" / ");
                                     text.Span(" / ");

+ 88 - 31
QuestPDF.Examples/TextExamples.cs

@@ -38,48 +38,105 @@ namespace QuestPDF.Examples
         }
         }
 
 
         [Test]
         [Test]
-        public void SuperscriptSubscript_General()
+        public void TextWeight()
         {
         {
             RenderingTest
             RenderingTest
-               .Create()
-               .PageSize(500, 500)
-               .ProduceImages()
-               .ShowResults()
-               .Render(container =>
-               {
-                   container
-                        .Padding(5)
+                .Create()
+                .PageSize(500, 500)
+                .ProduceImages()
+                .ShowResults()
+                .Render(container =>
+                {
+                    container
+                        .Padding(20)
                         .MinimalBox()
                         .MinimalBox()
                         .Border(1)
                         .Border(1)
-                        .Padding(10)
+                        .Padding(20)
+                        .Text(text =>
+                        {
+                            text.DefaultTextStyle(x => x.FontFamily(Fonts.Calibri).FontSize(20));
+
+                            text.Line("Thin").Thin();
+                            text.Line("ExtraLight").ExtraLight();
+                            text.Line("Light").Light();
+                            text.Line("NormalWeight").NormalWeight();
+                            text.Line("Medium").Medium();
+                            text.Line("SemiBold").SemiBold();
+                            text.Line("Bold").Bold();
+                            text.Line("ExtraBold").ExtraBold();
+                            text.Line("Black").Black();
+                            text.Line("ExtraBlack").ExtraBlack();
+                        });
+                });
+        }
+        
+        [Test]
+        public void LineHeight()
+        {
+            RenderingTest
+                .Create()
+                .PageSize(500, 700)
+                .ProduceImages()
+                .ShowResults()
+                .Render(container =>
+                {
+                    container
+                        .Padding(20)
+                        .Column(column =>
+                        {
+                            var lineHeights = new[] { 0.8f, 1f, 1.5f };
+                            var paragraph = Placeholders.Paragraph();
+
+                            foreach (var lineHeight in lineHeights)
+                            {
+                                column
+                                    .Item()
+                                    .Border(1)
+                                    .Padding(10)
+                                    .Text(paragraph)
+                                    .FontSize(16)
+                                    .LineHeight(lineHeight);
+                            }
+                        });
+                });
+        }
+        
+        [Test]
+        public void SuperscriptSubscript_Simple()
+        {
+            RenderingTest
+                .Create()
+                .PageSize(500, 500)
+                .ProduceImages()
+                .ShowResults()
+                .Render(container =>
+                {
+                    container
+                        .Padding(20)
+                        .MinimalBox()
+                        .Border(1)
+                        .Padding(20)
                         .Text(text =>
                         .Text(text =>
                         {
                         {
                             text.DefaultTextStyle(x => x.FontSize(20));
                             text.DefaultTextStyle(x => x.FontSize(20));
-                            text.ParagraphSpacing(2);
-                            
-                            
-                            text.Span("In physics, mass–energy equivalence is the relationship between mass and energy in a system's rest frame, where the two values differ only by a constant and the units of measurement.");
-                            text.Span("[1][2]").Superscript();
-                            text.Span(" The principle is described by the physicist Albert Einstein's famous formula: E = mc");
-                            text.Span("2").Superscript();
-                            text.Span(". ");
-                            text.Span("[3]").Superscript();
-                            
-                            text.EmptyLine();
-                            
-                            text.Span("H");
-                            text.Span("2").Subscript();
-                            text.Span("O is the chemical formula for water, meaning that each of its molecules contains one oxygen and two hydrogen atoms.");
+                            text.ParagraphSpacing(10);
 
 
-                            text.EmptyLine();
+                            var highlight = TextStyle.Default.BackgroundColor(Colors.Green.Lighten3);
+
+                            text.Span("E=mc").Style(highlight);
+                            text.Span("2").Superscript().Style(highlight);
+                            text.Span(" is the equation of mass–energy equivalence.");
 
 
-                            text.Span("H");
-                            text.Span("2").Subscript();
-                            text.Span("O");
+                            text.EmptyLine();
+                            
+                            text.Span("H").Style(highlight);
+                            text.Span("2").Subscript().Style(highlight);
+                            text.Span("O").Style(highlight);
+                            text.Span(" is the chemical formula for water.");
                         });
                         });
-               });
+                });
         }
         }
-        
+
         [Test]
         [Test]
         public void SuperscriptSubscript_Effects()
         public void SuperscriptSubscript_Effects()
         {
         {