Browse Source

Fix: improved `Image.FitUnproportionally` behavior to ensure it now respects minimal size constraints and doesn't just expand to use all the available space.

Marcin Ziąbek 2 years ago
parent
commit
cf96afd013
2 changed files with 19 additions and 1 deletions
  1. 18 0
      Source/QuestPDF.Examples/ImageExamples.cs
  2. 1 1
      Source/QuestPDF/Elements/Image.cs

+ 18 - 0
Source/QuestPDF.Examples/ImageExamples.cs

@@ -139,6 +139,24 @@ namespace QuestPDF.Examples
                 });
         }
         
+        [Test]
+        public void FitUnproportionally()
+        {
+            RenderingTest
+                .Create()
+                .PageSize(400, 600)
+                .ProduceImages()
+                .ShowResults()
+                .Render(page =>
+                {
+                    page.Padding(15).MinimalBox().Background(Colors.Grey.Lighten3).Row(row =>
+                    {
+                        row.RelativeItem().Padding(5).Text(Placeholders.LoremIpsum());
+                        row.RelativeItem().Image("photo.jpg").FitUnproportionally();
+                    });
+                });
+        }
+        
         [Test]
         public void Exception()
         {

+ 1 - 1
Source/QuestPDF/Elements/Image.cs

@@ -17,7 +17,7 @@ namespace QuestPDF.Elements
         {
             return availableSpace.IsNegative() 
                 ? SpacePlan.Wrap() 
-                : SpacePlan.FullRender(availableSpace);
+                : SpacePlan.FullRender(Size.Zero);
         }
 
         internal override void Draw(Size availableSpace)