LineExamples.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using QuestPDF.Fluent;
  2. using QuestPDF.Helpers;
  3. using QuestPDF.Infrastructure;
  4. namespace QuestPDF.DocumentationExamples;
  5. public class LineExamples
  6. {
  7. [Test]
  8. public void VerticalLineExample()
  9. {
  10. Document
  11. .Create(document =>
  12. {
  13. document.Page(page =>
  14. {
  15. page.MinSize(new PageSize(0, 0));
  16. page.MaxSize(new PageSize(1000, 1000));
  17. page.DefaultTextStyle(x => x.FontSize(20));
  18. page.Margin(25);
  19. page.Content()
  20. .Row(row =>
  21. {
  22. row.AutoItem().Text("Text on the left");
  23. row.AutoItem()
  24. .PaddingHorizontal(15)
  25. .LineVertical(3)
  26. .LineColor(Colors.Blue.Medium);
  27. row.AutoItem().Text("Text on the right");
  28. });
  29. });
  30. })
  31. .GenerateImages(x => "line-vertical.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.Best, RasterDpi = 144 });
  32. }
  33. [Test]
  34. public void HorizontalLineExample()
  35. {
  36. Document
  37. .Create(document =>
  38. {
  39. document.Page(page =>
  40. {
  41. page.MinSize(new PageSize(0, 0));
  42. page.MaxSize(new PageSize(1000, 1000));
  43. page.DefaultTextStyle(x => x.FontSize(20));
  44. page.Margin(25);
  45. page.Content()
  46. .Column(column =>
  47. {
  48. column.Item().Text("Text above the line");
  49. column.Item()
  50. .PaddingVertical(10)
  51. .LineHorizontal(2)
  52. .LineColor(Colors.Blue.Medium);
  53. column.Item().Text("Text below the line");
  54. });
  55. });
  56. })
  57. .GenerateImages(x => "line-horizontal.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.Best, RasterDpi = 144 });
  58. }
  59. }