| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- using NUnit.Framework;
- using QuestPDF.Examples.Engine;
- using QuestPDF.Fluent;
- using QuestPDF.Helpers;
- using QuestPDF.Infrastructure;
- namespace QuestPDF.Examples
- {
- public class RowExamples
- {
- [Test]
- public void ItemTypes()
- {
- RenderingTest
- .Create()
- .ProducePdf()
- .PageSize(650, 300)
- .ShowResults()
- .Render(container =>
- {
- container
- .Padding(25)
- .MinimalBox()
- .Border(1)
- .Column(column =>
- {
- column.Item().LabelCell("Total width: 600px");
-
- column.Item().Row(row =>
- {
- row.ConstantItem(150).ValueCell("150px");
- row.ConstantItem(100).ValueCell("100px");
- row.RelativeItem(4).ValueCell("200px");
- row.RelativeItem(3).ValueCell("150px");
- });
-
- column.Item().Row(row =>
- {
- row.ConstantItem(100).ValueCell("100px");
- row.ConstantItem(50).ValueCell("50px");
- row.RelativeItem(2).ValueCell("100px");
- row.RelativeItem(1).ValueCell("50px");
- });
- });
- });
- }
-
- [Test]
- public void Stability()
- {
- // up to version 2021.12, this code would always result with the infinite layout exception
-
- RenderingTest
- .Create()
- .ProducePdf()
- .MaxPages(100)
- .PageSize(250, 150)
- .ShowResults()
- .Render(container =>
- {
- container
- .Padding(25)
- .Row(row =>
- {
- row.RelativeItem().Column(column =>
- {
- column.Item().ShowOnce().Element(CreateBox).Text("X");
- column.Item().Element(CreateBox).Text("1");
- column.Item().Element(CreateBox).Text("2");
- });
-
- row.RelativeItem().Column(column =>
- {
- column.Item().Element(CreateBox).Text("1");
- column.Item().Element(CreateBox).Text("2");
- });
- });
- });
- static IContainer CreateBox(IContainer container)
- {
- return container
- .ExtendHorizontal()
- .ExtendVertical()
- .Background(Colors.Grey.Lighten4)
- .Border(1)
- .AlignCenter()
- .AlignMiddle()
- .ShowOnce();
- }
- }
-
- [Test]
- public void Stability_NoItems()
- {
- RenderingTest
- .Create()
- .ProducePdf()
- .MaxPages(100)
- .PageSize(250, 150)
- .Render(container =>
- {
- container
- .Padding(25)
- .Row(row => { });
- });
- }
-
- [Test]
- public void RowElementForRelativeHeightDivision()
- {
- RenderingTest
- .Create()
- .ProduceImages()
- .ShowResults()
- .MaxPages(100)
- .PageSize(250, 400)
- .Render(container =>
- {
- container
- .Padding(25)
- .AlignLeft()
- .RotateRight()
- .Row(row =>
- {
- row.Spacing(20);
- row.RelativeItem(1).Element(Content);
- row.RelativeItem(2).Element(Content);
- row.RelativeItem(3).Element(Content);
- void Content(IContainer container)
- {
- container
- .RotateLeft()
- .Border(1)
- .Background(Placeholders.BackgroundColor())
- .Padding(5)
- .Text(Placeholders.Label());
- }
- });
- });
- }
-
- [Test]
- public void RowElementShouldRespectProvidedVerticalSpace()
- {
- RenderingTest
- .Create()
- .ProduceImages()
- .ShowResults()
- .MaxPages(100)
- .PageSize(250, 400)
- .Render(container =>
- {
- container
- .Padding(25)
- .Height(200)
- .Border(1)
- .Row(row =>
- {
- row.Spacing(50);
- row.RelativeItem().AlignTop().Height(50).Background(Placeholders.BackgroundColor());
- row.RelativeItem().AlignMiddle().Height(50).Background(Placeholders.BackgroundColor());
- row.RelativeItem().AlignBottom().Height(50).Background(Placeholders.BackgroundColor());
- });
- });
- }
- }
- }
|