Files

53 lines
1.8 KiB
C#
Raw Permalink Normal View History

2021-06-09 23:34:25 +02:00
using NUnit.Framework;
2021-01-16 01:31:39 +01:00
using QuestPDF.Examples.Engine;
using QuestPDF.Fluent;
using QuestPDF.Helpers;
using QuestPDF.Infrastructure;
namespace QuestPDF.Examples
{
static class SimpleExtension
{
private static IContainer Cell(this IContainer container, bool dark)
{
return container
.Border(1)
2021-12-30 18:40:54 +01:00
.BorderColor(Colors.Grey.Medium)
.Background(dark ? Colors.Grey.Lighten3 : Colors.White)
.Padding(5);
2021-01-16 01:31:39 +01:00
}
2022-03-08 17:27:30 +01:00
public static void LabelCell(this IContainer container, string text) => container.Cell(true).Text(text).SemiBold();
2021-01-16 01:31:39 +01:00
public static IContainer ValueCell(this IContainer container) => container.Cell(false);
2022-03-08 17:27:30 +01:00
public static void ValueCell(this IContainer container, string text) => container.ValueCell().Text(text);
2021-01-16 01:31:39 +01:00
}
2021-06-09 23:34:25 +02:00
public class FrameExample
2021-01-16 01:31:39 +01:00
{
2021-06-09 23:34:25 +02:00
[Test]
2021-09-30 22:48:39 +02:00
public void Frame()
2021-01-16 01:31:39 +01:00
{
2021-06-09 23:34:25 +02:00
RenderingTest
.Create()
.PageSize(550, 400)
2021-09-30 22:48:39 +02:00
.ShowResults()
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("#FFF")
.Padding(25)
.Column(column =>
2021-01-16 01:31:39 +01:00
{
for(var i = 1; i <= 4; i++)
2021-06-09 23:34:25 +02:00
{
column.Item().Row(row =>
2021-06-09 23:34:25 +02:00
{
row.RelativeItem(2).LabelCell(Placeholders.Label());
row.RelativeItem(3).ValueCell().Text(Placeholders.Paragraph());
2021-06-09 23:34:25 +02:00
});
}
2021-01-16 01:31:39 +01:00
});
});
}
}
}