Fixed rendering for the "Rotate" element
This commit is contained in:
@@ -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());
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user