PhotoTemplate.cs 2.0 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. .Stack(stack =>
  18. {
  19. stack.Spacing(5);
  20. stack.Item().Element(PhotoWithMaps);
  21. stack.Item().Element(PhotoDetails);
  22. });
  23. }
  24. void PhotoWithMaps(IContainer container)
  25. {
  26. container
  27. .Row(row =>
  28. {
  29. row.RelativeColumn(2).AspectRatio(4 / 3f).Background(Colors.Grey.Lighten3);
  30. row.RelativeColumn().PaddingLeft(5).Stack(stack =>
  31. {
  32. stack.Spacing(7f);
  33. stack.Item().AspectRatio(4 / 3f).Background(Colors.Grey.Lighten3);
  34. stack.Item().AspectRatio(4 / 3f).Background(Colors.Grey.Lighten3);
  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", Typography.Normal);
  44. grid.Item(2).ValueCell().Text(Model.Date?.ToString("g") ?? string.Empty, Typography.Normal);
  45. grid.Item().LabelCell().Text("Location", Typography.Normal);
  46. grid.Item(2).ValueCell().Text(Model.Location.Format(), Typography.Normal);
  47. grid.Item().LabelCell().Text("Comments", Typography.Normal);
  48. grid.Item(5).ValueCell().Text(Model.Comments, Typography.Normal);
  49. });
  50. }
  51. }
  52. }