From 04af33fc31bc0e6f2b6e7a8f8deb21501e9ca1ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zi=C4=85bek?= Date: Mon, 23 Aug 2021 23:51:42 +0200 Subject: [PATCH] Included examples for DSL and complex layouts --- QuestPDF.Examples/ElementExamples.cs | 78 ++++++++++++++++++++++++++++ QuestPDF.Examples/FrameExample.cs | 6 +-- 2 files changed, 81 insertions(+), 3 deletions(-) diff --git a/QuestPDF.Examples/ElementExamples.cs b/QuestPDF.Examples/ElementExamples.cs index 44c046d..5494050 100644 --- a/QuestPDF.Examples/ElementExamples.cs +++ b/QuestPDF.Examples/ElementExamples.cs @@ -755,5 +755,83 @@ namespace QuestPDF.Examples }); }); } + + [Test] + public void ComplexLayout() + { + RenderingTest + .Create() + .PageSize(500, 225) + .FileName() + .Render(container => + { + container + .Padding(25) + .Stack(stack => + { + stack.Item().Row(row => + { + row.RelativeColumn().LabelCell("Label 1"); + + row.RelativeColumn(3).Grid(grid => + { + grid.Columns(3); + + grid.Item(2).LabelCell("Label 2"); + grid.Item().LabelCell("Label 3"); + + grid.Item(2).ValueCell().Text("Value 2"); + grid.Item().ValueCell().Text("Value 3"); + }); + }); + + stack.Item().Row(row => + { + row.RelativeColumn().ValueCell().Text("Value 1"); + + row.RelativeColumn(3).Grid(grid => + { + grid.Columns(3); + + grid.Item().LabelCell("Label 4"); + grid.Item(2).LabelCell("Label 5"); + + grid.Item().ValueCell().Text("Value 4"); + grid.Item(2).ValueCell().Text("Value 5"); + }); + }); + + stack.Item().Row(row => + { + row.RelativeColumn().LabelCell("Label 6"); + row.RelativeColumn().ValueCell().Text("Value 6"); + }); + }); + }); + } + + [Test] + public void DomainSpecificLanguage() + { + RenderingTest + .Create() + .PageSize(600, 310) + .FileName() + .Render(container => + { + container + .Padding(25) + .Grid(grid => + { + grid.Columns(10); + + for(var i=1; i<=4; i++) + { + grid.Item(2).LabelCell(Placeholders.Label()); + grid.Item(3).ValueCell().Image(Placeholders.Image(200, 150)); + } + }); + }); + } } } diff --git a/QuestPDF.Examples/FrameExample.cs b/QuestPDF.Examples/FrameExample.cs index 9f11f2c..e98bb35 100644 --- a/QuestPDF.Examples/FrameExample.cs +++ b/QuestPDF.Examples/FrameExample.cs @@ -12,11 +12,11 @@ namespace QuestPDF.Examples { return container .Border(1) - .Background(dark ? "#EEE" : "#FFF") + .Background(dark ? Colors.Grey.Lighten2 : Colors.White) .Padding(10); } - public static IContainer LabelCell(this IContainer container) => container.Cell(true); + public static void LabelCell(this IContainer container, string text) => container.Cell(true).Text(text, TextStyle.Default.Medium()); public static IContainer ValueCell(this IContainer container) => container.Cell(false); } @@ -40,7 +40,7 @@ namespace QuestPDF.Examples { stack.Item().Row(row => { - row.RelativeColumn(2).LabelCell().Text(Placeholders.Label()); + row.RelativeColumn(2).LabelCell(Placeholders.Label()); row.RelativeColumn(3).ValueCell().Text(Placeholders.Paragraph()); }); }