Skip to content

Commit 8e9fa33

Browse files
author
ArthurHub
committed
* fix render to image no filling min width
1 parent f25060d commit 8e9fa33

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

‎Source/HtmlRenderer/HtmlRender.cs‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -634,13 +634,21 @@ private static Size MeasureHtmlByRestrictions(HtmlContainer htmlContainer, Size
634634
htmlContainer.MaxSize = new SizeF(maxSize.Width, 0);
635635
htmlContainer.PerformLayout(measureGraphics);
636636
}
637-
}
638637

639-
// restrict the final size by min/max
640-
var finalWidth = Math.Max(maxSize.Width > 0 ? Math.Min(maxSize.Width, (int)htmlContainer.ActualSize.Width) : (int)htmlContainer.ActualSize.Width, minSize.Width);
641-
var finalHeight = Math.Max(maxSize.Height > 0 ? Math.Min(maxSize.Height, (int)htmlContainer.ActualSize.Height) : (int)htmlContainer.ActualSize.Height, minSize.Height);
638+
// restrict the final size by min/max
639+
var finalWidth = Math.Max(maxSize.Width > 0 ? Math.Min(maxSize.Width, (int)htmlContainer.ActualSize.Width) : (int)htmlContainer.ActualSize.Width, minSize.Width);
642640

643-
return new Size(finalWidth, finalHeight);
641+
// if the final width is larger than the actual we need to re-layout so the html can take the full given width.
642+
if (finalWidth > htmlContainer.ActualSize.Width)
643+
{
644+
htmlContainer.MaxSize = new SizeF(finalWidth, 0);
645+
htmlContainer.PerformLayout(measureGraphics);
646+
}
647+
648+
var finalHeight = Math.Max(maxSize.Height > 0 ? Math.Min(maxSize.Height, (int)htmlContainer.ActualSize.Height) : (int)htmlContainer.ActualSize.Height, minSize.Height);
649+
650+
return new Size(finalWidth, finalHeight);
651+
}
644652
}
645653

646654
/// <summary>

0 commit comments

Comments
 (0)