diff --git a/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs b/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs index 9d4a5bc4..1f7e3548 100644 --- a/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs +++ b/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs @@ -1,5 +1,7 @@ namespace UglyToad.PdfPig.Tests.Integration { + using Content; + public class GithubIssuesTests { [Fact] @@ -22,5 +24,32 @@ public void Issue874() Assert.StartsWith("Value cannot be null.", ex.Message); } } + + [Fact] + public void Issue913() + { + var doc = IntegrationHelpers.GetSpecificTestDocumentPath("Rotation 45.pdf"); + + using (var document = PdfDocument.Open(doc)) + { + var page1 = document.GetPage(1); + + for (int l = 131; l <= 137; ++l) + { + var letter = page1.Letters[l]; + Assert.Equal(TextOrientation.Other, letter.TextOrientation); + Assert.Equal(45.0, letter.GlyphRectangle.Rotation, 5); + } + + var page2 = document.GetPage(2); + Assert.Equal(157, page2.Letters.Count); + + var page3 = document.GetPage(3); + Assert.Equal(283, page3.Letters.Count); + + var page4 = document.GetPage(4); + Assert.Equal(304, page4.Letters.Count); + } + } } } diff --git a/src/UglyToad.PdfPig.Tests/Integration/SpecificTestDocuments/Rotation 45.pdf b/src/UglyToad.PdfPig.Tests/Integration/SpecificTestDocuments/Rotation 45.pdf new file mode 100644 index 00000000..a261dbcd Binary files /dev/null and b/src/UglyToad.PdfPig.Tests/Integration/SpecificTestDocuments/Rotation 45.pdf differ diff --git a/src/UglyToad.PdfPig/Content/Letter.cs b/src/UglyToad.PdfPig/Content/Letter.cs index 9d998499..ef27d1b2 100644 --- a/src/UglyToad.PdfPig/Content/Letter.cs +++ b/src/UglyToad.PdfPig/Content/Letter.cs @@ -175,13 +175,12 @@ private TextOrientation GetTextOrientation() private TextOrientation GetTextOrientationRot() { double rotation = GlyphRectangle.Rotation; - int rotationInt = (int)Math.Round(rotation, MidpointRounding.AwayFromZero); - - if (Math.Abs(rotation - rotationInt) >= 10e-5) + if (Math.Abs(rotation % 90) >= 10e-5) { return TextOrientation.Other; - } + } + int rotationInt = (int)Math.Round(rotation, MidpointRounding.AwayFromZero); switch (rotationInt) { case 0: