ReadingOrderDetector and tidying DLA project

This commit is contained in:
BobLd
2020-01-10 18:08:33 +00:00
committed by Eliot Jones
parent b4d917dcdc
commit e7417be75a
20 changed files with 606 additions and 49 deletions

View File

@@ -1,10 +1,10 @@
namespace UglyToad.PdfPig.DocumentLayoutAnalysis
{
using Content;
using Core;
using System;
using System.Collections.Generic;
using System.Linq;
using Content;
using Core;
/// <summary>
/// A block of text.
@@ -31,6 +31,11 @@
/// </summary>
public IReadOnlyList<TextLine> TextLines { get; }
/// <summary>
/// The reading order index. Starts at 0. A value of -1 means the block is not ordered.
/// </summary>
public int ReadingOrder { get; private set; }
/// <summary>
/// Create a new <see cref="TextBlock"/>.
/// </summary>
@@ -47,6 +52,8 @@
throw new ArgumentException("Empty lines provided.", nameof(lines));
}
ReadingOrder = -1;
TextLines = lines;
Text = string.Join(" ", lines.Select(x => x.Text));
@@ -60,6 +67,15 @@
TextDirection = lines[0].TextDirection;
}
internal void SetReadingOrder(int readingOrder)
{
if (readingOrder < -1)
{
throw new ArgumentException("The reading order should be more or equal to -1. A value of -1 means the block is not ordered.", nameof(readingOrder));
}
this.ReadingOrder = readingOrder;
}
/// <inheritdoc />
public override string ToString()
{