diff --git a/src/UglyToad.PdfPig/Content/Line.cs b/src/UglyToad.PdfPig/Content/Line.cs index a40f9c56..16f69823 100644 --- a/src/UglyToad.PdfPig/Content/Line.cs +++ b/src/UglyToad.PdfPig/Content/Line.cs @@ -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 { /// - /// A line. + /// A line of text. /// - public class Line + public class TextLine { /// /// The text of the line. @@ -32,10 +31,10 @@ namespace UglyToad.PdfPig.Content public IReadOnlyList Words { get; } /// - /// Create a new . + /// Create a new . /// - /// The letters contained in the word. - public Line(IReadOnlyList words) + /// The words contained in the word. + public TextLine(IReadOnlyList 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; + } } /// diff --git a/src/UglyToad.PdfPig/Geometry/PdfLine.cs b/src/UglyToad.PdfPig/Geometry/PdfLine.cs index 0fd57084..0b8bdb6f 100644 --- a/src/UglyToad.PdfPig/Geometry/PdfLine.cs +++ b/src/UglyToad.PdfPig/Geometry/PdfLine.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace UglyToad.PdfPig.Geometry +namespace UglyToad.PdfPig.Geometry { /// /// A line in a PDF file. @@ -14,6 +10,18 @@ namespace UglyToad.PdfPig.Geometry /// public struct PdfLine { + /// + /// Length of the line. + /// + 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); + } + } + /// /// First point of the line. /// @@ -25,7 +33,7 @@ namespace UglyToad.PdfPig.Geometry public PdfPoint Point2 { get; } /// - /// A line in a PDF file. + /// Create a new . /// /// /// @@ -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)) { } /// - /// A line in a PDF file. + /// Create a new . /// /// First point of the line. /// Second point of the line. diff --git a/src/UglyToad.PdfPig/Geometry/PdfRectangle.cs b/src/UglyToad.PdfPig/Geometry/PdfRectangle.cs index 77457202..aabfc1b8 100644 --- a/src/UglyToad.PdfPig/Geometry/PdfRectangle.cs +++ b/src/UglyToad.PdfPig/Geometry/PdfRectangle.cs @@ -69,7 +69,7 @@ internal PdfRectangle(short x1, short y1, short x2, short y2) : this((decimal) x1, y1, x2, y2) { } /// - /// A rectangle in a PDF file. + /// Create a new . /// /// ///