PhotoTemplate.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using QuestPDF.Fluent;
  2. using QuestPDF.Helpers;
  3. using QuestPDF.Infrastructure;
  4. namespace QuestPDF.ReportSample.Layouts
  5. {
  6. public class PhotoTemplate : IComponent
  7. {
  8. public ReportPhoto Model { get; set; }
  9. public PhotoTemplate(ReportPhoto model)
  10. {
  11. Model = model;
  12. }
  13. public void Compose(IContainer container)
  14. {
  15. container
  16. .ShowEntire()
  17. .Column(column =>
  18. {
  19. column.Spacing(5);
  20. column.Item().Element(PhotoWithMaps);
  21. column.Item().Element(PhotoDetails);
  22. });
  23. }
  24. void PhotoWithMaps(IContainer container)
  25. {
  26. container
  27. .Row(row =>
  28. {
  29. row.RelativeItem(2).AspectRatio(4 / 3f).Component<ImagePlaceholder>();
  30. row.RelativeItem().PaddingLeft(5).Column(column =>
  31. {
  32. column.Spacing(7f);
  33. column.Item().AspectRatio(4 / 3f).Component<ImagePlaceholder>();
  34. column.Item().AspectRatio(4 / 3f).Component<ImagePlaceholder>();
  35. });
  36. });
  37. }
  38. void PhotoDetails(IContainer container)
  39. {
  40. container.Border(0.75f).BorderColor(Colors.Grey.Medium).Grid(grid =>
  41. {
  42. grid.Columns(6);
  43. grid.Item().LabelCell().Text("Date");
  44. grid.Item(2).ValueCell().Text(Model.Date?.ToString("g") ?? string.Empty);
  45. grid.Item().LabelCell().Text("Location");
  46. grid.Item(2).ValueCell().Text(Model.Location.Format());
  47. grid.Item().LabelCell().Text("Comments");
  48. grid.Item(5).ValueCell().Text(Model.Comments);
  49. });
  50. }
  51. }
  52. }