Files
QuestPDF/QuestPDF.Examples/Padding.cs
T

167 lines
5.4 KiB
C#
Raw Normal View History

2021-06-09 23:34:25 +02:00
using NUnit.Framework;
using QuestPDF.Examples.Engine;
2021-01-16 01:31:39 +01:00
using QuestPDF.Fluent;
using QuestPDF.Infrastructure;
namespace QuestPDF.Examples
{
2021-06-09 23:34:25 +02:00
public class Examples
2021-01-16 01:31:39 +01:00
{
2021-06-09 23:34:25 +02:00
[Test]
public void Padding()
2021-01-16 01:31:39 +01:00
{
2021-06-09 23:34:25 +02:00
RenderingTest
.Create()
.PageSize(200, 150)
.FileName()
2021-06-09 23:34:25 +02:00
.Render(container =>
2021-01-16 01:31:39 +01:00
{
2021-06-09 23:34:25 +02:00
container
.Background("#FDD")
.Padding(50)
.Background("#AFA")
.PaddingVertical(50)
.Background("#77F")
.PaddingHorizontal(50)
2021-01-16 01:31:39 +01:00
.Background("#444");
});
}
2021-06-09 23:34:25 +02:00
[Test]
public void Border()
2021-01-16 01:31:39 +01:00
{
2021-06-09 23:34:25 +02:00
RenderingTest
.Create()
.PageSize(200, 150)
.FileName()
2021-06-09 23:34:25 +02:00
.Render(container =>
2021-01-16 01:31:39 +01:00
{
2021-06-09 23:34:25 +02:00
container
.Background("#EEE")
.Padding(25)
.AlignBottom()
.AlignCenter()
.BorderBottom(2)
.BorderColor("#000")
.Background("FFF")
.Padding(5)
.Text("Sample text", TextStyle.Default.FontType("Segoe UI emoji").Alignment(HorizontalAlignment.Center));
});
}
[Test]
public void Alignment()
{
RenderingTest
.Create()
.PageSize(200, 150)
.FileName()
2021-06-09 23:34:25 +02:00
.Render(container =>
{
container
.Stack(column =>
2021-01-16 01:31:39 +01:00
{
2021-06-09 23:34:25 +02:00
column
.Item()
.Height(100)
.Background("#FFF")
.AlignLeft()
.AlignMiddle()
2021-01-16 01:31:39 +01:00
.Width(50)
.Height(50)
2021-06-09 23:34:25 +02:00
.Background("#444");
2021-01-16 01:31:39 +01:00
2021-06-09 23:34:25 +02:00
column
.Item()
.Height(100)
.Background("#DDD")
.AlignCenter()
.AlignMiddle()
2021-01-16 01:31:39 +01:00
.Width(50)
2021-06-09 23:34:25 +02:00
.Height(50)
.Background("#222");
column
.Item()
.Height(100)
.Background("#BBB")
.AlignRight()
.AlignMiddle()
2021-01-16 01:31:39 +01:00
2021-06-09 23:34:25 +02:00
.Width(50)
.Height(50)
.Background("#000");
});
});
}
[Test]
public void Expand()
{
RenderingTest
.Create()
.PageSize(200, 150)
.FileName()
2021-06-09 23:34:25 +02:00
.Render(container =>
{
container
.Stack(column =>
{
column
.Item()
.Height(150)
.Row(row =>
{
row.RelativeColumn()
.Extend()
.Background("FFF")
.Height(50)
.Width(50)
.Background("444");
row.RelativeColumn()
.Extend()
.Background("BBB")
.Height(50)
.ExtendHorizontal()
.Background("444");
});
column
.Item()
.Height(150)
.Row(row =>
{
row.RelativeColumn()
.Extend()
.Background("BBB")
.ExtendVertical()
.Width(50)
.Background("444");
row.RelativeColumn()
.Extend()
.Background("BBB")
.ExtendVertical()
.ExtendHorizontal()
.Background("444");
});
2021-01-16 01:31:39 +01:00
});
});
}
}
}