diff --git a/QuestPDF.Examples/ElementExamples.cs b/QuestPDF.Examples/ElementExamples.cs index 819f179..9466ad0 100644 --- a/QuestPDF.Examples/ElementExamples.cs +++ b/QuestPDF.Examples/ElementExamples.cs @@ -593,6 +593,8 @@ namespace QuestPDF.Examples return element; }) + .Box() + .Background(Colors.Grey.Lighten1) .Text($"Rotated {turns * 90} degrees.", TextStyle.Default.Size(14)); } }); @@ -637,5 +639,29 @@ namespace QuestPDF.Examples }); }); } + + [Test] + public void RotateInTable() + { + RenderingTest + .Create() + .PageSize(200, 200) + .Render(container => + { + container + .Border(2) + .Row(row => + { + row.ConstantColumn(25) + .Border(1) + .RotateLeft() + .AlignCenter() + .AlignMiddle() + .Text("Sample text"); + + row.RelativeColumn().Border(1).Padding(5).Text(Placeholders.Paragraph()); + }); + }); + } } } diff --git a/QuestPDF.Examples/Engine/RenderingTest.cs b/QuestPDF.Examples/Engine/RenderingTest.cs index a0ab48b..fc95be5 100644 --- a/QuestPDF.Examples/Engine/RenderingTest.cs +++ b/QuestPDF.Examples/Engine/RenderingTest.cs @@ -11,7 +11,6 @@ namespace QuestPDF.Examples.Engine public class RenderingTest { private string FileNamePrefix = "test"; - private decimal ImageDpi = 2; private Size Size { get; set; } private RenderingTest() @@ -30,12 +29,6 @@ namespace QuestPDF.Examples.Engine return this; } - public RenderingTest Dpi(decimal value = 2) - { - ImageDpi = value; - return this; - } - public RenderingTest PageSize(int width, int height) { Size = new Size(width, height); diff --git a/QuestPDF.Examples/Engine/SimpleDocument.cs b/QuestPDF.Examples/Engine/SimpleDocument.cs index 801081a..5b182cf 100644 --- a/QuestPDF.Examples/Engine/SimpleDocument.cs +++ b/QuestPDF.Examples/Engine/SimpleDocument.cs @@ -8,6 +8,8 @@ namespace QuestPDF.Examples.Engine { public class SimpleDocument : IDocument { + public const int ImageScalingFactor = 2; + private IContainer Container { get; } private Size Size { get; } @@ -21,7 +23,7 @@ namespace QuestPDF.Examples.Engine { return new DocumentMetadata() { - RasterDpi = PageSizes.PointsPerInch * 2, + RasterDpi = PageSizes.PointsPerInch * ImageScalingFactor, DocumentLayoutExceptionThreshold = 10 }; } diff --git a/QuestPDF/Elements/Rotate.cs b/QuestPDF/Elements/Rotate.cs index a81c96e..dadf526 100644 --- a/QuestPDF/Elements/Rotate.cs +++ b/QuestPDF/Elements/Rotate.cs @@ -41,13 +41,17 @@ namespace QuestPDF.Elements var currentMatrix = skiaCanvas.TotalMatrix; - if (NormalizedTurnCount % 4 == 1 || NormalizedTurnCount % 4 == 2) + if (NormalizedTurnCount == 1 || NormalizedTurnCount == 2) skiaCanvas.Translate(availableSpace.Width, 0); - if (NormalizedTurnCount % 4 == 2 || NormalizedTurnCount % 4 == 3) + if (NormalizedTurnCount == 2 || NormalizedTurnCount == 3) skiaCanvas.Translate(0, availableSpace.Height); + + skiaCanvas.RotateRadians(NormalizedTurnCount * (float) Math.PI / 2f); + + if (NormalizedTurnCount == 1 || NormalizedTurnCount == 3) + availableSpace = new Size(availableSpace.Height, availableSpace.Width); - skiaCanvas.RotateRadians(TurnCount * (float) Math.PI / 2f); Child?.Draw(availableSpace); skiaCanvas.SetMatrix(currentMatrix); }