Browse Source

RTL: aspect ratio (fix)

MarcinZiabek 3 years ago
parent
commit
f5f90bd235
1 changed files with 7 additions and 2 deletions
  1. 7 2
      QuestPDF/Elements/AspectRatio.cs

+ 7 - 2
QuestPDF/Elements/AspectRatio.cs

@@ -4,8 +4,10 @@ using QuestPDF.Infrastructure;
 
 
 namespace QuestPDF.Elements
 namespace QuestPDF.Elements
 {
 {
-    internal class AspectRatio : ContainerElement, ICacheable
+    internal class AspectRatio : ContainerElement, ICacheable, IContentDirectionAware
     {
     {
+        public ContentDirection ContentDirection { get; set; }
+        
         public float Ratio { get; set; } = 1;
         public float Ratio { get; set; } = 1;
         public AspectRatioOption Option { get; set; } = AspectRatioOption.FitWidth;
         public AspectRatioOption Option { get; set; } = AspectRatioOption.FitWidth;
         
         
@@ -42,7 +44,10 @@ namespace QuestPDF.Elements
                 return;
                 return;
             
             
             var size = GetTargetSize(availableSpace);
             var size = GetTargetSize(availableSpace);
-            var offset = new Position(availableSpace.Width - size.Width, 0);
+            
+            var offset = ContentDirection == ContentDirection.LeftToRight
+                ? Position.Zero
+                : new Position(availableSpace.Width - size.Width, 0);
             
             
             Canvas.Translate(offset);
             Canvas.Translate(offset);
             base.Draw(size);
             base.Draw(size);