mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
rename TextDirection into TextOrientation
This commit is contained in:
@@ -196,7 +196,7 @@
|
||||
|
||||
private static IEnumerable<TextLine> GetLines(List<Word> words, double maxDist, AngleBounds withinLine, int maxDegreeOfParallelism)
|
||||
{
|
||||
TextDirection textDirection = words[0].TextDirection;
|
||||
TextOrientation TextOrientation = words[0].TextOrientation;
|
||||
var groupedIndexes = Clustering.NearestNeighbours(words, 2, Distances.Euclidean,
|
||||
(pivot, candidate) => maxDist,
|
||||
pivot => pivot.BoundingBox.BottomRight, candidate => candidate.BoundingBox.BottomLeft,
|
||||
@@ -205,15 +205,15 @@
|
||||
maxDegreeOfParallelism).ToList();
|
||||
|
||||
Func<IEnumerable<Word>, IReadOnlyList<Word>> orderFunc = l => l.OrderBy(x => x.BoundingBox.Left).ToList();
|
||||
if (textDirection == TextDirection.Rotate180)
|
||||
if (TextOrientation == TextOrientation.Rotate180)
|
||||
{
|
||||
orderFunc = l => l.OrderByDescending(x => x.BoundingBox.Right).ToList();
|
||||
}
|
||||
else if (textDirection == TextDirection.Rotate90)
|
||||
else if (TextOrientation == TextOrientation.Rotate90)
|
||||
{
|
||||
orderFunc = l => l.OrderByDescending(x => x.BoundingBox.Top).ToList();
|
||||
}
|
||||
else if (textDirection == TextDirection.Rotate270)
|
||||
else if (TextOrientation == TextOrientation.Rotate270)
|
||||
{
|
||||
orderFunc = l => l.OrderBy(x => x.BoundingBox.Bottom).ToList();
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
public string Text { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The text direction of the block.
|
||||
/// The text orientation of the block.
|
||||
/// </summary>
|
||||
public TextDirection TextDirection { get; }
|
||||
public TextOrientation TextOrientation { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The rectangle completely containing the block.
|
||||
@@ -64,7 +64,7 @@
|
||||
var maxY = lines.Max(x => x.BoundingBox.Top);
|
||||
BoundingBox = new PdfRectangle(minX, minY, maxX, maxY);
|
||||
|
||||
TextDirection = lines[0].TextDirection;
|
||||
TextOrientation = lines[0].TextOrientation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
public string Text { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The text direction of the line.
|
||||
/// The text orientation of the line.
|
||||
/// </summary>
|
||||
public TextDirection TextDirection { get; }
|
||||
public TextOrientation TextOrientation { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The rectangle completely containing the line.
|
||||
@@ -59,13 +59,13 @@
|
||||
|
||||
BoundingBox = new PdfRectangle(minX, minY, maxX, maxY);
|
||||
|
||||
if (words.All(x => x.TextDirection == words[0].TextDirection))
|
||||
if (words.All(x => x.TextOrientation == words[0].TextOrientation))
|
||||
{
|
||||
TextDirection = words[0].TextDirection;
|
||||
TextOrientation = words[0].TextOrientation;
|
||||
}
|
||||
else
|
||||
{
|
||||
TextDirection = TextDirection.Other;
|
||||
TextOrientation = TextOrientation.Other;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,14 +47,14 @@
|
||||
}
|
||||
|
||||
List<Word> wordsH = GetWords(
|
||||
letters.Where(l => l.TextDirection == TextDirection.Horizontal).ToList(),
|
||||
letters.Where(l => l.TextOrientation == TextOrientation.Horizontal).ToList(),
|
||||
(l1, l2) => maxDistFunc(l1, l2),
|
||||
Distances.Manhattan, filterFunc, MaxDegreeOfParallelism)
|
||||
.OrderByDescending(x => x.BoundingBox.Bottom)
|
||||
.ThenBy(x => x.BoundingBox.Left).ToList();
|
||||
|
||||
var words270 = GetWords(
|
||||
letters.Where(l => l.TextDirection == TextDirection.Rotate270).ToList(),
|
||||
letters.Where(l => l.TextOrientation == TextOrientation.Rotate270).ToList(),
|
||||
(l1, l2) => maxDistFunc(l1, l2),
|
||||
Distances.Manhattan, filterFunc, MaxDegreeOfParallelism)
|
||||
.OrderBy(x => x.BoundingBox.Right)
|
||||
@@ -62,7 +62,7 @@
|
||||
wordsH.AddRange(words270);
|
||||
|
||||
var words180 = GetWords(
|
||||
letters.Where(l => l.TextDirection == TextDirection.Rotate180).ToList(),
|
||||
letters.Where(l => l.TextOrientation == TextOrientation.Rotate180).ToList(),
|
||||
(l1, l2) => maxDistFunc(l1, l2),
|
||||
Distances.Manhattan, filterFunc, MaxDegreeOfParallelism)
|
||||
.OrderBy(x => x.BoundingBox.Top)
|
||||
@@ -70,7 +70,7 @@
|
||||
wordsH.AddRange(words180);
|
||||
|
||||
var words90 = GetWords(
|
||||
letters.Where(l => l.TextDirection == TextDirection.Rotate90).ToList(),
|
||||
letters.Where(l => l.TextOrientation == TextOrientation.Rotate90).ToList(),
|
||||
(l1, l2) => maxDistFunc(l1, l2),
|
||||
Distances.Manhattan, filterFunc, MaxDegreeOfParallelism)
|
||||
.OrderByDescending(x => x.BoundingBox.Left)
|
||||
@@ -78,7 +78,7 @@
|
||||
wordsH.AddRange(words90);
|
||||
|
||||
var wordsU = GetWords(
|
||||
letters.Where(l => l.TextDirection == TextDirection.Other).ToList(),
|
||||
letters.Where(l => l.TextOrientation == TextOrientation.Other).ToList(),
|
||||
(l1, l2) => maxDistFunc(l1, l2) * 2.0, // allow twice the distance for oriented text
|
||||
Distances.Euclidean, filterFunc, MaxDegreeOfParallelism)
|
||||
.OrderByDescending(x => x.BoundingBox.Bottom)
|
||||
|
||||
Reference in New Issue
Block a user