From 7cc272ff9ec013f786dc20d795f6547368e20faa Mon Sep 17 00:00:00 2001 From: MarcinZiabek Date: Thu, 30 Dec 2021 21:07:34 +0100 Subject: [PATCH] Border radius: added example --- QuestPDF.Examples/BarCode.cs | 32 ------------------- QuestPDF.Examples/BarcodeExamples.cs | 25 +++++++-------- QuestPDF.Examples/CanvasExamples.cs | 46 ++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 44 deletions(-) delete mode 100644 QuestPDF.Examples/BarCode.cs create mode 100644 QuestPDF.Examples/CanvasExamples.cs diff --git a/QuestPDF.Examples/BarCode.cs b/QuestPDF.Examples/BarCode.cs deleted file mode 100644 index fd4853b..0000000 --- a/QuestPDF.Examples/BarCode.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.IO; -using NUnit.Framework; -using QuestPDF.Drawing; -using QuestPDF.Examples.Engine; -using QuestPDF.Fluent; -using QuestPDF.Helpers; -using QuestPDF.Infrastructure; - -namespace QuestPDF.Examples -{ - public class BarCode - { - [Test] - public void Example() - { - FontManager.RegisterFontType("LibreBarcode39", File.OpenRead("LibreBarcode39-Regular.ttf")); - - RenderingTest - .Create() - .PageSize(400, 100) - .ShowResults() - .Render(container => - { - container - .Background(Colors.White) - .AlignCenter() - .AlignMiddle() - .Text("*QuestPDF*", TextStyle.Default.FontType("LibreBarcode39").Size(64)); - }); - } - } -} \ No newline at end of file diff --git a/QuestPDF.Examples/BarcodeExamples.cs b/QuestPDF.Examples/BarcodeExamples.cs index b9b3f9f..0ce3beb 100644 --- a/QuestPDF.Examples/BarcodeExamples.cs +++ b/QuestPDF.Examples/BarcodeExamples.cs @@ -1,4 +1,6 @@ -using NUnit.Framework; +using System.IO; +using NUnit.Framework; +using QuestPDF.Drawing; using QuestPDF.Examples.Engine; using QuestPDF.Fluent; using QuestPDF.Helpers; @@ -6,26 +8,25 @@ using QuestPDF.Infrastructure; namespace QuestPDF.Examples { - [TestFixture] public class BarcodeExamples { [Test] - public void Barcode() + public void Example() { + FontManager.RegisterFontType("LibreBarcode39", File.OpenRead("LibreBarcode39-Regular.ttf")); + RenderingTest .Create() - .PageSize(300, 300) + .PageSize(400, 100) + .ShowResults() .Render(container => { container - .Background("#FFF") - .Padding(25) - .Stack(stack => - { - stack.Item().Border(1).Background(Colors.Grey.Lighten3).Padding(5).Text("Barcode Example"); - stack.Item().Border(1).Padding(5).AlignCenter().Text("*123456789*", TextStyle.Default.FontType("CarolinaBar-Demo-25E2").Size(20)); - }); + .Background(Colors.White) + .AlignCenter() + .AlignMiddle() + .Text("*QuestPDF*", TextStyle.Default.FontType("LibreBarcode39").Size(64)); }); } } -} +} \ No newline at end of file diff --git a/QuestPDF.Examples/CanvasExamples.cs b/QuestPDF.Examples/CanvasExamples.cs new file mode 100644 index 0000000..a4f1be8 --- /dev/null +++ b/QuestPDF.Examples/CanvasExamples.cs @@ -0,0 +1,46 @@ +using Microcharts; +using NUnit.Framework; +using QuestPDF.Examples.Engine; +using QuestPDF.Fluent; +using QuestPDF.Helpers; +using QuestPDF.Infrastructure; +using SkiaSharp; + +namespace QuestPDF.Examples +{ + public class CanvasExamples + { + [Test] + public void BorderRadius() + { + RenderingTest + .Create() + .PageSize(400, 600) + .ProducePdf() + .ShowResults() + .Render(container => + { + container + .Background(Colors.White) + .Padding(25) + .Box() + .Layers(layers => + { + layers.PrimaryLayer().Padding(10).Text("Sample text"); + + layers.Layer().Canvas((canvas, size) => + { + using var paint = new SKPaint + { + Color = SKColor.Parse(Colors.Black), + IsStroke = true, + StrokeWidth = 1 + }; + + canvas.DrawRoundRect(0, 0, size.Width, size.Height, 20, 20, paint); + }); + }); + }); + } + } +} \ No newline at end of file