mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
Fix GetTextOrientation by cleanly checking if rotation is divisible by 90 and fix #913
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
namespace UglyToad.PdfPig.Tests.Integration
|
||||
{
|
||||
using Content;
|
||||
|
||||
public class GithubIssuesTests
|
||||
{
|
||||
[Fact]
|
||||
@@ -22,5 +24,32 @@
|
||||
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.
@@ -175,13 +175,12 @@
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user