diff --git a/src/UglyToad.PdfPig/Graphics/Operations/CloseAndStrokePath.cs b/src/UglyToad.PdfPig/Graphics/Operations/CloseAndStrokePath.cs index 6c440852..0503f734 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/CloseAndStrokePath.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/CloseAndStrokePath.cs @@ -3,29 +3,42 @@ using System.IO; using Content; + /// + /// Close and stroke the path. + /// internal class CloseAndStrokePath : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "s"; + /// + /// The instance of the operation. + /// public static readonly CloseAndStrokePath Value = new CloseAndStrokePath(); + /// public string Operator => Symbol; private CloseAndStrokePath() { } + /// public void Run(IOperationContext operationContext, IResourceStore resourceStore) { operationContext.StrokePath(true); } + /// public void Write(Stream stream) { stream.WriteText(Symbol); stream.WriteNewLine(); } + /// public override string ToString() { return Symbol; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/CloseFillPathEvenOddRuleAndStroke.cs b/src/UglyToad.PdfPig/Graphics/Operations/CloseFillPathEvenOddRuleAndStroke.cs index db2c8d8b..94c0debc 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/CloseFillPathEvenOddRuleAndStroke.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/CloseFillPathEvenOddRuleAndStroke.cs @@ -3,27 +3,41 @@ using System.IO; using Content; + /// + /// Close, fill, and then stroke the path, using the even-odd rule to determine the region to fill. + /// internal class CloseFillPathEvenOddRuleAndStroke : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "b*"; + /// + /// The instance of the operation. + /// public static readonly CloseFillPathEvenOddRuleAndStroke Value = new CloseFillPathEvenOddRuleAndStroke(); + /// public string Operator => Symbol; private CloseFillPathEvenOddRuleAndStroke() { } + /// public void Run(IOperationContext operationContext, IResourceStore resourceStore) { } + /// 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/CloseFillPathNonZeroWindingAndStroke.cs b/src/UglyToad.PdfPig/Graphics/Operations/CloseFillPathNonZeroWindingAndStroke.cs index f6dfbdc6..2d6d1f55 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/CloseFillPathNonZeroWindingAndStroke.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/CloseFillPathNonZeroWindingAndStroke.cs @@ -3,27 +3,41 @@ using System.IO; using Content; + /// + /// Close, fill, and then stroke the path, using the nonzero winding number rule to determine the region to fill. + /// internal class CloseFillPathNonZeroWindingAndStroke : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "b"; - + + /// + /// The instance of the operation. + /// public static readonly CloseFillPathNonZeroWindingAndStroke Value = new CloseFillPathNonZeroWindingAndStroke(); + /// public string Operator => Symbol; private CloseFillPathNonZeroWindingAndStroke() { } + /// public void Run(IOperationContext operationContext, IResourceStore resourceStore) { } + /// 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/FillPathEvenOddRule.cs b/src/UglyToad.PdfPig/Graphics/Operations/FillPathEvenOddRule.cs index c4e33de3..d9286de6 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/FillPathEvenOddRule.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/FillPathEvenOddRule.cs @@ -3,27 +3,41 @@ using System.IO; using Content; + /// + /// Fill the path, using the even-odd rule to determine the region to fill. + /// internal class FillPathEvenOddRule : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "f*"; + /// + /// The instance of the operation. + /// public static readonly FillPathEvenOddRule Value = new FillPathEvenOddRule(); + /// public string Operator => Symbol; private FillPathEvenOddRule() { } + /// public void Run(IOperationContext operationContext, IResourceStore resourceStore) { } + /// 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/FillPathEvenOddRuleAndStroke.cs b/src/UglyToad.PdfPig/Graphics/Operations/FillPathEvenOddRuleAndStroke.cs index c86fb06b..dcd974fe 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/FillPathEvenOddRuleAndStroke.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/FillPathEvenOddRuleAndStroke.cs @@ -3,27 +3,41 @@ using System.IO; using Content; + /// + /// Fill and then stroke the path, using the even-odd rule to determine the region to fill. + /// internal class FillPathEvenOddRuleAndStroke : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "B*"; + /// + /// The instance of the operation. + /// public static readonly FillPathEvenOddRuleAndStroke Value = new FillPathEvenOddRuleAndStroke(); + /// public string Operator => Symbol; private FillPathEvenOddRuleAndStroke() { } + /// public void Run(IOperationContext operationContext, IResourceStore resourceStore) { } + /// 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/FillPathNonZeroWinding.cs b/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWinding.cs index aa6731f0..27bf8de9 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWinding.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWinding.cs @@ -3,27 +3,42 @@ 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 { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "f"; + /// + /// The instance of the operation. + /// public static readonly FillPathNonZeroWinding Value = new FillPathNonZeroWinding(); + /// public string Operator => Symbol; private FillPathNonZeroWinding() { } + /// public void Run(IOperationContext operationContext, IResourceStore resourceStore) { } + /// 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/FillPathNonZeroWindingAndStroke.cs b/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWindingAndStroke.cs index 1ce7d630..ef6d9abc 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWindingAndStroke.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWindingAndStroke.cs @@ -3,27 +3,41 @@ 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 { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "B"; + /// + /// The instance of the operation. + /// public static readonly FillPathNonZeroWindingAndStroke Value = new FillPathNonZeroWindingAndStroke(); + /// public string Operator => Symbol; private FillPathNonZeroWindingAndStroke() { } + /// public void Run(IOperationContext operationContext, IResourceStore resourceStore) { } + /// 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/FillPathNonZeroWindingCompatibility.cs b/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWindingCompatibility.cs index ee9bcffb..0a8f1959 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWindingCompatibility.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/FillPathNonZeroWindingCompatibility.cs @@ -3,27 +3,42 @@ 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 { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "F"; + /// + /// The instance of the operation. + /// public static readonly FillPathNonZeroWindingCompatibility Value = new FillPathNonZeroWindingCompatibility(); + /// public string Operator => Symbol; private FillPathNonZeroWindingCompatibility() { } + /// public void Run(IOperationContext operationContext, IResourceStore resourceStore) { } + /// 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/InvokeNamedXObject.cs b/src/UglyToad.PdfPig/Graphics/Operations/InvokeNamedXObject.cs index 6f63ed90..522c4a3f 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/InvokeNamedXObject.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/InvokeNamedXObject.cs @@ -4,19 +4,37 @@ 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. + /// internal class InvokeNamedXObject : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "Do"; + /// public string Operator => Symbol; + /// + /// The name of the XObject which appears in the XObject subdictionary of the current resource dictionary. + /// public NameToken Name { get; } + /// + /// Create a new . + /// + /// The name of the XObject. public InvokeNamedXObject(NameToken name) { Name = name; } + /// public void Run(IOperationContext operationContext, IResourceStore resourceStore) { var xobject = resourceStore.GetXObject(Name); @@ -24,11 +42,16 @@ operationContext.ApplyXObject(xobject); } + /// public void Write(Stream stream) { - throw new System.NotImplementedException(); + stream.WriteText($"/{Name}"); + stream.WriteWhiteSpace(); + stream.WriteText(Symbol); + stream.WriteNewLine(); } + /// public override string ToString() { return $"{Name} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceCmyk.cs b/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceCmyk.cs index 9d6fde55..2264aac8 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceCmyk.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceCmyk.cs @@ -3,20 +3,46 @@ 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 { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "K"; + /// public string Operator => Symbol; + /// + /// The cyan level between 0 and 1. + /// public decimal C { get; } + /// + /// The magenta level between 0 and 1. + /// public decimal M { get; } + /// + /// The yellow level between 0 and 1. + /// public decimal Y { get; } + /// + /// The key level between 0 and 1. + /// public decimal K { get; } + /// + /// Create a new . + /// + /// The cyan level. + /// The magenta level. + /// The yellow level. + /// The key level. public SetNonStrokeColorDeviceCmyk(decimal c, decimal m, decimal y, decimal k) { C = c; @@ -25,15 +51,27 @@ K = k; } + /// public void Run(IOperationContext operationContext, IResourceStore resourceStore) { } + /// public void Write(Stream stream) { - throw new System.NotImplementedException(); + stream.WriteDecimal(C); + stream.WriteWhiteSpace(); + stream.WriteDecimal(M); + stream.WriteWhiteSpace(); + stream.WriteDecimal(Y); + stream.WriteWhiteSpace(); + stream.WriteDecimal(K); + stream.WriteWhiteSpace(); + stream.WriteText(Symbol); + stream.WriteNewLine(); } + /// public override string ToString() { return $"{C} {M} {Y} {K} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceGray.cs b/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceGray.cs index e0b3332b..35a8f50b 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceGray.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceGray.cs @@ -3,28 +3,45 @@ using System.IO; using Content; + /// + /// Set the gray level for non-stroking operations. + /// internal class SetNonStrokeColorDeviceGray : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "g"; + /// public string Operator => Symbol; + /// + /// The gray level between 0 (black) and 1 (white). + /// public decimal Gray { get; } + /// + /// Create a new . + /// + /// The gray level. public SetNonStrokeColorDeviceGray(decimal gray) { Gray = gray; } + /// public void Run(IOperationContext operationContext, IResourceStore resourceStore) { } + /// public void Write(Stream stream) { - throw new System.NotImplementedException(); + stream.WriteNumberText(Gray, Symbol); } + /// public override string ToString() { return $"{Gray} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceRgb.cs b/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceRgb.cs index 356bdbc0..184cd4b1 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceRgb.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/SetNonStrokeColorDeviceRgb.cs @@ -3,18 +3,40 @@ using System.IO; using Content; + /// + /// Set RGB color for non-stroking operations. + /// internal class SetNonStrokeColorDeviceRgb : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "rg"; + /// public string Operator => Symbol; + /// + /// The red level between 0 and 1. + /// public decimal R { get; } + /// + /// The green level between 0 and 1. + /// public decimal G { get; } + /// + /// The blue level between 0 and 1. + /// public decimal B { get; } + /// + /// Create a new . + /// + /// The red level. + /// The green level. + /// The blue level. public SetNonStrokeColorDeviceRgb(decimal r, decimal g, decimal b) { R = r; @@ -22,10 +44,12 @@ B = b; } + /// public void Run(IOperationContext operationContext, IResourceStore resourceStore) { } + /// public void Write(Stream stream) { stream.WriteDecimal(R); @@ -38,6 +62,7 @@ stream.WriteNewLine(); } + /// public override string ToString() { return $"{R} {G} {B} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceCmyk.cs b/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceCmyk.cs index de8db880..b64cf996 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceCmyk.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceCmyk.cs @@ -3,20 +3,46 @@ using System.IO; using Content; + /// + /// Set the stroking color space to DeviceCMYK and set the color to use for stroking operations. + /// internal class SetStrokeColorDeviceCmyk : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "K"; - + + /// public string Operator => Symbol; + /// + /// The cyan level between 0 and 1. + /// public decimal C { get; } + /// + /// The magenta level between 0 and 1. + /// public decimal M { get; } + /// + /// The yellow level between 0 and 1. + /// public decimal Y { get; } + /// + /// The key level between 0 and 1. + /// public decimal K { get; } + /// + /// Create a new . + /// + /// The cyan level. + /// The magenta level. + /// The yellow level. + /// The key level. public SetStrokeColorDeviceCmyk(decimal c, decimal m, decimal y, decimal k) { C = c; @@ -25,15 +51,27 @@ K = k; } + /// public void Run(IOperationContext operationContext, IResourceStore resourceStore) { } + /// public void Write(Stream stream) { - throw new System.NotImplementedException(); + stream.WriteDecimal(C); + stream.WriteWhiteSpace(); + stream.WriteDecimal(M); + stream.WriteWhiteSpace(); + stream.WriteDecimal(Y); + stream.WriteWhiteSpace(); + stream.WriteDecimal(K); + stream.WriteWhiteSpace(); + stream.WriteText(Symbol); + stream.WriteNewLine(); } + /// public override string ToString() { return $"{C} {M} {Y} {K} {Symbol}"; diff --git a/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceGray.cs b/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceGray.cs index 63e2c352..aea58bc2 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceGray.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceGray.cs @@ -8,6 +8,9 @@ /// internal class SetStrokeColorDeviceGray : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "G"; /// @@ -35,10 +38,7 @@ /// public void Write(Stream stream) { - stream.WriteDecimal(Gray); - stream.WriteWhiteSpace(); - stream.WriteText(Symbol); - stream.WriteNewLine(); + stream.WriteNumberText(Gray, Symbol); } /// diff --git a/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceRgb.cs b/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceRgb.cs index e353d828..7bfeeff9 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceRgb.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/SetStrokeColorDeviceRgb.cs @@ -8,6 +8,9 @@ /// internal class SetStrokeColorDeviceRgb : IGraphicsStateOperation { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "RG"; /// diff --git a/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/MoveToNextLineShowText.cs b/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/MoveToNextLineShowText.cs index 979a00c8..33546963 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/MoveToNextLineShowText.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/TextShowing/MoveToNextLineShowText.cs @@ -1,32 +1,56 @@ namespace UglyToad.PdfPig.Graphics.Operations.TextShowing { + 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 { + /// + /// The symbol for this operation in a stream. + /// public const string Symbol = "'"; + /// public string Operator => Symbol; + /// + /// The text to show as a . + /// [CanBeNull] public string Text { get; } + /// + /// The text to show as hex bytes. + /// [CanBeNull] public byte[] Bytes { get; } + /// + /// Create a new . + /// + /// The text to show. public MoveToNextLineShowText(string text) { Text = text; } - + + /// + /// Create a new . + /// + /// The bytes of the text to show. public MoveToNextLineShowText(byte[] hexBytes) { Bytes = hexBytes; } + /// public void Run(IOperationContext operationContext, IResourceStore resourceStore) { var move = MoveToNextLine.Value; @@ -37,11 +61,23 @@ showText.Run(operationContext, resourceStore); } + /// public void Write(Stream stream) { - throw new System.NotImplementedException(); + if (Bytes == null) + { + stream.WriteText($"({Text}) {Symbol}"); + stream.WriteNewLine(); + } + else + { + var hex = BitConverter.ToString(Bytes.ToArray()).Replace("-", string.Empty); + stream.WriteText($"<{hex}> {Symbol}"); + stream.WriteNewLine(); + } } + /// public override string ToString() { return $"{Text} {Symbol}";