PhotoTemplate.cs 1.9 KB

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