Files
QuestPDF/QuestPDF.ReportSample/Layouts/PhotoTemplate.cs
T

61 lines
1.9 KiB
C#
Raw Normal View History

2021-01-16 01:31:39 +01:00
using QuestPDF.Fluent;
using QuestPDF.Helpers;
2021-01-16 01:31:39 +01:00
using QuestPDF.Infrastructure;
namespace QuestPDF.ReportSample.Layouts
{
public class PhotoTemplate : IComponent
{
public ReportPhoto Model { get; set; }
public PhotoTemplate(ReportPhoto model)
{
Model = model;
}
public void Compose(IContainer container)
{
container
.ShowEntire()
2021-01-16 01:31:39 +01:00
.Stack(stack =>
{
stack.Spacing(5);
stack.Item().Element(PhotoWithMaps);
stack.Item().Element(PhotoDetails);
2021-01-16 01:31:39 +01:00
});
}
void PhotoWithMaps(IContainer container)
{
container
.Row(row =>
{
row.RelativeColumn(2).AspectRatio(4 / 3f).Component<ImagePlaceholder>();
2021-01-16 01:31:39 +01:00
row.RelativeColumn().PaddingLeft(5).Stack(stack =>
2021-01-16 01:31:39 +01:00
{
stack.Spacing(7f);
stack.Item().AspectRatio(4 / 3f).Component<ImagePlaceholder>();
stack.Item().AspectRatio(4 / 3f).Component<ImagePlaceholder>();
2021-01-16 01:31:39 +01:00
});
});
}
void PhotoDetails(IContainer container)
{
container.Border(0.75f).BorderColor(Colors.Grey.Medium).Grid(grid =>
2021-01-16 01:31:39 +01:00
{
grid.Columns(6);
2021-01-16 01:31:39 +01:00
grid.Item().LabelCell().Text("Date");
grid.Item(2).ValueCell().Text(Model.Date?.ToString("g") ?? string.Empty);
grid.Item().LabelCell().Text("Location");
grid.Item(2).ValueCell().Text(Model.Location.Format());
grid.Item().LabelCell().Text("Comments");
grid.Item(5).ValueCell().Text(Model.Comments);
2021-01-16 01:31:39 +01:00
});
}
}
}