From a07fdb8d45bb37bfb93cf848ee6e79b01ea4efed Mon Sep 17 00:00:00 2001 From: mvantzet Date: Tue, 14 Mar 2023 12:33:21 +0100 Subject: [PATCH] Follow suggestion by @BobLd, added 2 more test cases for if we want to support more lenient page size parsing in the future. --- src/UglyToad.PdfPig.Tests/Geometry/PdfRectangleTests.cs | 2 ++ src/UglyToad.PdfPig/Content/PageSize.cs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/UglyToad.PdfPig.Tests/Geometry/PdfRectangleTests.cs b/src/UglyToad.PdfPig.Tests/Geometry/PdfRectangleTests.cs index 3d49dc86..adb67ddc 100644 --- a/src/UglyToad.PdfPig.Tests/Geometry/PdfRectangleTests.cs +++ b/src/UglyToad.PdfPig.Tests/Geometry/PdfRectangleTests.cs @@ -1699,6 +1699,8 @@ [Theory] [InlineData(595, 842, PageSize.A4)] + [InlineData(594, 843, PageSize.Custom)] + [InlineData(596, 841, PageSize.Custom)] [InlineData(842, 595, PageSize.A4)] [InlineData(595.3, 841.5, PageSize.A4)] [InlineData(841.5, 595.3, PageSize.A4)] diff --git a/src/UglyToad.PdfPig/Content/PageSize.cs b/src/UglyToad.PdfPig/Content/PageSize.cs index fd1e6de6..f5795aeb 100644 --- a/src/UglyToad.PdfPig/Content/PageSize.cs +++ b/src/UglyToad.PdfPig/Content/PageSize.cs @@ -150,8 +150,8 @@ public override bool Equals(object obj) { return obj is WidthHeight height && - Math.Abs(Width - height.Width) < 1 && - Math.Abs(Height - height.Height) < 1; + Math.Round(Width) == Math.Round(height.Width) && + Math.Round(Height) == Math.Round(height.Height); } public override int GetHashCode()