Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using Content;

public class GithubIssuesTests
{
[Fact]
Expand All @@ -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);
}
}
}
}
Binary file not shown.
7 changes: 3 additions & 4 deletions src/UglyToad.PdfPig/Content/Letter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading