PaddingExamples.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using QuestPDF.Fluent;
  2. using QuestPDF.Helpers;
  3. using QuestPDF.Infrastructure;
  4. namespace QuestPDF.DocumentationExamples;
  5. public class PaddingExamples
  6. {
  7. [Test]
  8. public void SimpleExample()
  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. .PaddingVertical(10)
  21. .PaddingLeft(20)
  22. .PaddingRight(40)
  23. .Background(Colors.Grey.Lighten2)
  24. .Text("Sample text");
  25. });
  26. })
  27. .GenerateImages(x => "padding-simple.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
  28. }
  29. [Test]
  30. public void NegativeExample()
  31. {
  32. Document
  33. .Create(document =>
  34. {
  35. document.Page(page =>
  36. {
  37. page.MinSize(new PageSize(0, 0));
  38. page.MaxSize(new PageSize(1000, 1000));
  39. page.DefaultTextStyle(x => x.FontSize(20));
  40. page.Content()
  41. .Width(250)
  42. .Padding(50)
  43. .Background(Colors.Grey.Lighten2)
  44. .PaddingHorizontal(-25)
  45. .Text("Sample text with negative padding");
  46. });
  47. })
  48. .GenerateImages(x => "padding-negative.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
  49. }
  50. }