Minor modifications and updates

This commit is contained in:
BobLd
2019-05-14 20:56:34 +01:00
parent de421d65a1
commit 97f0f6fe75
3 changed files with 30 additions and 16 deletions

View File

@@ -1,15 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
using UglyToad.PdfPig.Geometry;
using System.Linq;
using UglyToad.PdfPig.Geometry;
namespace UglyToad.PdfPig.Content
{
/// <summary>
/// A line.
/// A line of text.
/// </summary>
public class Line
public class TextLine
{
/// <summary>
/// The text of the line.
@@ -32,10 +31,10 @@ namespace UglyToad.PdfPig.Content
public IReadOnlyList<Word> Words { get; }
/// <summary>
/// Create a new <see cref="Word"/>.
/// Create a new <see cref="TextLine"/>.
/// </summary>
/// <param name="words">The letters contained in the word.</param>
public Line(IReadOnlyList<Word> words)
/// <param name="words">The words contained in the word.</param>
public TextLine(IReadOnlyList<Word> words)
{
if (words == null)
{
@@ -57,7 +56,14 @@ namespace UglyToad.PdfPig.Content
var maxY = words.Max(x => x.BoundingBox.Top);
BoundingBox = new PdfRectangle(minX, minY, maxX, maxY);
TextDirection = words[0].TextDirection;
if (words.All(x => x.TextDirection == words[0].TextDirection))
{
TextDirection = words[0].TextDirection;
}
else
{
TextDirection = TextDirection.Unknown;
}
}
/// <inheritdoc />

View File

@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace UglyToad.PdfPig.Geometry
namespace UglyToad.PdfPig.Geometry
{
/// <summary>
/// A line in a PDF file.
@@ -14,6 +10,18 @@ namespace UglyToad.PdfPig.Geometry
/// </remarks>
public struct PdfLine
{
/// <summary>
/// Length of the line.
/// </summary>
public decimal Length
{
get
{
decimal l = (Point1.X - Point1.X) * (Point1.X - Point1.X) + (Point1.Y - Point1.Y) * (Point1.Y - Point1.Y);
return (decimal)System.Math.Sqrt((double)l);
}
}
/// <summary>
/// First point of the line.
/// </summary>
@@ -25,7 +33,7 @@ namespace UglyToad.PdfPig.Geometry
public PdfPoint Point2 { get; }
/// <summary>
/// A line in a PDF file.
/// Create a new <see cref="PdfLine"/>.
/// </summary>
/// <param name="x1"></param>
/// <param name="y1"></param>
@@ -34,7 +42,7 @@ namespace UglyToad.PdfPig.Geometry
public PdfLine(decimal x1, decimal y1, decimal x2, decimal y2) : this(new PdfPoint(x1, y1), new PdfPoint(x2, y2)) { }
/// <summary>
/// A line in a PDF file.
/// Create a new <see cref="PdfLine"/>.
/// </summary>
/// <param name="point1">First point of the line.</param>
/// <param name="point2">Second point of the line.</param>

View File

@@ -69,7 +69,7 @@
internal PdfRectangle(short x1, short y1, short x2, short y2) : this((decimal) x1, y1, x2, y2) { }
/// <summary>
/// A rectangle in a PDF file.
/// Create a new <see cref="PdfRectangle"/>.
/// </summary>
/// <param name="x1"></param>
/// <param name="y1"></param>