Browse Source

Fix MaxWidth calculation when pages are empty.

Bebo-Maker 3 years ago
parent
commit
828bb86737
1 changed files with 1 additions and 1 deletions
  1. 1 1
      QuestPDF.Previewer/InteractiveCanvas.cs

+ 1 - 1
QuestPDF.Previewer/InteractiveCanvas.cs

@@ -26,7 +26,7 @@ class InteractiveCanvas : ICustomDrawOperation
     private const float SafeZone = 50f;
     private const float SafeZone = 50f;
 
 
     public float TotalHeight => Pages.Sum(x => x.Size.Height) + (Pages.Count - 1) * PageSpacing;
     public float TotalHeight => Pages.Sum(x => x.Size.Height) + (Pages.Count - 1) * PageSpacing;
-    public float MaxWidth => Pages.Max(x => x.Size.Width);
+    public float MaxWidth => Pages.Any() ? Pages.Max(x => x.Size.Width) : 0;
     public float MaxTranslateY => -(Height / 2 - SafeZone) / Scale;
     public float MaxTranslateY => -(Height / 2 - SafeZone) / Scale;
     public float MinTranslateY => (Height / 2 - SafeZone) / Scale - TotalHeight;
     public float MinTranslateY => (Height / 2 - SafeZone) / Scale - TotalHeight;