ContentDirectionExamples.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using QuestPDF.Fluent;
  2. using QuestPDF.Helpers;
  3. using QuestPDF.Infrastructure;
  4. namespace QuestPDF.DocumentationExamples;
  5. public class ContentDirectionExamples
  6. {
  7. [Test]
  8. public void LeftToRightExample()
  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.Content()
  19. .Width(250)
  20. .ContentFromLeftToRight()
  21. .Row(row =>
  22. {
  23. row.Spacing(5);
  24. row.AutoItem().Height(50).Width(50).Background(Colors.Red.Lighten1);
  25. row.AutoItem().Height(50).Width(50).Background(Colors.Green.Lighten1);
  26. row.AutoItem().Height(50).Width(75).Background(Colors.Blue.Lighten1);
  27. });
  28. });
  29. })
  30. .GenerateImages(x => "content-direction-ltr.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
  31. }
  32. [Test]
  33. public void RightToLeftExample()
  34. {
  35. Document
  36. .Create(document =>
  37. {
  38. document.Page(page =>
  39. {
  40. page.MinSize(new PageSize(0, 0));
  41. page.MaxSize(new PageSize(1000, 1000));
  42. page.DefaultTextStyle(x => x.FontSize(20));
  43. page.Content()
  44. .Width(250)
  45. .ContentFromRightToLeft()
  46. .Row(row =>
  47. {
  48. row.Spacing(5);
  49. row.AutoItem().Height(50).Width(50).Background(Colors.Red.Lighten1);
  50. row.AutoItem().Height(50).Width(50).Background(Colors.Green.Lighten1);
  51. row.AutoItem().Height(50).Width(75).Background(Colors.Blue.Lighten1);
  52. });
  53. });
  54. })
  55. .GenerateImages(x => "content-direction-rtl.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
  56. }
  57. }