Program.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using System.Net.Http.Headers;
  2. using Avalonia.Media;
  3. using QuestPDF.Fluent;
  4. using QuestPDF.Helpers;
  5. using QuestPDF.Infrastructure;
  6. using QuestPDF.Previewer;
  7. using QuestPDF.ReportSample;
  8. using QuestPDF.ReportSample.Layouts;
  9. using Colors = QuestPDF.Helpers.Colors;
  10. ImagePlaceholder.Solid = true;
  11. // var model = DataSource.GetReport();
  12. // var report = new StandardReport(model);
  13. // report.ShowInPreviewer().Wait();
  14. //
  15. // return;
  16. Document
  17. .Create(container =>
  18. {
  19. container.Page(page =>
  20. {
  21. page.Size(PageSizes.A4);
  22. page.Margin(2, Unit.Centimetre);
  23. page.PageColor(Colors.White);
  24. page.DefaultTextStyle(x => x.FontSize(20));
  25. page.Header()
  26. .Text("Hot Reload!")
  27. .SemiBold().FontSize(36).FontColor(Colors.Blue.Darken2);
  28. page.Content()
  29. .PaddingVertical(1, Unit.Centimetre)
  30. .Column(x =>
  31. {
  32. x.Spacing(20);
  33. x.Item().Table(t =>
  34. {
  35. t.ColumnsDefinition(c =>
  36. {
  37. c.RelativeColumn();
  38. c.RelativeColumn(3);
  39. });
  40. t.Cell().Border(1).Background(Colors.Grey.Lighten3).Padding(5).Text("Visual Studio");
  41. t.Cell().Border(1).Padding(5).Text("Start in debug mode with 'Hot Reload on Save' enabled.");
  42. t.Cell().Border(1).Background(Colors.Grey.Lighten3).Padding(5).Text("Command line");
  43. t.Cell().Border(1).Padding(5).Text("Run 'dotnet watch'.");
  44. });
  45. x.Item().Text("Modify this line and the preview should show your changes instantly.");
  46. // for testing exception handling
  47. // try
  48. // {
  49. // throw new ArgumentException("This file does not exists... peace.png");
  50. // }
  51. // catch (Exception e)
  52. // {
  53. // throw new FileNotFoundException("This is the top exception!", e);
  54. // }
  55. });
  56. page.Footer()
  57. .AlignCenter()
  58. .Text(x =>
  59. {
  60. x.Span("Page ");
  61. x.CurrentPageNumber();
  62. });
  63. });
  64. container.Page(page =>
  65. {
  66. page.Size(PageSizes.A4);
  67. page.Margin(2, Unit.Centimetre);
  68. page.DefaultTextStyle(x => x.FontSize(20));
  69. page.Content()
  70. .PaddingVertical(1, Unit.Centimetre)
  71. .Column(x =>
  72. {
  73. x.Spacing(20);
  74. foreach (var i in Enumerable.Range(0, 10))
  75. x.Item().Background(Colors.Grey.Lighten2).Height(80);
  76. });
  77. });
  78. })
  79. .ShowInPreviewer().Wait();