From 5c8a77bf33c71d1cd97aded46f044bfc3ae62024 Mon Sep 17 00:00:00 2001 From: Eliot Jones Date: Thu, 3 Jan 2019 22:20:53 +0000 Subject: [PATCH] #26 make almost all operators public --- .../Operations/General/SetMiterLimitTests.cs | 3 +- .../SpecialGraphicsState/PopTests.cs | 7 +- .../SpecialGraphicsState/PushTests.cs | 3 +- .../TextState/SetFontAndSizeTests.cs | 3 +- .../Graphics/TestOperationContext.cs | 2 +- .../Parser/PageContentParserTests.cs | 4 +- .../PublicApiScannerTests.cs | 78 ++++++++++-- .../Core/TransformationMatrix.cs | 115 +++++++++++++++--- src/UglyToad.PdfPig/Geometry/PdfPath.cs | 29 +++-- .../Graphics/ContentStreamProcessor.cs | 6 +- .../Graphics/Core/LineCapStyle.cs | 14 ++- .../Graphics/Core/LineDashPattern.cs | 35 +++++- .../Graphics/Core/LineJoinStyle.cs | 16 ++- .../Graphics/Core/RenderingIntent.cs | 5 +- .../Graphics/Core/RenderingModeExtensions.cs | 30 ++--- ...{RenderingMode.cs => TextRenderingMode.cs} | 6 +- .../Graphics/CurrentFontState.cs | 17 ++- .../Graphics/CurrentGraphicsState.cs | 8 +- .../Graphics/IOperationContext.cs | 52 +++++++- .../ModifyClippingByEvenOddIntersect.cs | 23 +++- ...ModifyClippingByNonZeroWindingIntersect.cs | 23 +++- .../Graphics/Operations/CloseAndStrokePath.cs | 6 +- .../CloseFillPathEvenOddRuleAndStroke.cs | 6 +- .../CloseFillPathNonZeroWindingAndStroke.cs | 6 +- .../Graphics/Operations/EndPath.cs | 6 +- .../Operations/FillPathEvenOddRule.cs | 6 +- .../FillPathEvenOddRuleAndStroke.cs | 4 +- .../Operations/FillPathNonZeroWinding.cs | 6 +- .../FillPathNonZeroWindingAndStroke.cs | 6 +- .../FillPathNonZeroWindingCompatibility.cs | 6 +- .../General/SetColorRenderingIntent.cs | 40 +++++- .../General/SetFlatnessTolerance.cs | 29 ++++- .../Graphics/Operations/General/SetLineCap.cs | 32 +++-- .../Operations/General/SetLineDashPattern.cs | 47 ++++++- .../Operations/General/SetLineJoin.cs | 27 ++-- .../Operations/General/SetLineWidth.cs | 28 +++-- .../Operations/General/SetMiterLimit.cs | 27 +++- .../Operations/IGraphicsStateOperation.cs | 21 +++- .../Graphics/Operations/InvokeNamedXObject.cs | 15 ++- .../AppendDualControlPointBezierCurve.cs | 37 +++++- .../AppendEndControlPointBezierCurve.cs | 30 ++++- .../PathConstruction/AppendRectangle.cs | 32 ++++- .../AppendStartControlPointBezierCurve.cs | 30 ++++- .../AppendStraightLineSegment.cs | 24 +++- .../PathConstruction/BeginNewSubpath.cs | 24 +++- .../PathConstruction/CloseSubpath.cs | 20 ++- .../Operations/SetNonStrokeColorDeviceCmyk.cs | 6 +- .../Operations/SetNonStrokeColorDeviceGray.cs | 4 +- .../Operations/SetNonStrokeColorDeviceRgb.cs | 6 +- .../Operations/SetStrokeColorDeviceCmyk.cs | 4 +- .../Operations/SetStrokeColorDeviceGray.cs | 4 +- .../Operations/SetStrokeColorDeviceRgb.cs | 6 +- .../ModifyCurrentTransformationMatrix.cs | 20 ++- .../Operations/SpecialGraphicsState/Pop.cs | 18 ++- .../Operations/SpecialGraphicsState/Push.cs | 17 ++- .../Graphics/Operations/StrokePath.cs | 19 ++- .../Operations/TextObjects/BeginText.cs | 17 ++- .../Operations/TextObjects/EndText.cs | 17 ++- .../TextPositioning/MoveToNextLine.cs | 19 ++- .../MoveToNextLineWithOffset.cs | 26 +++- .../MoveToNextLineWithOffsetSetLeading.cs | 15 ++- .../TextPositioning/SetTextMatrix.cs | 13 +- .../TextShowing/MoveToNextLineShowText.cs | 10 +- .../MoveToNextLineShowTextWithSpacing.cs | 48 ++++++-- .../Operations/TextShowing/ShowText.cs | 31 ++++- .../TextShowing/ShowTextsWithPositioning.cs | 23 +++- .../TextState/SetCharacterSpacing.cs | 25 ++-- .../Operations/TextState/SetFontAndSize.cs | 30 +++-- .../TextState/SetHorizontalScaling.cs | 24 +++- .../Operations/TextState/SetTextLeading.cs | 25 +++- .../TextState/SetTextRenderingMode.cs | 30 +++-- .../Operations/TextState/SetTextRise.cs | 6 +- .../Operations/TextState/SetWordSpacing.cs | 5 +- src/UglyToad.PdfPig/Graphics/TextMatrices.cs | 11 +- src/UglyToad.PdfPig/IO/IInputBytes.cs | 27 +++- 75 files changed, 1196 insertions(+), 304 deletions(-) rename src/UglyToad.PdfPig/Graphics/Core/{RenderingMode.cs => TextRenderingMode.cs} (83%) diff --git a/src/UglyToad.PdfPig.Tests/Graphics/Operations/General/SetMiterLimitTests.cs b/src/UglyToad.PdfPig.Tests/Graphics/Operations/General/SetMiterLimitTests.cs index 45beabce..2ea23419 100644 --- a/src/UglyToad.PdfPig.Tests/Graphics/Operations/General/SetMiterLimitTests.cs +++ b/src/UglyToad.PdfPig.Tests/Graphics/Operations/General/SetMiterLimitTests.cs @@ -5,7 +5,6 @@ public class SetMiterLimitTests { - private readonly TestResourceStore resourceStore = new TestResourceStore(); private readonly TestOperationContext context = new TestOperationContext(); [Fact] @@ -13,7 +12,7 @@ { var limit = new SetMiterLimit(25); - limit.Run(context, resourceStore); + limit.Run(context); Assert.Equal(25, context.GetCurrentState().MiterLimit); } diff --git a/src/UglyToad.PdfPig.Tests/Graphics/Operations/SpecialGraphicsState/PopTests.cs b/src/UglyToad.PdfPig.Tests/Graphics/Operations/SpecialGraphicsState/PopTests.cs index 78ac0716..237a0431 100644 --- a/src/UglyToad.PdfPig.Tests/Graphics/Operations/SpecialGraphicsState/PopTests.cs +++ b/src/UglyToad.PdfPig.Tests/Graphics/Operations/SpecialGraphicsState/PopTests.cs @@ -7,7 +7,6 @@ public class PopTests { - private readonly TestResourceStore resourceStore = new TestResourceStore(); private readonly TestOperationContext context = new TestOperationContext(); [Fact] @@ -20,7 +19,7 @@ [Fact] public void CannotPopWithSingleFrame() { - Action action = () => Pop.Value.Run(context, resourceStore); + Action action = () => Pop.Value.Run(context); Assert.Throws(action); } @@ -30,7 +29,7 @@ { context.StateStack.Pop(); - Action action = () => Pop.Value.Run(context, resourceStore); + Action action = () => Pop.Value.Run(context); Assert.Throws(action); } @@ -43,7 +42,7 @@ LineWidth = 23 }); - Pop.Value.Run(context, resourceStore); + Pop.Value.Run(context); Assert.Equal(1, context.StackSize); Assert.Equal(1, context.GetCurrentState().LineWidth); diff --git a/src/UglyToad.PdfPig.Tests/Graphics/Operations/SpecialGraphicsState/PushTests.cs b/src/UglyToad.PdfPig.Tests/Graphics/Operations/SpecialGraphicsState/PushTests.cs index c966600b..8d676424 100644 --- a/src/UglyToad.PdfPig.Tests/Graphics/Operations/SpecialGraphicsState/PushTests.cs +++ b/src/UglyToad.PdfPig.Tests/Graphics/Operations/SpecialGraphicsState/PushTests.cs @@ -5,7 +5,6 @@ public class PushTests { - private readonly TestResourceStore resourceStore = new TestResourceStore(); private readonly TestOperationContext context = new TestOperationContext(); [Fact] @@ -18,7 +17,7 @@ [Fact] public void PushAddsToStack() { - Push.Value.Run(context, resourceStore); + Push.Value.Run(context); Assert.Equal(2, context.StackSize); } diff --git a/src/UglyToad.PdfPig.Tests/Graphics/Operations/TextState/SetFontAndSizeTests.cs b/src/UglyToad.PdfPig.Tests/Graphics/Operations/TextState/SetFontAndSizeTests.cs index aca30b5a..974d5e65 100644 --- a/src/UglyToad.PdfPig.Tests/Graphics/Operations/TextState/SetFontAndSizeTests.cs +++ b/src/UglyToad.PdfPig.Tests/Graphics/Operations/TextState/SetFontAndSizeTests.cs @@ -57,9 +57,8 @@ var setFontAndSize = new SetFontAndSize(Font1Name, 69.42m); var context = new TestOperationContext(); - var store = new TestResourceStore(); - setFontAndSize.Run(context, store); + setFontAndSize.Run(context); var state = context.GetCurrentState(); diff --git a/src/UglyToad.PdfPig.Tests/Graphics/TestOperationContext.cs b/src/UglyToad.PdfPig.Tests/Graphics/TestOperationContext.cs index 3008f97f..f092e6f4 100644 --- a/src/UglyToad.PdfPig.Tests/Graphics/TestOperationContext.cs +++ b/src/UglyToad.PdfPig.Tests/Graphics/TestOperationContext.cs @@ -51,7 +51,7 @@ { } - public void ApplyXObject(StreamToken xObjectStream) + public void ApplyXObject(NameToken xObjectName) { } diff --git a/src/UglyToad.PdfPig.Tests/Parser/PageContentParserTests.cs b/src/UglyToad.PdfPig.Tests/Parser/PageContentParserTests.cs index fce173e5..5cd05ebb 100644 --- a/src/UglyToad.PdfPig.Tests/Parser/PageContentParserTests.cs +++ b/src/UglyToad.PdfPig.Tests/Parser/PageContentParserTests.cs @@ -56,7 +56,7 @@ ET"; Assert.Equal(38, nextLine.Ty); var renderingMode = Assert.IsType(result[3]); - Assert.Equal(RenderingMode.Stroke, renderingMode.Mode); + Assert.Equal(TextRenderingMode.Stroke, renderingMode.Mode); var lineWidth = Assert.IsType(result[4]); Assert.Equal(2, lineWidth.Width); @@ -88,7 +88,7 @@ ET"; Assert.Equal(32, moveLine.Ty); var renderingMode = Assert.IsType(result[2]); - Assert.Equal(RenderingMode.Fill, renderingMode.Mode); + Assert.Equal(TextRenderingMode.Fill, renderingMode.Mode); Assert.Equal(EndText.Value, result[3]); } diff --git a/src/UglyToad.PdfPig.Tests/PublicApiScannerTests.cs b/src/UglyToad.PdfPig.Tests/PublicApiScannerTests.cs index f57f535b..eaeab994 100644 --- a/src/UglyToad.PdfPig.Tests/PublicApiScannerTests.cs +++ b/src/UglyToad.PdfPig.Tests/PublicApiScannerTests.cs @@ -24,33 +24,89 @@ var expected = new List { - "UglyToad.PdfPig.IndirectReference", - "UglyToad.PdfPig.PdfDocument", - "UglyToad.PdfPig.ParsingOptions", - "UglyToad.PdfPig.Structure", "UglyToad.PdfPig.Annotations.Annotation", - "UglyToad.PdfPig.Annotations.AnnotationType", "UglyToad.PdfPig.Annotations.AnnotationBorder", "UglyToad.PdfPig.Annotations.AnnotationFlags", - "UglyToad.PdfPig.Logging.ILog", - "UglyToad.PdfPig.Geometry.PdfPoint", - "UglyToad.PdfPig.Geometry.PdfRectangle", - "UglyToad.PdfPig.Fonts.Exceptions.InvalidFontFormatException", - "UglyToad.PdfPig.Exceptions.PdfDocumentFormatException", + "UglyToad.PdfPig.Annotations.AnnotationType", "UglyToad.PdfPig.Content.Catalog", "UglyToad.PdfPig.Content.DocumentInformation", "UglyToad.PdfPig.Content.Letter", "UglyToad.PdfPig.Content.Page", "UglyToad.PdfPig.Content.PageSize", "UglyToad.PdfPig.Content.Word", + "UglyToad.PdfPig.Core.TransformationMatrix", "UglyToad.PdfPig.CrossReference.CrossReferenceTable", "UglyToad.PdfPig.CrossReference.CrossReferenceType", "UglyToad.PdfPig.CrossReference.TrailerDictionary", + "UglyToad.PdfPig.Exceptions.PdfDocumentFormatException", "UglyToad.PdfPig.Fonts.DescriptorFontFile", + "UglyToad.PdfPig.Fonts.Exceptions.InvalidFontFormatException", "UglyToad.PdfPig.Fonts.FontDescriptor", "UglyToad.PdfPig.Fonts.FontDescriptorFlags", "UglyToad.PdfPig.Fonts.FontStretch", "UglyToad.PdfPig.Fonts.Standard14Font", + "UglyToad.PdfPig.Geometry.PdfPath", + "UglyToad.PdfPig.Geometry.PdfPoint", + "UglyToad.PdfPig.Geometry.PdfRectangle", + "UglyToad.PdfPig.Graphics.Core.LineCapStyle", + "UglyToad.PdfPig.Graphics.Core.LineDashPattern", + "UglyToad.PdfPig.Graphics.Core.LineJoinStyle", + "UglyToad.PdfPig.Graphics.Core.RenderingIntent", + "UglyToad.PdfPig.Graphics.Core.TextRenderingMode", + "UglyToad.PdfPig.Graphics.CurrentFontState", + "UglyToad.PdfPig.Graphics.CurrentGraphicsState", + "UglyToad.PdfPig.Graphics.IOperationContext", + "UglyToad.PdfPig.Graphics.Operations.ClippingPaths.ModifyClippingByEvenOddIntersect", + "UglyToad.PdfPig.Graphics.Operations.ClippingPaths.ModifyClippingByNonZeroWindingIntersect", + "UglyToad.PdfPig.Graphics.Operations.CloseAndStrokePath", + "UglyToad.PdfPig.Graphics.Operations.EndPath", + "UglyToad.PdfPig.Graphics.Operations.FillPathEvenOddRule", + "UglyToad.PdfPig.Graphics.Operations.FillPathNonZeroWinding", + "UglyToad.PdfPig.Graphics.Operations.FillPathNonZeroWindingAndStroke", + "UglyToad.PdfPig.Graphics.Operations.FillPathNonZeroWindingCompatibility", + "UglyToad.PdfPig.Graphics.Operations.General.SetColorRenderingIntent", + "UglyToad.PdfPig.Graphics.Operations.General.SetFlatnessTolerance", + "UglyToad.PdfPig.Graphics.Operations.General.SetLineCap", + "UglyToad.PdfPig.Graphics.Operations.General.SetLineDashPattern", + "UglyToad.PdfPig.Graphics.Operations.General.SetLineJoin", + "UglyToad.PdfPig.Graphics.Operations.General.SetLineWidth", + "UglyToad.PdfPig.Graphics.Operations.General.SetMiterLimit", + "UglyToad.PdfPig.Graphics.Operations.IGraphicsStateOperation", + "UglyToad.PdfPig.Graphics.Operations.InvokeNamedXObject", + "UglyToad.PdfPig.Graphics.Operations.PathConstruction.AppendDualControlPointBezierCurve", + "UglyToad.PdfPig.Graphics.Operations.PathConstruction.AppendEndControlPointBezierCurve", + "UglyToad.PdfPig.Graphics.Operations.PathConstruction.AppendRectangle", + "UglyToad.PdfPig.Graphics.Operations.PathConstruction.AppendStartControlPointBezierCurve", + "UglyToad.PdfPig.Graphics.Operations.PathConstruction.AppendStraightLineSegment", + "UglyToad.PdfPig.Graphics.Operations.PathConstruction.BeginNewSubpath", + "UglyToad.PdfPig.Graphics.Operations.PathConstruction.CloseSubpath", + "UglyToad.PdfPig.Graphics.Operations.SetNonStrokeColorDeviceCmyk", + "UglyToad.PdfPig.Graphics.Operations.SetNonStrokeColorDeviceRgb", + "UglyToad.PdfPig.Graphics.Operations.SetStrokeColorDeviceRgb", + "UglyToad.PdfPig.Graphics.Operations.SpecialGraphicsState.ModifyCurrentTransformationMatrix", + "UglyToad.PdfPig.Graphics.Operations.SpecialGraphicsState.Pop", + "UglyToad.PdfPig.Graphics.Operations.SpecialGraphicsState.Push", + "UglyToad.PdfPig.Graphics.Operations.StrokePath", + "UglyToad.PdfPig.Graphics.Operations.TextObjects.BeginText", + "UglyToad.PdfPig.Graphics.Operations.TextObjects.EndText", + "UglyToad.PdfPig.Graphics.Operations.TextPositioning.MoveToNextLine", + "UglyToad.PdfPig.Graphics.Operations.TextShowing.MoveToNextLineShowText", + "UglyToad.PdfPig.Graphics.Operations.TextShowing.MoveToNextLineShowTextWithSpacing", + "UglyToad.PdfPig.Graphics.Operations.TextShowing.ShowText", + "UglyToad.PdfPig.Graphics.Operations.TextState.SetCharacterSpacing", + "UglyToad.PdfPig.Graphics.Operations.TextState.SetFontAndSize", + "UglyToad.PdfPig.Graphics.Operations.TextState.SetHorizontalScaling", + "UglyToad.PdfPig.Graphics.Operations.TextState.SetTextLeading", + "UglyToad.PdfPig.Graphics.Operations.TextState.SetTextRenderingMode", + "UglyToad.PdfPig.Graphics.Operations.TextState.SetTextRise", + "UglyToad.PdfPig.Graphics.Operations.TextState.SetWordSpacing", + "UglyToad.PdfPig.Graphics.TextMatrices", + "UglyToad.PdfPig.IndirectReference", + "UglyToad.PdfPig.IO.IInputBytes", + "UglyToad.PdfPig.Logging.ILog", + "UglyToad.PdfPig.ParsingOptions", + "UglyToad.PdfPig.PdfDocument", + "UglyToad.PdfPig.Structure", "UglyToad.PdfPig.Tokens.ArrayToken", "UglyToad.PdfPig.Tokens.BooleanToken", "UglyToad.PdfPig.Tokens.CommentToken", @@ -71,7 +127,7 @@ "UglyToad.PdfPig.Writer.TokenWriter", "UglyToad.PdfPig.XObjects.XObjectImage" }; - + foreach (var publicTypeName in publicTypeNames) { Assert.True(expected.Contains(publicTypeName), $"Type should not be public: {publicTypeName}."); diff --git a/src/UglyToad.PdfPig/Core/TransformationMatrix.cs b/src/UglyToad.PdfPig/Core/TransformationMatrix.cs index bd3cab85..8579d237 100644 --- a/src/UglyToad.PdfPig/Core/TransformationMatrix.cs +++ b/src/UglyToad.PdfPig/Core/TransformationMatrix.cs @@ -8,8 +8,11 @@ /// /// Specifies the conversion from the transformed coordinate space to the original untransformed coordinate space. /// - internal struct TransformationMatrix + public struct TransformationMatrix { + /// + /// The default . + /// public static TransformationMatrix Identity = new TransformationMatrix(new decimal[] { 1,0,0, @@ -23,37 +26,52 @@ /// The scale for the X dimension. /// public decimal A => value[0]; + /// + /// The value at (0, 1). + /// public decimal B => value[1]; + /// + /// The value at (1, 0). + /// public decimal C => value[3]; /// /// The scale for the Y dimension. /// public decimal D => value[4]; + /// + /// The value at (2, 0) - translation in X. + /// public decimal E => value[6]; + /// + /// The value at (2, 1) - translation in Y. + /// public decimal F => value[7]; + /// + /// Get the value at the specific row and column. + /// public decimal this[int row, int col] { get { if (row >= Rows) { - throw new ArgumentOutOfRangeException($"The transformation matrix only contains {Rows} rows and is zero indexed, you tried to access row {row}."); + throw new ArgumentOutOfRangeException(nameof(row), $"The transformation matrix only contains {Rows} rows and is zero indexed, you tried to access row {row}."); } if (row < 0) { - throw new ArgumentOutOfRangeException("Cannot access negative rows in a matrix."); + throw new ArgumentOutOfRangeException(nameof(row), "Cannot access negative rows in a matrix."); } if (col >= Columns) { - throw new ArgumentOutOfRangeException($"The transformation matrix only contains {Columns} columns and is zero indexed, you tried to access column {col}."); + throw new ArgumentOutOfRangeException(nameof(col), $"The transformation matrix only contains {Columns} columns and is zero indexed, you tried to access column {col}."); } if (col < 0) { - throw new ArgumentOutOfRangeException("Cannot access negative columns in a matrix."); + throw new ArgumentOutOfRangeException(nameof(col), "Cannot access negative columns in a matrix."); } var resultIndex = row * Rows + col; @@ -67,9 +85,19 @@ } } + /// + /// The number of rows in the matrix. + /// public const int Rows = 3; + /// + /// The number of columns in the matrix. + /// public const int Columns = 3; + /// + /// Create a new . + /// + /// The 9 values of the matrix. public TransformationMatrix(decimal[] value) { if (value == null) @@ -85,6 +113,12 @@ this.value = value; } + /// + /// Transform a point using this transformation matrix. + /// + /// The original point. + /// A new point which is the result of applying this transformation matrix. + [Pure] public PdfPoint Transform(PdfPoint original) { var x = A * original.X + C * original.Y + E; @@ -93,16 +127,26 @@ return new PdfPoint(x, y); } + /// + /// Transform an X coordinate using this transformation matrix. + /// + /// The X coordinate. + /// The transformed X coordinate. [Pure] - public decimal TransformX(decimal x) + internal decimal TransformX(decimal x) { var xt = A * x + C * 0 + E; return xt; } + /// + /// Transform a vector using this transformation matrix. + /// + /// The original vector. + /// A new vector which is the result of applying this transformation matrix. [Pure] - public PdfVector Transform(PdfVector original) + internal PdfVector Transform(PdfVector original) { var x = A * original.X + C * original.Y + E; var y = B * original.X + D * original.Y + F; @@ -110,6 +154,11 @@ return new PdfVector(x, y); } + /// + /// Transform a rectangle using this transformation matrix. + /// + /// The original rectangle. + /// A new rectangle which is the result of applying this transformation matrix. [Pure] public PdfRectangle Transform(PdfRectangle original) { @@ -121,8 +170,17 @@ ); } + /// + /// Create a new from the 6 values provided in the default PDF order. + /// public static TransformationMatrix FromValues(decimal a, decimal b, decimal c, decimal d, decimal e, decimal f) => FromArray(new[] {a, b, c, d, e, f}); + + /// + /// Create a new from the values. + /// + /// Either all 9 values of the matrix, 6 values in the default PDF order or the 4 values of the top left square. + /// public static TransformationMatrix FromArray(decimal[] values) { if (values.Length == 9) @@ -153,19 +211,25 @@ throw new ArgumentException("The array must either define all 9 elements of the matrix or all 6 key elements. Instead array was: " + values); } + /// + /// Multiplies one transformation matrix by another without modifying either matrix. Order is: (this * matrix). + /// + /// The matrix to multiply + /// The resulting matrix. + [Pure] public TransformationMatrix Multiply(TransformationMatrix matrix) { var result = new decimal[9]; - for (int i = 0; i < Rows; i++) + for (var i = 0; i < Rows; i++) { var rowIndexPart = i * Rows; - for (int j = 0; j < Columns; j++) + for (var j = 0; j < Columns; j++) { var index = rowIndexPart + j; - for (int x = 0; x < Rows; x++) + for (var x = 0; x < Rows; x++) { result[index] += this[i, x] * matrix[x, j]; } @@ -175,17 +239,23 @@ return new TransformationMatrix(result); } + /// + /// Multiplies the matrix by a scalar value without modifying this matrix. + /// + /// The value to multiply. + /// A new matrix which is multiplied by the scalar value. + [Pure] public TransformationMatrix Multiply(decimal scalar) { var result = new decimal[9]; - for (int i = 0; i < Rows; i++) + for (var i = 0; i < Rows; i++) { - for (int j = 0; j < Columns; j++) + for (var j = 0; j < Columns; j++) { var index = (i * Rows) + j; - for (int x = 0; x < Rows; x++) + for (var x = 0; x < Rows; x++) { result[index] += this[i, x] * scalar; } @@ -195,7 +265,11 @@ return new TransformationMatrix(result); } - public decimal GetScalingFactorX() + /// + /// Get the X scaling component of the current matrix. + /// + /// + internal decimal GetScalingFactorX() { var xScale = A; @@ -224,6 +298,7 @@ return xScale; } + /// public override bool Equals(object obj) { if (!(obj is TransformationMatrix m)) @@ -234,11 +309,14 @@ return Equals(this, m); } + /// + /// Determines whether 2 transformation matrices are equal. + /// public static bool Equals(TransformationMatrix a, TransformationMatrix b) { - for (int i = 0; i < Rows; i++) + for (var i = 0; i < Rows; i++) { - for (int j = 0; j < Columns; j++) + for (var j = 0; j < Columns; j++) { if (a[i, j] != b[i, j]) { @@ -250,6 +328,7 @@ return true; } + /// public override int GetHashCode() { var hashCode = 1113510858; @@ -258,11 +337,15 @@ return hashCode; } + /// public override string ToString() { return $"{A}, {B}, 0\r\n{C}, {D}, 0\r\n{E}, {F}, 1"; } + /// + /// Create a new with the X and Y translation values set. + /// public static TransformationMatrix GetTranslationMatrix(decimal x, decimal y) { return new TransformationMatrix(new [] diff --git a/src/UglyToad.PdfPig/Geometry/PdfPath.cs b/src/UglyToad.PdfPig/Geometry/PdfPath.cs index b53aa36b..d5a06cd7 100644 --- a/src/UglyToad.PdfPig/Geometry/PdfPath.cs +++ b/src/UglyToad.PdfPig/Geometry/PdfPath.cs @@ -6,18 +6,21 @@ namespace UglyToad.PdfPig.Geometry using System.Linq; using System.Text; - internal class PdfPath + /// + /// A path in a PDF document, used by glyphs and page content. + /// + public class PdfPath { private readonly List commands = new List(); private PdfPoint? currentPosition; - public void MoveTo(decimal x, decimal y) + internal void MoveTo(decimal x, decimal y) { currentPosition = new PdfPoint(x, y); commands.Add(new Move(currentPosition.Value)); } - public void LineTo(decimal x, decimal y) + internal void LineTo(decimal x, decimal y) { if (currentPosition.HasValue) { @@ -31,9 +34,9 @@ namespace UglyToad.PdfPig.Geometry } } - public void QuadraticCurveTo(decimal x1, decimal y1, decimal x2, decimal y2) { } + internal void QuadraticCurveTo(decimal x1, decimal y1, decimal x2, decimal y2) { } - public void BezierCurveTo(decimal x1, decimal y1, decimal x2, decimal y2, decimal x3, decimal y3) + internal void BezierCurveTo(decimal x1, decimal y1, decimal x2, decimal y2, decimal x3, decimal y3) { if (currentPosition.HasValue) { @@ -48,14 +51,14 @@ namespace UglyToad.PdfPig.Geometry } } - public void SetWindingRuleMode(int windingRule) { } + internal void SetWindingRuleMode(int windingRule) { } - public void ClosePath() + internal void ClosePath() { commands.Add(new Close()); } - public PdfRectangle? GetBoundingRectangle() + internal PdfRectangle? GetBoundingRectangle() { if (commands.Count == 0) { @@ -100,7 +103,7 @@ namespace UglyToad.PdfPig.Geometry return new PdfRectangle(minX, minY, maxX, maxY); } - public string ToSvg() + internal string ToSvg() { var builder = new StringBuilder(); foreach (var pathCommand in commands) @@ -121,7 +124,7 @@ namespace UglyToad.PdfPig.Geometry return builder.ToString(); } - public string ToFullSvg() + internal string ToFullSvg() { string BboxToRect(PdfRectangle box, string stroke) { @@ -150,7 +153,7 @@ namespace UglyToad.PdfPig.Geometry return result; } - public interface IPathCommand + internal interface IPathCommand { PdfRectangle? GetBoundingRectangle(); @@ -213,7 +216,7 @@ namespace UglyToad.PdfPig.Geometry } } - public class BezierCurve : IPathCommand + internal class BezierCurve : IPathCommand { public PdfPoint StartPoint { get; } @@ -374,7 +377,7 @@ namespace UglyToad.PdfPig.Geometry } } - public void Rectangle(decimal x, decimal y, decimal width, decimal height) + internal void Rectangle(decimal x, decimal y, decimal width, decimal height) { } } diff --git a/src/UglyToad.PdfPig/Graphics/ContentStreamProcessor.cs b/src/UglyToad.PdfPig/Graphics/ContentStreamProcessor.cs index 4db29d77..726fe73b 100644 --- a/src/UglyToad.PdfPig/Graphics/ContentStreamProcessor.cs +++ b/src/UglyToad.PdfPig/Graphics/ContentStreamProcessor.cs @@ -66,7 +66,7 @@ { foreach (var stateOperation in operations) { - stateOperation.Run(this, resourceStore); + stateOperation.Run(this); } } @@ -221,8 +221,10 @@ } } - public void ApplyXObject(StreamToken xObjectStream) + public void ApplyXObject(NameToken xObjectName) { + var xObjectStream = resourceStore.GetXObject(xObjectName); + // For now we will determine the type and store the object with the graphics state information preceding it. // Then consumers of the page can request the object/s to be retrieved by type. var subType = (NameToken)xObjectStream.StreamDictionary.Data[NameToken.Subtype.Data]; diff --git a/src/UglyToad.PdfPig/Graphics/Core/LineCapStyle.cs b/src/UglyToad.PdfPig/Graphics/Core/LineCapStyle.cs index 7837ceb8..0115f278 100644 --- a/src/UglyToad.PdfPig/Graphics/Core/LineCapStyle.cs +++ b/src/UglyToad.PdfPig/Graphics/Core/LineCapStyle.cs @@ -1,9 +1,21 @@ namespace UglyToad.PdfPig.Graphics.Core { - internal enum LineCapStyle + /// + /// The line cap style specifies the shape to be used at the ends of open subpaths (and dashes, if any) when they are stroked. + /// + public enum LineCapStyle { + /// + /// The stroke is squared off at the endpoint of the path. There is no projection beyond the end of the path. + /// Butt = 0, + /// + /// A semicircular arc with a diameter equal to the line width is drawn around the endpoint and filled in. + /// Round = 1, + /// + /// The stroke continues beyond the endpoint of the path for a distance equal to half the line width and is squared off. + /// ProjectingSquare = 2 } } \ No newline at end of file diff --git a/src/UglyToad.PdfPig/Graphics/Core/LineDashPattern.cs b/src/UglyToad.PdfPig/Graphics/Core/LineDashPattern.cs index 0d43e8e8..dba76139 100644 --- a/src/UglyToad.PdfPig/Graphics/Core/LineDashPattern.cs +++ b/src/UglyToad.PdfPig/Graphics/Core/LineDashPattern.cs @@ -1,20 +1,49 @@ namespace UglyToad.PdfPig.Graphics.Core { using System; + using System.Collections.Generic; + using System.Linq; + using Util.JetBrains.Annotations; - internal struct LineDashPattern + /// + /// The line dash pattern controls the pattern of dashes and gaps used to stroke paths. + /// It is specified by a dash array and a dash phase. + /// + public struct LineDashPattern { + /// + /// The distance into the dash pattern at which to start the dash. + /// public int Phase { get; } - public decimal[] Array { get; } + /// + /// The numbers that specify the lengths of alternating dashes and gaps. + /// + [NotNull] + public IReadOnlyList Array { get; } - public LineDashPattern(int phase, decimal[] array) + /// + /// Create a new . + /// + /// The phase. . + /// The array. . + public LineDashPattern(int phase, [NotNull]IReadOnlyList array) { Phase = phase; Array = array ?? throw new ArgumentNullException(nameof(array)); } + /// + /// The default solid line. + /// public static LineDashPattern Solid { get; } = new LineDashPattern(0, new decimal[0]); + + /// + public override string ToString() + { + var arrayStr = string.Join(" ", Array.Select(x => x.ToString("N"))); + return $"[{arrayStr}] {Phase}."; + } } } diff --git a/src/UglyToad.PdfPig/Graphics/Core/LineJoinStyle.cs b/src/UglyToad.PdfPig/Graphics/Core/LineJoinStyle.cs index 05184e11..eee405c5 100644 --- a/src/UglyToad.PdfPig/Graphics/Core/LineJoinStyle.cs +++ b/src/UglyToad.PdfPig/Graphics/Core/LineJoinStyle.cs @@ -1,9 +1,23 @@ namespace UglyToad.PdfPig.Graphics.Core { - internal enum LineJoinStyle + /// + /// The line join style specifies the shape to be used at the corners of paths that are stroked. + /// + public enum LineJoinStyle { + /// + /// The outer edges of the strokes for the two segments are extended until they meet at an angle, as in a picture frame. + /// If the segments meet at too sharp an angle (as defined by the miter limit parameter), a bevel join is used instead. + /// Miter = 0, + /// + /// An arc of a circle with a diameter equal to the line width is drawn around the point where the two segments meet, + /// connecting the outer edges of the strokes for the two segments + /// Round = 1, + /// + /// The two segments are finished with butt caps and the resulting notch beyond the ends of the segments is filled with a triangle. + /// Bevel = 2 } } \ No newline at end of file diff --git a/src/UglyToad.PdfPig/Graphics/Core/RenderingIntent.cs b/src/UglyToad.PdfPig/Graphics/Core/RenderingIntent.cs index dc6f1470..ee868a09 100644 --- a/src/UglyToad.PdfPig/Graphics/Core/RenderingIntent.cs +++ b/src/UglyToad.PdfPig/Graphics/Core/RenderingIntent.cs @@ -1,6 +1,9 @@ namespace UglyToad.PdfPig.Graphics.Core { - internal enum RenderingIntent + /// + /// Specifying a rendering intent allows a PDF file to set priorities regarding which properties to preserve and which to sacrifice for CIE colors. + /// + public enum RenderingIntent { /// /// No correction for the output medium's white point. Colors diff --git a/src/UglyToad.PdfPig/Graphics/Core/RenderingModeExtensions.cs b/src/UglyToad.PdfPig/Graphics/Core/RenderingModeExtensions.cs index 5332566f..b5db796e 100644 --- a/src/UglyToad.PdfPig/Graphics/Core/RenderingModeExtensions.cs +++ b/src/UglyToad.PdfPig/Graphics/Core/RenderingModeExtensions.cs @@ -2,28 +2,28 @@ { internal static class RenderingModeExtensions { - public static bool IsFill(this RenderingMode mode) + public static bool IsFill(this TextRenderingMode mode) { - return mode == RenderingMode.Fill - || mode == RenderingMode.FillThenStroke - || mode == RenderingMode.FillClip - || mode == RenderingMode.FillThenStrokeClip; + return mode == TextRenderingMode.Fill + || mode == TextRenderingMode.FillThenStroke + || mode == TextRenderingMode.FillClip + || mode == TextRenderingMode.FillThenStrokeClip; } - public static bool IsStroke(this RenderingMode mode) + public static bool IsStroke(this TextRenderingMode mode) { - return mode == RenderingMode.Stroke - || mode == RenderingMode.FillThenStroke - || mode == RenderingMode.StrokeClip - || mode == RenderingMode.FillThenStrokeClip; + return mode == TextRenderingMode.Stroke + || mode == TextRenderingMode.FillThenStroke + || mode == TextRenderingMode.StrokeClip + || mode == TextRenderingMode.FillThenStrokeClip; } - public static bool IsClip(this RenderingMode mode) + public static bool IsClip(this TextRenderingMode mode) { - return mode == RenderingMode.FillClip - || mode == RenderingMode.StrokeClip - || mode == RenderingMode.FillThenStrokeClip - || mode == RenderingMode.NeitherClip; + return mode == TextRenderingMode.FillClip + || mode == TextRenderingMode.StrokeClip + || mode == TextRenderingMode.FillThenStrokeClip + || mode == TextRenderingMode.NeitherClip; } } } \ No newline at end of file diff --git a/src/UglyToad.PdfPig/Graphics/Core/RenderingMode.cs b/src/UglyToad.PdfPig/Graphics/Core/TextRenderingMode.cs similarity index 83% rename from src/UglyToad.PdfPig/Graphics/Core/RenderingMode.cs rename to src/UglyToad.PdfPig/Graphics/Core/TextRenderingMode.cs index 980ccbfd..fd1749a1 100644 --- a/src/UglyToad.PdfPig/Graphics/Core/RenderingMode.cs +++ b/src/UglyToad.PdfPig/Graphics/Core/TextRenderingMode.cs @@ -1,6 +1,10 @@ namespace UglyToad.PdfPig.Graphics.Core { - internal enum RenderingMode + /// + /// The text rendering mode determines whether showing text causes glyph outlines to be stroked, filled, used as a clipping boundary, + /// or some combination of the three. + /// + public enum TextRenderingMode { /// /// Fill text. diff --git a/src/UglyToad.PdfPig/Graphics/CurrentFontState.cs b/src/UglyToad.PdfPig/Graphics/CurrentFontState.cs index 66e580d7..dbccbd41 100644 --- a/src/UglyToad.PdfPig/Graphics/CurrentFontState.cs +++ b/src/UglyToad.PdfPig/Graphics/CurrentFontState.cs @@ -8,7 +8,7 @@ namespace UglyToad.PdfPig.Graphics /// /// The current state of text related parameters for a content stream. /// - internal class CurrentFontState : IDeepCloneable + public class CurrentFontState : IDeepCloneable { /// /// A value in unscaled text space units which is added to the horizontal (or vertical if in vertical writing mode) @@ -39,19 +39,25 @@ namespace UglyToad.PdfPig.Graphics /// public decimal Leading { get; set; } + /// + /// The name of the currently active font. + /// public NameToken FontName { get; set; } + /// + /// The current font size. + /// public decimal FontSize { get; set; } /// - /// The for glyph outlines. + /// The for glyph outlines. /// /// /// When the rendering mode requires filling the current non-stroking color in the state is used.
/// When the rendering mode requires stroking the current stroking color in the state is used.
/// The rendering mode has no impact on Type 3 fonts. ///
- public RenderingMode RenderingMode { get; set; } = RenderingMode.Fill; + public TextRenderingMode TextRenderingMode { get; set; } = TextRenderingMode.Fill; /// /// The distance in unscaled text space units to move the default baseline either up or down. @@ -62,16 +68,17 @@ namespace UglyToad.PdfPig.Graphics public decimal Rise { get; set; } /// - /// Are all glpyhs in a text object treated as a single elementary object for the purpose of the transparent imaging model? + /// Are all glyphs in a text object treated as a single elementary object for the purpose of the transparent imaging model? /// public bool Knockout { get; set; } + /// public CurrentFontState DeepClone() { return new CurrentFontState { CharacterSpacing = CharacterSpacing, - RenderingMode = RenderingMode, + TextRenderingMode = TextRenderingMode, Rise = Rise, Leading = Leading, WordSpacing = WordSpacing, diff --git a/src/UglyToad.PdfPig/Graphics/CurrentGraphicsState.cs b/src/UglyToad.PdfPig/Graphics/CurrentGraphicsState.cs index 86fb2061..f3270926 100644 --- a/src/UglyToad.PdfPig/Graphics/CurrentGraphicsState.cs +++ b/src/UglyToad.PdfPig/Graphics/CurrentGraphicsState.cs @@ -1,15 +1,16 @@ -namespace UglyToad.PdfPig.Graphics +// ReSharper disable RedundantDefaultMemberInitializer +namespace UglyToad.PdfPig.Graphics { using Core; using PdfPig.Core; /// - /// The state of the current graphics control parameters. + /// The state of the current graphics control parameters set by operations in the content stream. /// /// /// Initialized per page. /// - internal class CurrentGraphicsState : IDeepCloneable + public class CurrentGraphicsState : IDeepCloneable { /// /// The for this graphics state. @@ -97,6 +98,7 @@ #endregion + /// public CurrentGraphicsState DeepClone() { return new CurrentGraphicsState diff --git a/src/UglyToad.PdfPig/Graphics/IOperationContext.cs b/src/UglyToad.PdfPig/Graphics/IOperationContext.cs index 1f15aef9..924b2ec2 100644 --- a/src/UglyToad.PdfPig/Graphics/IOperationContext.cs +++ b/src/UglyToad.PdfPig/Graphics/IOperationContext.cs @@ -1,39 +1,85 @@ namespace UglyToad.PdfPig.Graphics { using System.Collections.Generic; - using Fonts; using Geometry; using IO; using Tokens; using Util.JetBrains.Annotations; - internal interface IOperationContext + /// + /// The current graphics state context when running a PDF content stream. + /// + public interface IOperationContext { + /// + /// The current path being drawn if applicable. + /// [CanBeNull] PdfPath CurrentPath { get; } + /// + /// The current p + /// PdfPoint CurrentPosition { get; set; } + /// + /// Get the currently active . States are stored on a stack structure. + /// + /// The currently active graphics state. CurrentGraphicsState GetCurrentState(); + /// + /// The matrices for the current text state. + /// TextMatrices TextMatrices { get; } + /// + /// The number of graphics states on the stack. + /// int StackSize { get; } + /// + /// Sets the current graphics state to the state from the top of the stack. + /// void PopState(); + /// + /// Saves a copy of the current graphics state on the stack. + /// void PushState(); + /// + /// Shows the text represented by the provided bytes using the current graphics state. + /// + /// The bytes of the text. void ShowText(IInputBytes bytes); + /// + /// Interprets the tokens to draw text at positions. + /// + /// The tokens to show. void ShowPositionedText(IReadOnlyList tokens); - void ApplyXObject(StreamToken xObjectStream); + /// + /// Retrieves the named XObject and applies it to the current state. + /// + /// The name of the XObject. + void ApplyXObject(NameToken xObjectName); + /// + /// Start a new sub-path. + /// void BeginSubpath(); + /// + /// Stroke the current path. + /// + /// Whether to also close the path. void StrokePath(bool close); + /// + /// Close the current path. + /// void ClosePath(); } } \ No newline at end of file diff --git a/src/UglyToad.PdfPig/Graphics/Operations/ClippingPaths/ModifyClippingByEvenOddIntersect.cs b/src/UglyToad.PdfPig/Graphics/Operations/ClippingPaths/ModifyClippingByEvenOddIntersect.cs index 47dacf88..ac88494d 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/ClippingPaths/ModifyClippingByEvenOddIntersect.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/ClippingPaths/ModifyClippingByEvenOddIntersect.cs @@ -1,29 +1,44 @@ namespace UglyToad.PdfPig.Graphics.Operations.ClippingPaths { using System.IO; - using Content; - internal class ModifyClippingByEvenOddIntersect : IGraphicsStateOperation + /// + /// + /// Modify the current clipping path by intersecting it with the current path, using the + /// even-odd rule to determine which regions lie inside the clipping path. + /// + public class ModifyClippingByEvenOddIntersect : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "W*"; + /// + /// The instance of the operation. + /// public static readonly ModifyClippingByEvenOddIntersect Value = new ModifyClippingByEvenOddIntersect(); + /// public string Operator => Symbol; private ModifyClippingByEvenOddIntersect() { } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { } + /// public void Write(Stream stream) { - throw new System.NotImplementedException(); + stream.WriteText(Symbol); + stream.WriteNewLine(); } + /// public override string ToString() { return Symbol; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/ClippingPaths/ModifyClippingByNonZeroWindingIntersect.cs b/src/UglyToad.PdfPig/Graphics/Operations/ClippingPaths/ModifyClippingByNonZeroWindingIntersect.cs index 734d7312..fa39bac0 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/ClippingPaths/ModifyClippingByNonZeroWindingIntersect.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/ClippingPaths/ModifyClippingByNonZeroWindingIntersect.cs @@ -1,29 +1,44 @@ namespace UglyToad.PdfPig.Graphics.Operations.ClippingPaths { using System.IO; - using Content; - internal class ModifyClippingByNonZeroWindingIntersect : IGraphicsStateOperation + /// + /// + /// Modify the current clipping path by intersecting it with the current path, using the + /// nonzero winding number rule to determine which regions lie inside the clipping path. + /// + public class ModifyClippingByNonZeroWindingIntersect : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "W"; + /// + /// The instance of the operation. + /// public static readonly ModifyClippingByNonZeroWindingIntersect Value = new ModifyClippingByNonZeroWindingIntersect(); + /// public string Operator => Symbol; private ModifyClippingByNonZeroWindingIntersect() { } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { } + /// public void Write(Stream stream) { - throw new System.NotImplementedException(); + stream.WriteText(Symbol); + stream.WriteNewLine(); } + /// public override string ToString() { return Symbol; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/CloseAndStrokePath.cs b/src/UglyToad.PdfPig/Graphics/Operations/CloseAndStrokePath.cs index 0503f734..897ee940 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/CloseAndStrokePath.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/CloseAndStrokePath.cs @@ -1,12 +1,12 @@ namespace UglyToad.PdfPig.Graphics.Operations { using System.IO; - using Content; + /// /// /// Close and stroke the path. /// - internal class CloseAndStrokePath : IGraphicsStateOperation + public class CloseAndStrokePath : IGraphicsStateOperation { /// /// The symbol for this operation in a stream. @@ -26,7 +26,7 @@ } /// - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + public void Run(IOperationContext operationContext) { operationContext.StrokePath(true); } diff --git a/src/UglyToad.PdfPig/Graphics/Operations/CloseFillPathEvenOddRuleAndStroke.cs b/src/UglyToad.PdfPig/Graphics/Operations/CloseFillPathEvenOddRuleAndStroke.cs index 94c0debc..7d7a292f 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/CloseFillPathEvenOddRuleAndStroke.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/CloseFillPathEvenOddRuleAndStroke.cs @@ -1,8 +1,8 @@ namespace UglyToad.PdfPig.Graphics.Operations { using System.IO; - using Content; - + + /// /// /// Close, fill, and then stroke the path, using the even-odd rule to determine the region to fill. /// @@ -26,7 +26,7 @@ } /// - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + public void Run(IOperationContext operationContext) { } diff --git a/src/UglyToad.PdfPig/Graphics/Operations/CloseFillPathNonZeroWindingAndStroke.cs b/src/UglyToad.PdfPig/Graphics/Operations/CloseFillPathNonZeroWindingAndStroke.cs index 2d6d1f55..b0abf77d 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/CloseFillPathNonZeroWindingAndStroke.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/CloseFillPathNonZeroWindingAndStroke.cs @@ -1,8 +1,8 @@ namespace UglyToad.PdfPig.Graphics.Operations { using System.IO; - using Content; - + + /// /// /// Close, fill, and then stroke the path, using the nonzero winding number rule to determine the region to fill. /// @@ -26,7 +26,7 @@ } /// - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + public void Run(IOperationContext operationContext) { } diff --git a/src/UglyToad.PdfPig/Graphics/Operations/EndPath.cs b/src/UglyToad.PdfPig/Graphics/Operations/EndPath.cs index 3d1c1c18..d11d8745 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/EndPath.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/EndPath.cs @@ -1,12 +1,12 @@ namespace UglyToad.PdfPig.Graphics.Operations { using System.IO; - using Content; + /// /// /// End path without filling or stroking. /// - internal class EndPath : IGraphicsStateOperation + public class EndPath : IGraphicsStateOperation { /// /// The symbol for this operation in a stream. @@ -26,7 +26,7 @@ } /// - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + public void Run(IOperationContext operationContext) { } diff --git a/src/UglyToad.PdfPig/Graphics/Operations/FillPathEvenOddRule.cs b/src/UglyToad.PdfPig/Graphics/Operations/FillPathEvenOddRule.cs index d9286de6..97c20ed5 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/FillPathEvenOddRule.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/FillPathEvenOddRule.cs @@ -1,12 +1,12 @@ namespace UglyToad.PdfPig.Graphics.Operations { using System.IO; - using Content; + /// /// /// Fill the path, using the even-odd rule to determine the region to fill. /// - internal class FillPathEvenOddRule : IGraphicsStateOperation + public class FillPathEvenOddRule : IGraphicsStateOperation { /// /// The symbol for this operation in a stream. @@ -26,7 +26,7 @@ } /// - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + public void Run(IOperationContext operationContext) { } diff --git a/src/UglyToad.PdfPig/Graphics/Operations/FillPathEvenOddRuleAndStroke.cs b/src/UglyToad.PdfPig/Graphics/Operations/FillPathEvenOddRuleAndStroke.cs index dcd974fe..a4e1e7d2 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/FillPathEvenOddRuleAndStroke.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/FillPathEvenOddRuleAndStroke.cs @@ -1,8 +1,8 @@ namespace UglyToad.PdfPig.Graphics.Operations { using System.IO; - using Content; + /// /// /// Fill and then stroke the path, using the even-odd rule to determine the region to fill. /// @@ -26,7 +26,7 @@ } /// - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + public void Run(IOperationContext operationContext) { } diff --git a/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWinding.cs b/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWinding.cs index 27bf8de9..d9afc6e0 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWinding.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWinding.cs @@ -1,13 +1,13 @@ namespace UglyToad.PdfPig.Graphics.Operations { using System.IO; - using Content; + /// /// /// Fill the path, using the nonzero winding number rule to determine the region to fill. /// Any subpaths that are open are implicitly closed before being filled. /// - internal class FillPathNonZeroWinding : IGraphicsStateOperation + public class FillPathNonZeroWinding : IGraphicsStateOperation { /// /// The symbol for this operation in a stream. @@ -27,7 +27,7 @@ } /// - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + public void Run(IOperationContext operationContext) { } diff --git a/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWindingAndStroke.cs b/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWindingAndStroke.cs index ef6d9abc..b21c215e 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWindingAndStroke.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWindingAndStroke.cs @@ -1,12 +1,12 @@ namespace UglyToad.PdfPig.Graphics.Operations { using System.IO; - using Content; + /// /// /// Fill and then stroke the path, using the nonzero winding number rule to determine the region to fill. /// - internal class FillPathNonZeroWindingAndStroke : IGraphicsStateOperation + public class FillPathNonZeroWindingAndStroke : IGraphicsStateOperation { /// /// The symbol for this operation in a stream. @@ -26,7 +26,7 @@ } /// - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + public void Run(IOperationContext operationContext) { } diff --git a/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWindingCompatibility.cs b/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWindingCompatibility.cs index 0a8f1959..29f5d895 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWindingCompatibility.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWindingCompatibility.cs @@ -1,13 +1,13 @@ namespace UglyToad.PdfPig.Graphics.Operations { using System.IO; - using Content; + /// /// /// Equivalent to included only for compatibility. /// Although PDF consumer applications must be able to accept this operator, PDF producer applications should use instead. /// - internal class FillPathNonZeroWindingCompatibility : IGraphicsStateOperation + public class FillPathNonZeroWindingCompatibility : IGraphicsStateOperation { /// /// The symbol for this operation in a stream. @@ -27,7 +27,7 @@ } /// - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + public void Run(IOperationContext operationContext) { } diff --git a/src/UglyToad.PdfPig/Graphics/Operations/General/SetColorRenderingIntent.cs b/src/UglyToad.PdfPig/Graphics/Operations/General/SetColorRenderingIntent.cs index 68322bb9..b8d14bdd 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/General/SetColorRenderingIntent.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/General/SetColorRenderingIntent.cs @@ -1,22 +1,54 @@ namespace UglyToad.PdfPig.Graphics.Operations.General { + using System; using System.IO; - using Content; + using Tokens; - internal class SetColorRenderingIntent : IGraphicsStateOperation + /// + /// + /// Set the color rendering intent in the graphics state. + /// + public class SetColorRenderingIntent : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "ri"; + /// public string Operator => Symbol; - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + /// The rendering intent for CIE-based colors. + /// + public NameToken RenderingIntent { get; } + + /// + /// Create new . + /// + /// The rendering intent. + public SetColorRenderingIntent(NameToken renderingIntent) + { + RenderingIntent = renderingIntent ?? throw new ArgumentNullException(nameof(renderingIntent)); + } + + /// + public void Run(IOperationContext operationContext) { } + /// public void Write(Stream stream) { - throw new System.NotImplementedException(); + stream.WriteText($"/{RenderingIntent.Data} {Symbol}"); + stream.WriteNewLine(); + } + + /// + public override string ToString() + { + return $"{RenderingIntent} {Symbol}"; } } } \ No newline at end of file diff --git a/src/UglyToad.PdfPig/Graphics/Operations/General/SetFlatnessTolerance.cs b/src/UglyToad.PdfPig/Graphics/Operations/General/SetFlatnessTolerance.cs index a115d176..ac9299ea 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/General/SetFlatnessTolerance.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/General/SetFlatnessTolerance.cs @@ -1,31 +1,50 @@ namespace UglyToad.PdfPig.Graphics.Operations.General { using System.IO; - using Content; - internal class SetFlatnessTolerance : IGraphicsStateOperation + /// + /// + /// Set the flatness tolerance in the graphics state. + /// Flatness is a number in the range 0 to 100; a value of 0 specifies the output device’s default flatness tolerance. + /// + public class SetFlatnessTolerance : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "i"; + /// public string Operator => Symbol; + /// + /// The flatness tolerance controls the maximum permitted distance in device pixels + /// between the mathematically correct path and an approximation constructed from straight line segments. + /// public decimal Tolerance { get; } + /// + /// Create new . + /// + /// The flatness tolerance. public SetFlatnessTolerance(decimal tolerance) { Tolerance = tolerance; } - - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + + /// + public void Run(IOperationContext operationContext) { operationContext.GetCurrentState().Flatness = Tolerance; } + /// public void Write(Stream stream) { - throw new System.NotImplementedException(); + stream.WriteNumberText(Tolerance, Symbol); } + /// public override string ToString() { return $"{Tolerance} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/General/SetLineCap.cs b/src/UglyToad.PdfPig/Graphics/Operations/General/SetLineCap.cs index 3526fa7c..1e06ec59 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/General/SetLineCap.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/General/SetLineCap.cs @@ -2,18 +2,36 @@ { using System; using System.IO; - using Content; using Core; - internal class SetLineCap : IGraphicsStateOperation + /// + /// + /// Set the line cap style in the graphics state. + /// + public class SetLineCap : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "J"; + /// public string Operator => Symbol; + /// + /// The cap style. + /// public LineCapStyle Cap { get; } + /// + /// + /// Create a new . + /// public SetLineCap(int cap) : this((LineCapStyle)cap) { } + + /// + /// Create a new . + /// public SetLineCap(LineCapStyle cap) { if (cap < 0 || (int)cap > 2) @@ -24,19 +42,19 @@ Cap = cap; } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { operationContext.GetCurrentState().CapStyle = Cap; } + /// public void Write(Stream stream) { - stream.WriteDecimal((int)Cap); - stream.WriteWhiteSpace(); - stream.WriteText(Symbol); - stream.WriteNewLine(); + stream.WriteNumberText((int)Cap, Symbol); } + /// public override string ToString() { return $"{(int) Cap} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/General/SetLineDashPattern.cs b/src/UglyToad.PdfPig/Graphics/Operations/General/SetLineDashPattern.cs index e421ae25..3dcad6cf 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/General/SetLineDashPattern.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/General/SetLineDashPattern.cs @@ -1,32 +1,71 @@ namespace UglyToad.PdfPig.Graphics.Operations.General { using System.IO; - using Content; using Core; - internal class SetLineDashPattern : IGraphicsStateOperation + /// + /// + /// Set the line dash pattern in the graphics state. + /// + public class SetLineDashPattern : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "d"; + /// public string Operator => Symbol; + /// + /// The line dash pattern. + /// public LineDashPattern Pattern { get; } + /// + /// Create a new . + /// public SetLineDashPattern(decimal[] array, int phase) { Pattern = new LineDashPattern(phase, array); } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { operationContext.GetCurrentState().LineDashPattern = Pattern; } + /// public void Write(Stream stream) { - throw new System.NotImplementedException(); + stream.WriteText("["); + + for (var i = 0; i < Pattern.Array.Count; i++) + { + var value = Pattern.Array[i]; + stream.WriteDecimal(value); + + if (i < Pattern.Array.Count - 1) + { + stream.WriteWhiteSpace(); + } + } + + stream.WriteText("]"); + + stream.WriteWhiteSpace(); + + stream.WriteDecimal(Pattern.Phase); + + stream.WriteWhiteSpace(); + + stream.WriteText(Symbol); + + stream.WriteNewLine(); } + /// public override string ToString() { return $"{Pattern.Array} {Pattern.Phase} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/General/SetLineJoin.cs b/src/UglyToad.PdfPig/Graphics/Operations/General/SetLineJoin.cs index 1797e6ee..95398ff7 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/General/SetLineJoin.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/General/SetLineJoin.cs @@ -2,18 +2,31 @@ { using System; using System.IO; - using Content; using Core; - internal class SetLineJoin : IGraphicsStateOperation + /// + public class SetLineJoin : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "j"; + /// public string Operator => Symbol; + /// + /// The line join style. + /// public LineJoinStyle Join { get; } + /// + /// Create a new . + /// public SetLineJoin(int join) : this((LineJoinStyle)join) { } + /// + /// Create a new . + /// public SetLineJoin(LineJoinStyle join) { if (join < 0 || (int)join > 2) @@ -24,19 +37,19 @@ Join = join; } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { operationContext.GetCurrentState().JoinStyle = Join; } + /// public void Write(Stream stream) { - stream.WriteDecimal((int)Join); - stream.WriteWhiteSpace(); - stream.WriteText(Symbol); - stream.WriteNewLine(); + stream.WriteNumberText((int)Join, Symbol); } + /// public override string ToString() { return $"{(int)Join} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/General/SetLineWidth.cs b/src/UglyToad.PdfPig/Graphics/Operations/General/SetLineWidth.cs index 64b43465..949bc2cc 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/General/SetLineWidth.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/General/SetLineWidth.cs @@ -1,36 +1,50 @@ namespace UglyToad.PdfPig.Graphics.Operations.General { using System.IO; - using Content; - internal class SetLineWidth : IGraphicsStateOperation + /// + /// + /// Set the line width in the graphics state. + /// + public class SetLineWidth : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "w"; + /// public string Operator => Symbol; + /// + /// The line width. + /// public decimal Width { get; } + /// + /// Create a new . + /// + /// The line width. public SetLineWidth(decimal width) { Width = width; } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { var currentState = operationContext.GetCurrentState(); currentState.LineWidth = Width; } + /// public void Write(Stream stream) { - stream.WriteDecimal(Width); - stream.WriteWhiteSpace(); - stream.WriteText(Symbol); - stream.WriteNewLine(); + stream.WriteNumberText(Width, Symbol); } + /// public override string ToString() { return $"{Width} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/General/SetMiterLimit.cs b/src/UglyToad.PdfPig/Graphics/Operations/General/SetMiterLimit.cs index 16ab2e10..54ac37f1 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/General/SetMiterLimit.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/General/SetMiterLimit.cs @@ -1,33 +1,50 @@ namespace UglyToad.PdfPig.Graphics.Operations.General { using System.IO; - using Content; - internal class SetMiterLimit : IGraphicsStateOperation + /// + /// + /// Set the miter limit in the graphics state. + /// + public class SetMiterLimit : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "M"; + /// public string Operator => Symbol; + /// + /// The miter limit. The miter limit imposes a maximum on the ratio of the miter length to the line width. + /// When the limit is exceeded, the join is converted from a miter to a bevel. + /// public decimal Limit { get; } + /// + /// Create a new . + /// public SetMiterLimit(decimal limit) { Limit = limit; } - - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + + /// + public void Run(IOperationContext operationContext) { var currentState = operationContext.GetCurrentState(); currentState.MiterLimit = Limit; } + /// public void Write(Stream stream) { - throw new System.NotImplementedException(); + stream.WriteNumberText(Limit, Symbol); } + /// public override string ToString() { return $"{Limit} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/IGraphicsStateOperation.cs b/src/UglyToad.PdfPig/Graphics/Operations/IGraphicsStateOperation.cs index eb64f639..d08c54e8 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/IGraphicsStateOperation.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/IGraphicsStateOperation.cs @@ -1,14 +1,27 @@ namespace UglyToad.PdfPig.Graphics.Operations { using System.IO; - using Content; - internal interface IGraphicsStateOperation + /// + /// An operation with associated data from a content stream. + /// + public interface IGraphicsStateOperation { + /// + /// The symbol representing the operator in the content stream. + /// string Operator { get; } - void Run(IOperationContext operationContext, IResourceStore resourceStore); - + /// + /// Writes the operator and any operands as valid PDF content to the stream. + /// + /// The stream to write to. void Write(Stream stream); + + /// + /// Applies the operation to the current context with the provided resources. + /// + /// + void Run(IOperationContext operationContext); } } \ No newline at end of file diff --git a/src/UglyToad.PdfPig/Graphics/Operations/InvokeNamedXObject.cs b/src/UglyToad.PdfPig/Graphics/Operations/InvokeNamedXObject.cs index 522c4a3f..5be69543 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/InvokeNamedXObject.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/InvokeNamedXObject.cs @@ -1,16 +1,17 @@ namespace UglyToad.PdfPig.Graphics.Operations { + using System; using System.IO; - using Content; using Tokens; + /// /// /// Paint the specified XObject. /// The operand name must appear as a key in the XObject subdictionary of the current resource dictionary. /// The associated value must be a stream whose Type entry, if present, is XObject. - /// The effect of depends on the value of the XObject's Subtype entry, which may be Image, Form or PS. + /// The effect of depends on the value of the XObject's Subtype entry, which may be Image, Form or PS. /// - internal class InvokeNamedXObject : IGraphicsStateOperation + public class InvokeNamedXObject : IGraphicsStateOperation { /// /// The symbol for this operation in a stream. @@ -31,15 +32,13 @@ /// The name of the XObject. public InvokeNamedXObject(NameToken name) { - Name = name; + Name = name ?? throw new ArgumentNullException(nameof(name)); } /// - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + public void Run(IOperationContext operationContext) { - var xobject = resourceStore.GetXObject(Name); - - operationContext.ApplyXObject(xobject); + operationContext.ApplyXObject(Name); } /// diff --git a/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendDualControlPointBezierCurve.cs b/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendDualControlPointBezierCurve.cs index e25d8e84..cf191f9c 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendDualControlPointBezierCurve.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendDualControlPointBezierCurve.cs @@ -1,21 +1,47 @@ namespace UglyToad.PdfPig.Graphics.Operations.PathConstruction { using System.IO; - using Content; using Geometry; - - internal class AppendDualControlPointBezierCurve : IGraphicsStateOperation + + /// + /// + /// Append a cubic Bezier curve to the current path. + /// The curve extends from the current point to the point (x3, y3), using (x1, y1) and (x2, y2) as the Bezier control points + /// + public class AppendDualControlPointBezierCurve : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "c"; + /// public string Operator => Symbol; + /// + /// The first control point. + /// public PdfPoint ControlPoint1 { get; } + /// + /// The second control point. + /// public PdfPoint ControlPoint2 { get; } + /// + /// The end point. + /// public PdfPoint End { get; } + /// + /// Create a new . + /// + /// Control point 1 x coordinate. + /// Control point 1 y coordinate. + /// Control point 2 x coordinate. + /// Control point 2 y coordinate. + /// End point x coordinate. + /// End point y coordinate. public AppendDualControlPointBezierCurve(decimal x1, decimal y1, decimal x2, decimal y2, decimal x3, decimal y3) { ControlPoint1 = new PdfPoint(x1, y1); @@ -23,7 +49,8 @@ End = new PdfPoint(x3, y3); } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { operationContext.CurrentPath.BezierCurveTo(ControlPoint1.X, ControlPoint1.Y, ControlPoint2.X, ControlPoint2.Y, @@ -31,6 +58,7 @@ operationContext.CurrentPosition = End; } + /// public void Write(Stream stream) { stream.WriteDecimal(ControlPoint1.X); @@ -49,6 +77,7 @@ stream.WriteNewLine(); } + /// public override string ToString() { return $"{ControlPoint1.X} {ControlPoint1.Y} {ControlPoint2.X} {ControlPoint2.Y} {End.X} {End.Y} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendEndControlPointBezierCurve.cs b/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendEndControlPointBezierCurve.cs index 2972118b..5c1ebfc5 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendEndControlPointBezierCurve.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendEndControlPointBezierCurve.cs @@ -1,26 +1,48 @@ namespace UglyToad.PdfPig.Graphics.Operations.PathConstruction { using System.IO; - using Content; using Geometry; - internal class AppendEndControlPointBezierCurve : IGraphicsStateOperation + /// + /// + /// Append a cubic Bezier curve to the current path. + /// The curve extends from the current point to the point (x3, y3), using (x1, y1) and (x3, y3) as the Bezier control points + /// + public class AppendEndControlPointBezierCurve : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "y"; + /// public string Operator => Symbol; + /// + /// The first control point. + /// public PdfPoint ControlPoint1 { get; } + /// + /// The end point and second control point. + /// public PdfPoint End { get; } + /// + /// Create a new . + /// + /// Control point 1 x coordinate. + /// Control point 1 y coordinate. + /// Control point 2/End x coordinate. + /// Control point 2/End y coordinate. public AppendEndControlPointBezierCurve(decimal x1, decimal y1, decimal x3, decimal y3) { ControlPoint1 = new PdfPoint(x1, y1); End = new PdfPoint(x3, y3); } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { operationContext.CurrentPath.BezierCurveTo(ControlPoint1.X, ControlPoint1.Y, End.X, @@ -30,6 +52,7 @@ operationContext.CurrentPosition = End; } + /// public void Write(Stream stream) { stream.WriteDecimal(ControlPoint1.X); @@ -44,6 +67,7 @@ stream.WriteNewLine(); } + /// public override string ToString() { return $"{ControlPoint1.X} {ControlPoint1.Y} {End.X} {End.Y} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendRectangle.cs b/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendRectangle.cs index 94e159dc..6639bd41 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendRectangle.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendRectangle.cs @@ -1,21 +1,44 @@ namespace UglyToad.PdfPig.Graphics.Operations.PathConstruction { using System.IO; - using Content; using Geometry; - internal class AppendRectangle : IGraphicsStateOperation + /// + /// + /// Append a rectangle to the current path as a complete subpath. + /// + public class AppendRectangle : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "re"; + /// public string Operator => Symbol; + /// + /// The lower left corner. + /// public PdfPoint LowerLeft { get; } + /// + /// The width of the rectangle. + /// public decimal Width { get; } + /// + /// The height of the rectangle. + /// public decimal Height { get; } + /// + /// Create a new . + /// + /// The x coordinate of the lower left corner. + /// The y coordinate of the lower left corner. + /// The width of the rectangle. + /// The height of the rectangle. public AppendRectangle(decimal x, decimal y, decimal width, decimal height) { LowerLeft = new PdfPoint(x, y); @@ -24,13 +47,15 @@ Height = height; } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { operationContext.BeginSubpath(); operationContext.CurrentPath.Rectangle(LowerLeft.X, LowerLeft.Y, Width, Height); operationContext.CurrentPath.ClosePath(); } + /// public void Write(Stream stream) { stream.WriteDecimal(LowerLeft.X); @@ -45,6 +70,7 @@ stream.WriteNewLine(); } + /// public override string ToString() { return $"{LowerLeft.X} {LowerLeft.Y} {Width} {Height} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendStartControlPointBezierCurve.cs b/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendStartControlPointBezierCurve.cs index bc85f3cf..9895670c 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendStartControlPointBezierCurve.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendStartControlPointBezierCurve.cs @@ -1,26 +1,48 @@ namespace UglyToad.PdfPig.Graphics.Operations.PathConstruction { using System.IO; - using Content; using Geometry; - internal class AppendStartControlPointBezierCurve : IGraphicsStateOperation + /// + /// + /// Append a cubic Bezier curve to the current path. + /// The curve extends from the current point to the point (x3, y3), using the current point and (x2, y2) as the Bezier control points + /// + public class AppendStartControlPointBezierCurve : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "v"; + /// public string Operator => Symbol; + /// + /// The second control point. + /// public PdfPoint ControlPoint2 { get; } + /// + /// The last point on the curve. + /// public PdfPoint End { get; } + /// + /// Create a new . + /// + /// The x coordinate of the second control point. + /// The y coordinate of the second control point. + /// The x coordinate of the end point. + /// The y coordinate of the end point. public AppendStartControlPointBezierCurve(decimal x2, decimal y2, decimal x3, decimal y3) { ControlPoint2 = new PdfPoint(x2, y2); End = new PdfPoint(x3, y3); } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { operationContext.CurrentPath.BezierCurveTo(operationContext.CurrentPosition.X, operationContext.CurrentPosition.Y, @@ -31,6 +53,7 @@ operationContext.CurrentPosition = End; } + /// public void Write(Stream stream) { stream.WriteDecimal(ControlPoint2.X); @@ -45,6 +68,7 @@ stream.WriteNewLine(); } + /// public override string ToString() { return $"{ControlPoint2.X} {ControlPoint2.Y} {End.X} {End.Y} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendStraightLineSegment.cs b/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendStraightLineSegment.cs index 33d485a8..22ccd217 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendStraightLineSegment.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/AppendStraightLineSegment.cs @@ -1,28 +1,45 @@ namespace UglyToad.PdfPig.Graphics.Operations.PathConstruction { using System.IO; - using Content; using Geometry; - internal class AppendStraightLineSegment : IGraphicsStateOperation + /// + /// + /// Append a straight line segment from the current point to the point (x, y). + /// + public class AppendStraightLineSegment : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "l"; + /// public string Operator => Symbol; + /// + /// The end point of the line. + /// public PdfPoint End { get; } + /// + /// Create a new . + /// + /// The x coordinate of the line's end point. + /// The y coordinate of the line's end point. public AppendStraightLineSegment(decimal x, decimal y) { End = new PdfPoint(x, y); } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { operationContext.CurrentPath.LineTo(End.X, End.Y); operationContext.CurrentPosition = End; } + /// public void Write(Stream stream) { stream.WriteDecimal(End.X); @@ -33,6 +50,7 @@ stream.WriteWhiteSpace(); } + /// public override string ToString() { return $"{End.X} {End.Y} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/BeginNewSubpath.cs b/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/BeginNewSubpath.cs index ea0d3067..a565fbb2 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/BeginNewSubpath.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/BeginNewSubpath.cs @@ -1,28 +1,45 @@ namespace UglyToad.PdfPig.Graphics.Operations.PathConstruction { using System.IO; - using Content; using Geometry; - internal class BeginNewSubpath : IGraphicsStateOperation + /// + /// + /// Begin a new subpath by moving the current point to coordinates (x, y), omitting any connecting line segment. + /// + public class BeginNewSubpath : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "m"; + /// public string Operator => Symbol; + /// + /// The point to begin the new subpath at. + /// public PdfPoint Point { get; } + /// + /// Create a new . + /// + /// The x coordinate. + /// The y coordinate. public BeginNewSubpath(decimal x, decimal y) { Point = new PdfPoint(x, y); } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { operationContext.BeginSubpath(); operationContext.CurrentPosition = Point; } + /// public void Write(Stream stream) { stream.WriteDecimal(Point.X); @@ -33,6 +50,7 @@ stream.WriteNewLine(); } + /// public override string ToString() { return $"{Point.X} {Point.Y} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/CloseSubpath.cs b/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/CloseSubpath.cs index 2185c7f8..8abe0429 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/CloseSubpath.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/PathConstruction/CloseSubpath.cs @@ -1,31 +1,45 @@ namespace UglyToad.PdfPig.Graphics.Operations.PathConstruction { using System.IO; - using Content; - internal class CloseSubpath : IGraphicsStateOperation + /// + /// + /// Close the current subpath by appending a straight line segment from the current point to the starting point of the subpath. + /// If the current subpath is already closed, this does nothing. + /// + public class CloseSubpath : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "h"; + /// + /// The instance of the operation. + /// public static readonly CloseSubpath Value = new CloseSubpath(); + /// public string Operator => Symbol; private CloseSubpath() { } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { operationContext.CurrentPath.ClosePath(); } + /// public void Write(Stream stream) { stream.WriteText(Symbol); stream.WriteNewLine(); } + /// public override string ToString() { return Symbol; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceCmyk.cs b/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceCmyk.cs index 2264aac8..1e86cf69 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceCmyk.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceCmyk.cs @@ -1,12 +1,12 @@ namespace UglyToad.PdfPig.Graphics.Operations { using System.IO; - using Content; + /// /// /// Set the non-stroking color space to DeviceCMYK and set the color to use for stroking operations. /// - internal class SetNonStrokeColorDeviceCmyk : IGraphicsStateOperation + public class SetNonStrokeColorDeviceCmyk : IGraphicsStateOperation { /// /// The symbol for this operation in a stream. @@ -52,7 +52,7 @@ } /// - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + public void Run(IOperationContext operationContext) { } diff --git a/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceGray.cs b/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceGray.cs index 35a8f50b..e92cb399 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceGray.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceGray.cs @@ -1,8 +1,8 @@ namespace UglyToad.PdfPig.Graphics.Operations { using System.IO; - using Content; + /// /// /// Set the gray level for non-stroking operations. /// @@ -31,7 +31,7 @@ } /// - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + public void Run(IOperationContext operationContext) { } diff --git a/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceRgb.cs b/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceRgb.cs index 184cd4b1..95bcdfb7 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceRgb.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceRgb.cs @@ -1,12 +1,12 @@ namespace UglyToad.PdfPig.Graphics.Operations { using System.IO; - using Content; + /// /// /// Set RGB color for non-stroking operations. /// - internal class SetNonStrokeColorDeviceRgb : IGraphicsStateOperation + public class SetNonStrokeColorDeviceRgb : IGraphicsStateOperation { /// /// The symbol for this operation in a stream. @@ -45,7 +45,7 @@ } /// - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + public void Run(IOperationContext operationContext) { } diff --git a/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceCmyk.cs b/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceCmyk.cs index b64cf996..a459137f 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceCmyk.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceCmyk.cs @@ -1,8 +1,8 @@ namespace UglyToad.PdfPig.Graphics.Operations { using System.IO; - using Content; + /// /// /// Set the stroking color space to DeviceCMYK and set the color to use for stroking operations. /// @@ -52,7 +52,7 @@ } /// - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + public void Run(IOperationContext operationContext) { } diff --git a/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceGray.cs b/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceGray.cs index aea58bc2..38c5f437 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceGray.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceGray.cs @@ -1,8 +1,8 @@ namespace UglyToad.PdfPig.Graphics.Operations { using System.IO; - using Content; + /// /// /// Set the gray level for stroking operations. /// @@ -31,7 +31,7 @@ } /// - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + public void Run(IOperationContext operationContext) { } diff --git a/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceRgb.cs b/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceRgb.cs index 7bfeeff9..6b5cf44c 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceRgb.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceRgb.cs @@ -1,12 +1,12 @@ namespace UglyToad.PdfPig.Graphics.Operations { using System.IO; - using Content; + /// /// /// Set RGB color for stroking operations. /// - internal class SetStrokeColorDeviceRgb : IGraphicsStateOperation + public class SetStrokeColorDeviceRgb : IGraphicsStateOperation { /// /// The symbol for this operation in a stream. @@ -45,7 +45,7 @@ } /// - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + public void Run(IOperationContext operationContext) { } diff --git a/src/UglyToad.PdfPig/Graphics/Operations/SpecialGraphicsState/ModifyCurrentTransformationMatrix.cs b/src/UglyToad.PdfPig/Graphics/Operations/SpecialGraphicsState/ModifyCurrentTransformationMatrix.cs index b7bf4c3f..f6a33234 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/SpecialGraphicsState/ModifyCurrentTransformationMatrix.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/SpecialGraphicsState/ModifyCurrentTransformationMatrix.cs @@ -2,20 +2,31 @@ { using System; using System.IO; - using Content; using PdfPig.Core; + /// /// /// Modify the current transformation matrix by concatenating the specified matrix. /// - internal class ModifyCurrentTransformationMatrix : IGraphicsStateOperation + public class ModifyCurrentTransformationMatrix : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "cm"; + /// public string Operator => Symbol; + /// + /// The 6 values for the transformation matrix. + /// public decimal[] Value { get; } + /// + /// Create a new . + /// + /// The 6 transformation matrix values. public ModifyCurrentTransformationMatrix(decimal[] value) { if (value == null) @@ -30,7 +41,8 @@ Value = value; } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { var newMatrix = TransformationMatrix.FromArray(Value); @@ -41,6 +53,7 @@ operationContext.GetCurrentState().CurrentTransformationMatrix = newCtm; } + /// public void Write(Stream stream) { stream.WriteDecimal(Value[0]); @@ -59,6 +72,7 @@ stream.WriteNewLine(); } + /// public override string ToString() { return $"{Value[0]} {Value[1]} {Value[2]} {Value[3]} {Value[4]} {Value[5]} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/SpecialGraphicsState/Pop.cs b/src/UglyToad.PdfPig/Graphics/Operations/SpecialGraphicsState/Pop.cs index f22cbd77..ad343f07 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/SpecialGraphicsState/Pop.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/SpecialGraphicsState/Pop.cs @@ -2,24 +2,32 @@ { using System; using System.IO; - using Content; + /// /// /// Restore the graphics state by removing the most recently saved state from the stack and making it the current state. /// - internal class Pop : IGraphicsStateOperation + public class Pop : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "Q"; + /// + /// The instance of the operation. + /// public static readonly Pop Value = new Pop(); + /// public string Operator => Symbol; private Pop() { } - - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + + /// + public void Run(IOperationContext operationContext) { var currentStackSize = operationContext.StackSize; if (currentStackSize > 1) @@ -32,12 +40,14 @@ } } + /// public void Write(Stream stream) { stream.WriteText(Symbol); stream.WriteNewLine(); } + /// public override string ToString() { return Symbol; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/SpecialGraphicsState/Push.cs b/src/UglyToad.PdfPig/Graphics/Operations/SpecialGraphicsState/Push.cs index a363d2a3..709d6ec1 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/SpecialGraphicsState/Push.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/SpecialGraphicsState/Push.cs @@ -1,33 +1,44 @@ namespace UglyToad.PdfPig.Graphics.Operations.SpecialGraphicsState { using System.IO; - using Content; + /// /// /// Save the current graphics state on the graphics state stack. /// - internal class Push : IGraphicsStateOperation + public class Push : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "q"; + + /// + /// The instance of the operation. + /// public static readonly Push Value = new Push(); + /// public string Operator => Symbol; private Push() { } - public void Run(IOperationContext context, IResourceStore resourceStore) + /// + public void Run(IOperationContext context) { context.PushState(); } + /// public void Write(Stream stream) { stream.WriteText(Symbol); stream.WriteNewLine(); } + /// public override string ToString() { return Symbol; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/StrokePath.cs b/src/UglyToad.PdfPig/Graphics/Operations/StrokePath.cs index cfe54048..9ebd889a 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/StrokePath.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/StrokePath.cs @@ -1,31 +1,44 @@ namespace UglyToad.PdfPig.Graphics.Operations { using System.IO; - using Content; - internal class StrokePath : IGraphicsStateOperation + /// + /// + /// Stroke the path. + /// + public class StrokePath : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "S"; + /// + /// The instance of the operation. + /// public static readonly StrokePath Value = new StrokePath(); + /// public string Operator => Symbol; private StrokePath() { } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { operationContext.StrokePath(false); } + /// public void Write(Stream stream) { stream.WriteText(Symbol); stream.WriteNewLine(); } + /// public override string ToString() { return Symbol; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/TextObjects/BeginText.cs b/src/UglyToad.PdfPig/Graphics/Operations/TextObjects/BeginText.cs index 86e3fab0..f872f8dc 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/TextObjects/BeginText.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/TextObjects/BeginText.cs @@ -1,35 +1,46 @@ namespace UglyToad.PdfPig.Graphics.Operations.TextObjects { using System.IO; - using Content; using PdfPig.Core; + /// /// /// Begin a text object, initializing the text matrix and the text line matrix to the identity matrix. Text objects cannot be nested. /// - internal class BeginText : IGraphicsStateOperation + public class BeginText : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "BT"; + + /// + /// The instance of the operation. + /// public static readonly BeginText Value = new BeginText(); + /// public string Operator => Symbol; private BeginText() { } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { operationContext.TextMatrices.TextMatrix = TransformationMatrix.Identity; operationContext.TextMatrices.TextLineMatrix = TransformationMatrix.Identity; } + /// public void Write(Stream stream) { stream.WriteText(Symbol); stream.WriteNewLine(); } + /// public override string ToString() { return Symbol; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/TextObjects/EndText.cs b/src/UglyToad.PdfPig/Graphics/Operations/TextObjects/EndText.cs index 10f9b917..eaa298bd 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/TextObjects/EndText.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/TextObjects/EndText.cs @@ -1,35 +1,46 @@ namespace UglyToad.PdfPig.Graphics.Operations.TextObjects { using System.IO; - using Content; using PdfPig.Core; + /// /// /// End a text object, discarding the text matrix. /// - internal class EndText : IGraphicsStateOperation + public class EndText : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "ET"; + + /// + /// The instance of the operation. + /// public static readonly EndText Value = new EndText(); + /// public string Operator => Symbol; private EndText() { } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { operationContext.TextMatrices.TextMatrix = TransformationMatrix.Identity; operationContext.TextMatrices.TextLineMatrix = TransformationMatrix.Identity; } + /// public void Write(Stream stream) { stream.WriteText(Symbol); stream.WriteNewLine(); } + /// public override string ToString() { return Symbol; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/TextPositioning/MoveToNextLine.cs b/src/UglyToad.PdfPig/Graphics/Operations/TextPositioning/MoveToNextLine.cs index 4d737c3a..b9ee0025 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/TextPositioning/MoveToNextLine.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/TextPositioning/MoveToNextLine.cs @@ -1,8 +1,8 @@ namespace UglyToad.PdfPig.Graphics.Operations.TextPositioning { using System.IO; - using Content; + /// /// /// Move to the start of the next line. /// @@ -10,30 +10,41 @@ /// This performs this operation: 0 -Tl Td /// The offset is negative leading text (Tl) value, this is incorrect in the specification. /// - internal class MoveToNextLine : IGraphicsStateOperation + public class MoveToNextLine : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "T*"; + + /// + /// The instance of the operation. + /// public static readonly MoveToNextLine Value = new MoveToNextLine(); + /// public string Operator => Symbol; private MoveToNextLine() { } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { var tdOperation = new MoveToNextLineWithOffset(0, -1 * operationContext.GetCurrentState().FontState.Leading); - tdOperation.Run(operationContext, resourceStore); + tdOperation.Run(operationContext); } + /// public void Write(Stream stream) { stream.WriteText(Symbol); stream.WriteNewLine(); } + /// public override string ToString() { return Symbol; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/TextPositioning/MoveToNextLineWithOffset.cs b/src/UglyToad.PdfPig/Graphics/Operations/TextPositioning/MoveToNextLineWithOffset.cs index 985ad13f..d51e6d95 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/TextPositioning/MoveToNextLineWithOffset.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/TextPositioning/MoveToNextLineWithOffset.cs @@ -1,35 +1,51 @@ namespace UglyToad.PdfPig.Graphics.Operations.TextPositioning { using System.IO; - using Content; using PdfPig.Core; + /// /// /// Move to the start of the next line offset by Tx Ty. /// /// /// Performs the following operation: - /// 1 0 0
- /// Tm = Tlm = 0 1 0 * Tlm
+ /// 1 0 0
+ /// Tm = Tlm = 0 1 0 * Tlm
/// tx ty 1 ///
internal class MoveToNextLineWithOffset : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "Td"; + /// public string Operator => Symbol; + /// + /// The x value of the offset. + /// public decimal Tx { get; } + /// + /// The y value of the offset. + /// public decimal Ty { get; } + /// + /// Create a new . + /// + /// The x offset. + /// The y offset. public MoveToNextLineWithOffset(decimal tx, decimal ty) { Tx = tx; Ty = ty; } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { var currentTextLineMatrix = operationContext.TextMatrices.TextLineMatrix; @@ -41,6 +57,7 @@ operationContext.TextMatrices.TextMatrix = transformed; } + /// public void Write(Stream stream) { stream.WriteDecimal(Tx); @@ -51,6 +68,7 @@ stream.WriteNewLine(); } + /// public override string ToString() { return $"{Tx} {Ty} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/TextPositioning/MoveToNextLineWithOffsetSetLeading.cs b/src/UglyToad.PdfPig/Graphics/Operations/TextPositioning/MoveToNextLineWithOffsetSetLeading.cs index 440b360d..a113f8a0 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/TextPositioning/MoveToNextLineWithOffsetSetLeading.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/TextPositioning/MoveToNextLineWithOffsetSetLeading.cs @@ -1,17 +1,21 @@ namespace UglyToad.PdfPig.Graphics.Operations.TextPositioning { using System.IO; - using Content; using TextState; + /// /// /// Move to the start of the next line, offset from the start of the current line by (tx, ty). /// This operator also sets the leading parameter in the text state. /// internal class MoveToNextLineWithOffsetSetLeading : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "TD"; + /// public string Operator => Symbol; public decimal Tx { get; } @@ -24,17 +28,19 @@ Ty = ty; } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { var tlOperation = new SetTextLeading(-Ty); - tlOperation.Run(operationContext, resourceStore); + tlOperation.Run(operationContext); var tdOperation = new MoveToNextLineWithOffset(Tx, Ty); - tdOperation.Run(operationContext, resourceStore); + tdOperation.Run(operationContext); } + /// public void Write(Stream stream) { stream.WriteDecimal(Tx); @@ -45,6 +51,7 @@ stream.WriteNewLine(); } + /// public override string ToString() { return $"{Tx} {Ty} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/TextPositioning/SetTextMatrix.cs b/src/UglyToad.PdfPig/Graphics/Operations/TextPositioning/SetTextMatrix.cs index 53718c8a..a755a9c0 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/TextPositioning/SetTextMatrix.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/TextPositioning/SetTextMatrix.cs @@ -2,16 +2,20 @@ { using System; using System.IO; - using Content; using PdfPig.Core; + /// /// /// Set the text matrix and the text line matrix. /// internal class SetTextMatrix : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "Tm"; + /// public string Operator => Symbol; public decimal[] Value { get; } @@ -25,8 +29,9 @@ Value = value; } - - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + + /// + public void Run(IOperationContext operationContext) { var newMatrix = TransformationMatrix.FromArray(Value); @@ -34,6 +39,7 @@ operationContext.TextMatrices.TextLineMatrix = newMatrix; } + /// public void Write(Stream stream) { stream.WriteDecimal(Value[0]); @@ -52,6 +58,7 @@ stream.WriteNewLine(); } + /// public override string ToString() { return $"{Value[0]} {Value[1]} {Value[2]} {Value[3]} {Value[4]} {Value[5]} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/MoveToNextLineShowText.cs b/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/MoveToNextLineShowText.cs index 33546963..88d82aea 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/MoveToNextLineShowText.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/MoveToNextLineShowText.cs @@ -3,14 +3,14 @@ using System; using System.IO; using System.Linq; - using Content; using TextPositioning; using Util.JetBrains.Annotations; + /// /// /// Move to the next line and show a text string. /// - internal class MoveToNextLineShowText : IGraphicsStateOperation + public class MoveToNextLineShowText : IGraphicsStateOperation { /// /// The symbol for this operation in a stream. @@ -51,14 +51,14 @@ } /// - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + public void Run(IOperationContext operationContext) { var move = MoveToNextLine.Value; var showText = Text != null ? new ShowText(Text) : new ShowText(Bytes); - move.Run(operationContext, resourceStore); - showText.Run(operationContext, resourceStore); + move.Run(operationContext); + showText.Run(operationContext); } /// diff --git a/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/MoveToNextLineShowTextWithSpacing.cs b/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/MoveToNextLineShowTextWithSpacing.cs index be141740..62bde629 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/MoveToNextLineShowTextWithSpacing.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/MoveToNextLineShowTextWithSpacing.cs @@ -1,27 +1,52 @@ namespace UglyToad.PdfPig.Graphics.Operations.TextShowing { using System.IO; - using Content; using TextPositioning; using TextState; using Util.JetBrains.Annotations; - internal class MoveToNextLineShowTextWithSpacing : IGraphicsStateOperation + /// + /// + /// Move to the next line and show a text string, using the first number as the word spacing and the second as the character spacing + /// + public class MoveToNextLineShowTextWithSpacing : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "\""; + /// public string Operator => Symbol; + /// + /// The word spacing. + /// public decimal WordSpacing { get; } + /// + /// The character spacing. + /// public decimal CharacterSpacing { get; } + /// + /// The bytes of the text. + /// [CanBeNull] public byte[] Bytes { get; } + /// + /// The text to show. + /// [CanBeNull] public string Text { get; } + /// + /// Create a new . + /// + /// The word spacing. + /// The character spacing. + /// The text to show. public MoveToNextLineShowTextWithSpacing(decimal wordSpacing, decimal characterSpacing, string text) { WordSpacing = wordSpacing; @@ -29,6 +54,12 @@ Text = text; } + /// + /// Create a new . + /// + /// The word spacing. + /// The character spacing. + /// The bytes of the text to show. public MoveToNextLineShowTextWithSpacing(decimal wordSpacing, decimal characterSpacing, byte[] hexBytes) { WordSpacing = wordSpacing; @@ -36,24 +67,27 @@ Bytes = hexBytes; } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { var setWordSpacing = new SetWordSpacing(WordSpacing); var setCharacterSpacing = new SetCharacterSpacing(CharacterSpacing); var moveToNextLine = MoveToNextLine.Value; var showText = Text != null ? new ShowText(Text) : new ShowText(Bytes); - setWordSpacing.Run(operationContext, resourceStore); - setCharacterSpacing.Run(operationContext, resourceStore); - moveToNextLine.Run(operationContext, resourceStore); - showText.Run(operationContext, resourceStore); + setWordSpacing.Run(operationContext); + setCharacterSpacing.Run(operationContext); + moveToNextLine.Run(operationContext); + showText.Run(operationContext); } + /// public void Write(Stream stream) { throw new System.NotImplementedException(); } + /// public override string ToString() { return $"{WordSpacing} {CharacterSpacing} {Text} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/ShowText.cs b/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/ShowText.cs index a249d839..288bd01b 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/ShowText.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/ShowText.cs @@ -2,11 +2,11 @@ { using System; using System.IO; - using Content; using IO; using Util; using Util.JetBrains.Annotations; + /// /// /// Show a text string /// @@ -15,43 +15,61 @@ /// /// Generally each byte represents a single character code, however starting in version 1.2+ /// a composite font might use multi-byte character codes to map to glyphs. - /// For these composite fonts, the of the font defines the mapping from code to glyph. + /// For these composite fonts, the of the font defines the mapping from code to glyph. /// /// - /// The grouping of character codes in arguments to this operator does not have any impact on the meaning; for example:
- /// (Abc) Tj is equivalent to (A) Tj (b) Tj (c) Tj
+ /// The grouping of character codes in arguments to this operator does not have any impact on the meaning; for example:
+ /// (Abc) Tj is equivalent to (A) Tj (b) Tj (c) Tj
/// However grouping character codes makes the document easier to search and extract text from. ///
/// - internal class ShowText : IGraphicsStateOperation + public class ShowText : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "Tj"; + /// public string Operator => Symbol; + /// + /// The text string to show. + /// [CanBeNull] public string Text { get; } + /// + /// The bytes of the string to show. + /// [CanBeNull] public byte[] Bytes { get; } + /// + /// Create a new . + /// public ShowText(string text) { Text = text; } + /// + /// Create a new . + /// public ShowText(byte[] hexBytes) { Bytes = hexBytes; } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { var input = new ByteArrayInputBytes(Text != null ? OtherEncodings.StringAsLatin1Bytes(Text) : Bytes); operationContext.ShowText(input); } + /// public void Write(Stream stream) { if (Text == null && Bytes != null) @@ -65,6 +83,7 @@ stream.WriteNewLine(); } + /// public override string ToString() { return $"{Text} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/ShowTextsWithPositioning.cs b/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/ShowTextsWithPositioning.cs index 9e135e63..0d8ae41e 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/ShowTextsWithPositioning.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/ShowTextsWithPositioning.cs @@ -3,17 +3,34 @@ using System; using System.Collections.Generic; using System.IO; - using Content; using Tokens; + /// + /// + /// Show one or more text strings, allowing individual glyph positioning. + /// Each element of array can be a string or a number. + /// If the element is a string, this operator shows the string. + /// If it is a number, the operator adjusts the text position by that amount + /// internal class ShowTextsWithPositioning : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "TJ"; + /// public string Operator => Symbol; + /// + /// The array elements. + /// public IReadOnlyList Array { get; } + /// + /// Create a new . + /// + /// The array elements. public ShowTextsWithPositioning(IReadOnlyList array) { if (array == null) @@ -33,11 +50,13 @@ Array = array; } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { operationContext.ShowPositionedText(Array); } + /// public void Write(Stream stream) { throw new NotImplementedException(); diff --git a/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetCharacterSpacing.cs b/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetCharacterSpacing.cs index c5e739a9..4938a267 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetCharacterSpacing.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetCharacterSpacing.cs @@ -1,40 +1,51 @@ namespace UglyToad.PdfPig.Graphics.Operations.TextState { using System.IO; - using Content; + /// /// /// Set the character spacing to a number expressed in unscaled text space units. /// Initial value: 0. /// - internal class SetCharacterSpacing : IGraphicsStateOperation + public class SetCharacterSpacing : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "Tc"; + /// public string Operator => Symbol; + /// + /// The character spacing. + /// public decimal Spacing { get; } + /// + /// Create a new . + /// + /// The character spacing. public SetCharacterSpacing(decimal spacing) { Spacing = spacing; } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { var currentState = operationContext.GetCurrentState(); currentState.FontState.CharacterSpacing = Spacing; } + /// public void Write(Stream stream) { - stream.WriteDecimal(Spacing); - stream.WriteWhiteSpace(); - stream.WriteText(Symbol); - stream.WriteNewLine(); + stream.WriteNumberText(Spacing, Symbol); } + /// public override string ToString() { return $"{Spacing} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetFontAndSize.cs b/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetFontAndSize.cs index 5be81a85..926ddab7 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetFontAndSize.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetFontAndSize.cs @@ -2,14 +2,23 @@ { using System; using System.IO; - using Content; using Tokens; using Util.JetBrains.Annotations; - internal class SetFontAndSize : IGraphicsStateOperation + /// + /// + /// Set the font and the font size. + /// Font is the name of a font resource in the Font subdictionary of the current resource dictionary. + /// Size is a number representing a scale factor. + /// + public class SetFontAndSize : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "Tf"; + /// public string Operator => Symbol; /// @@ -24,13 +33,19 @@ /// public decimal Size { get; } + /// + /// Create a new . + /// + /// The font name. + /// The font size. public SetFontAndSize(NameToken font, decimal size) { Font = font ?? throw new ArgumentNullException(nameof(font)); Size = size; } - - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + + /// + public void Run(IOperationContext operationContext) { var currentState = operationContext.GetCurrentState(); @@ -38,16 +53,15 @@ currentState.FontState.FontName = Font; } + /// public void Write(Stream stream) { stream.WriteText(Font.ToString()); stream.WriteWhiteSpace(); - stream.WriteDecimal(Size); - stream.WriteWhiteSpace(); - stream.WriteText(Symbol); - stream.WriteNewLine(); + stream.WriteNumberText(Size, Symbol); } + /// public override string ToString() { return $"{Font} {Size} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetHorizontalScaling.cs b/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetHorizontalScaling.cs index 9734158f..a775db4a 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetHorizontalScaling.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetHorizontalScaling.cs @@ -1,33 +1,47 @@ namespace UglyToad.PdfPig.Graphics.Operations.TextState { using System.IO; - using Content; - internal class SetHorizontalScaling : IGraphicsStateOperation + /// + public class SetHorizontalScaling : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "Tz"; + /// public string Operator => Symbol; + /// + /// A number specifying the percentage of the normal width. + /// public decimal Scale { get; } + /// + /// Create a new . + /// + /// The horizontal scaling percentage. public SetHorizontalScaling(decimal scale) { Scale = scale; } - - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + + /// + public void Run(IOperationContext operationContext) { var currentState = operationContext.GetCurrentState(); currentState.FontState.HorizontalScaling = Scale; } + /// public void Write(Stream stream) { - throw new System.NotImplementedException(); + stream.WriteNumberText(Scale, Symbol); } + /// public override string ToString() { return $"{Scale} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetTextLeading.cs b/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetTextLeading.cs index cfb6eed0..7117bc67 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetTextLeading.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetTextLeading.cs @@ -1,33 +1,50 @@ namespace UglyToad.PdfPig.Graphics.Operations.TextState { using System.IO; - using Content; - internal class SetTextLeading : IGraphicsStateOperation + /// + /// + /// Set the text leading. + /// + public class SetTextLeading : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "TL"; + /// public string Operator => Symbol; + /// + /// The text leading in unscaled text space units. + /// public decimal Leading { get; } + /// + /// Create a new . + /// + /// The text leading. public SetTextLeading(decimal leading) { Leading = leading; } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { var currentState = operationContext.GetCurrentState(); currentState.FontState.Leading = Leading; } + /// public void Write(Stream stream) { - throw new System.NotImplementedException(); + stream.WriteNumberText(Leading, Symbol); } + /// public override string ToString() { return $"{Leading} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetTextRenderingMode.cs b/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetTextRenderingMode.cs index a07c8107..091d2261 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetTextRenderingMode.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetTextRenderingMode.cs @@ -1,34 +1,50 @@ namespace UglyToad.PdfPig.Graphics.Operations.TextState { using System.IO; - using Content; using Core; - internal class SetTextRenderingMode : IGraphicsStateOperation + /// + /// + /// Set the text rendering mode. + /// + public class SetTextRenderingMode : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "Tr"; + /// public string Operator => Symbol; - public RenderingMode Mode { get; } + /// + /// The text rendering mode to set. + /// + public TextRenderingMode Mode { get; } + /// + /// Create a new . + /// public SetTextRenderingMode(int mode) { - Mode = (RenderingMode)mode; + Mode = (TextRenderingMode)mode; } - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + /// + public void Run(IOperationContext operationContext) { var currentState = operationContext.GetCurrentState(); - currentState.FontState.RenderingMode = Mode; + currentState.FontState.TextRenderingMode = Mode; } + /// public void Write(Stream stream) { - throw new System.NotImplementedException(); + stream.WriteNumberText((int)Mode, Symbol); } + /// public override string ToString() { return $"{Mode} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetTextRise.cs b/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetTextRise.cs index 094f9632..0bf1c6e9 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetTextRise.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetTextRise.cs @@ -1,12 +1,12 @@ namespace UglyToad.PdfPig.Graphics.Operations.TextState { using System.IO; - using Content; + /// /// /// Set text rise. /// - internal class SetTextRise : IGraphicsStateOperation + public class SetTextRise : IGraphicsStateOperation { /// /// The symbol for this operation in a stream. @@ -31,7 +31,7 @@ } /// - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + public void Run(IOperationContext operationContext) { var currentState = operationContext.GetCurrentState(); diff --git a/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetWordSpacing.cs b/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetWordSpacing.cs index f40cc0fe..81dc45e4 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetWordSpacing.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/TextState/SetWordSpacing.cs @@ -1,12 +1,11 @@ namespace UglyToad.PdfPig.Graphics.Operations.TextState { using System.IO; - using Content; /// /// Sets the word spacing. /// - internal class SetWordSpacing : IGraphicsStateOperation + public class SetWordSpacing : IGraphicsStateOperation { /// /// The symbol for this operation in a stream. @@ -33,7 +32,7 @@ } /// - public void Run(IOperationContext operationContext, IResourceStore resourceStore) + public void Run(IOperationContext operationContext) { var currentState = operationContext.GetCurrentState(); diff --git a/src/UglyToad.PdfPig/Graphics/TextMatrices.cs b/src/UglyToad.PdfPig/Graphics/TextMatrices.cs index fa838c34..c21fbfc9 100644 --- a/src/UglyToad.PdfPig/Graphics/TextMatrices.cs +++ b/src/UglyToad.PdfPig/Graphics/TextMatrices.cs @@ -3,12 +3,19 @@ using PdfPig.Core; /// - /// Manages the Text Matrix (Tm), Text line matrix (Tlm) and Text Rendering Matrix (Trm). + /// Manages the Text Matrix (Tm), Text line matrix (Tlm) and used to generate the Text Rendering Matrix (Trm). /// - internal class TextMatrices + public class TextMatrices { + /// + /// The current text matrix (Tm). + /// public TransformationMatrix TextMatrix { get; set; } + /// + /// Captures the value of the at the beginning of a line of text. + /// This is convenient for aligning evenly spaced lines of text. + /// public TransformationMatrix TextLineMatrix { get; set; } } } \ No newline at end of file diff --git a/src/UglyToad.PdfPig/IO/IInputBytes.cs b/src/UglyToad.PdfPig/IO/IInputBytes.cs index 8ee38e0f..6d57fe5f 100644 --- a/src/UglyToad.PdfPig/IO/IInputBytes.cs +++ b/src/UglyToad.PdfPig/IO/IInputBytes.cs @@ -2,20 +2,45 @@ { using System; - internal interface IInputBytes : IDisposable + /// + /// + /// The input bytes for a PDF document. + /// + public interface IInputBytes : IDisposable { + /// + /// The current offset in bytes. + /// long CurrentOffset { get; } + /// + /// Moves to the next byte if available. + /// bool MoveNext(); + /// + /// The current byte. + /// byte CurrentByte { get; } + /// + /// The length of the data in bytes. + /// long Length { get; } + /// + /// Returns the next byte if available. + /// byte? Peek(); + /// + /// Whether we are at the end of the available data. + /// bool IsAtEnd(); + /// + /// Move to a given position. + /// void Seek(long position); } } \ No newline at end of file