PhotoTemplate.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using QuestPDF.Fluent;
  2. using QuestPDF.Infrastructure;
  3. namespace QuestPDF.ReportSample.Layouts
  4. {
  5. public class PhotoTemplate : IComponent
  6. {
  7. public ReportPhoto Model { get; set; }
  8. public PhotoTemplate(ReportPhoto model)
  9. {
  10. Model = model;
  11. }
  12. public void Compose(IContainer container)
  13. {
  14. container
  15. .Stack(stack =>
  16. {
  17. stack.Element(PhotoWithMaps);
  18. stack.Element(PhotoDetails);
  19. });
  20. }
  21. void PhotoWithMaps(IContainer container)
  22. {
  23. container
  24. .Padding(-3)
  25. .PaddingBottom(3)
  26. .Row(row =>
  27. {
  28. row.RelativeColumn(2).Padding(3).Component(new ImageTemplate(Model.PhotoData));
  29. row.RelativeColumn().Stack(stack =>
  30. {
  31. stack.Element().Padding(3).Component(new ImageTemplate(Model.MapDetailsSource));
  32. stack.Element().Padding(3).Component(new ImageTemplate(Model.MapContextSource));
  33. });
  34. });
  35. }
  36. void PhotoDetails(IContainer container)
  37. {
  38. container.Stack(stack =>
  39. {
  40. stack.Element().Row(row =>
  41. {
  42. row.RelativeColumn().DarkCell().Text("Date", Typography.Normal);
  43. row.RelativeColumn(2).LightCell().Text(Model.Date?.ToString("g") ?? string.Empty, Typography.Normal);
  44. row.RelativeColumn().DarkCell().Text("Location", Typography.Normal);
  45. row.RelativeColumn(2).LightCell().Text(Model.Location.Format(), Typography.Normal);
  46. });
  47. stack.Element().Row(row =>
  48. {
  49. row.RelativeColumn().DarkCell().Text("Comments", Typography.Normal);
  50. row.RelativeColumn(5).LightCell().Text(Model.Comments, Typography.Normal);
  51. });
  52. });
  53. }
  54. }
  55. }