CanvasExamples.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using Microcharts;
  2. using NUnit.Framework;
  3. using QuestPDF.Examples.Engine;
  4. using QuestPDF.Fluent;
  5. using QuestPDF.Helpers;
  6. using QuestPDF.Infrastructure;
  7. using SkiaSharp;
  8. namespace QuestPDF.Examples
  9. {
  10. public class CanvasExamples
  11. {
  12. [Test]
  13. public void BorderRadius()
  14. {
  15. RenderingTest
  16. .Create()
  17. .PageSize(400, 600)
  18. .ProducePdf()
  19. .ShowResults()
  20. .Render(container =>
  21. {
  22. container
  23. .Background(Colors.White)
  24. .Padding(25)
  25. .Box()
  26. .Layers(layers =>
  27. {
  28. layers.PrimaryLayer().Padding(10).Text("Sample text");
  29. layers.Layer().Canvas((canvas, size) =>
  30. {
  31. using var paint = new SKPaint
  32. {
  33. Color = SKColor.Parse(Colors.Black),
  34. IsStroke = true,
  35. StrokeWidth = 1
  36. };
  37. canvas.DrawRoundRect(0, 0, size.Width, size.Height, 20, 20, paint);
  38. });
  39. });
  40. });
  41. }
  42. }
  43. }