Program.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using Avalonia.Media;
  2. using QuestPDF.Fluent;
  3. using QuestPDF.Helpers;
  4. using QuestPDF.Infrastructure;
  5. using QuestPDF.Previewer;
  6. using QuestPDF.ReportSample;
  7. using QuestPDF.ReportSample.Layouts;
  8. using Colors = QuestPDF.Helpers.Colors;
  9. var model = DataSource.GetReport();
  10. var report = new StandardReport(model);
  11. report.ShowInPreviewer();
  12. Document
  13. .Create(container =>
  14. {
  15. container.Page(page =>
  16. {
  17. page.Size(PageSizes.A4);
  18. page.Margin(2, Unit.Centimetre);
  19. page.PageColor(Colors.White);
  20. page.DefaultTextStyle(x => x.FontSize(20));
  21. page.Header()
  22. .Text("Hot Reload!")
  23. .SemiBold().FontSize(36).FontColor(Colors.Blue.Darken2);
  24. page.Content()
  25. .PaddingVertical(1, Unit.Centimetre)
  26. .Column(x =>
  27. {
  28. x.Spacing(20);
  29. x.Item().Table(t =>
  30. {
  31. t.ColumnsDefinition(c =>
  32. {
  33. c.RelativeColumn();
  34. c.RelativeColumn(3);
  35. });
  36. t.Cell().Border(1).Background(Colors.Grey.Lighten3).Padding(5).Text("Visual Studio");
  37. t.Cell().Border(1).Padding(5).Text("Start in debug mode with 'Hot Reload on Save' enabled.");
  38. t.Cell().Border(1).Background(Colors.Grey.Lighten3).Padding(5).Text("Command line");
  39. t.Cell().Border(1).Padding(5).Text("Run 'dotnet watch'.");
  40. });
  41. x.Item().Text("Modify this line and the preview should show your changes instantly.");
  42. });
  43. page.Footer()
  44. .AlignCenter()
  45. .Text(x =>
  46. {
  47. x.Span("Page ");
  48. x.CurrentPageNumber();
  49. });
  50. });
  51. container.Page(page =>
  52. {
  53. page.Size(PageSizes.A4);
  54. page.Margin(2, Unit.Centimetre);
  55. page.PageColor(Colors.Red.Medium);
  56. page.DefaultTextStyle(x => x.FontSize(20));
  57. page.Content()
  58. .PaddingVertical(1, Unit.Centimetre)
  59. .Column(x =>
  60. {
  61. x.Spacing(20);
  62. foreach (var i in Enumerable.Range(0, 10))
  63. x.Item().Background(Colors.Grey.Lighten2).Height(80);
  64. });
  65. });
  66. })
  67. .ShowInPreviewer();