mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-15 11:44:51 +08:00
#26 prepare more content stream operations for public api
This commit is contained in:
@@ -3,29 +3,42 @@
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <summary>
|
||||
/// Close and stroke the path.
|
||||
/// </summary>
|
||||
internal class CloseAndStrokePath : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "s";
|
||||
|
||||
/// <summary>
|
||||
/// The instance of the <see cref="CloseAndStrokePath"/> operation.
|
||||
/// </summary>
|
||||
public static readonly CloseAndStrokePath Value = new CloseAndStrokePath();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
private CloseAndStrokePath()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
{
|
||||
operationContext.StrokePath(true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Symbol;
|
||||
|
@@ -3,27 +3,41 @@
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <summary>
|
||||
/// Close, fill, and then stroke the path, using the even-odd rule to determine the region to fill.
|
||||
/// </summary>
|
||||
internal class CloseFillPathEvenOddRuleAndStroke : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "b*";
|
||||
|
||||
/// <summary>
|
||||
/// The instance of the <see cref="CloseFillPathEvenOddRuleAndStroke"/> operation.
|
||||
/// </summary>
|
||||
public static readonly CloseFillPathEvenOddRuleAndStroke Value = new CloseFillPathEvenOddRuleAndStroke();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
private CloseFillPathEvenOddRuleAndStroke()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Symbol;
|
||||
|
@@ -3,27 +3,41 @@
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <summary>
|
||||
/// Close, fill, and then stroke the path, using the nonzero winding number rule to determine the region to fill.
|
||||
/// </summary>
|
||||
internal class CloseFillPathNonZeroWindingAndStroke : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "b";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The instance of the <see cref="CloseFillPathNonZeroWindingAndStroke"/> operation.
|
||||
/// </summary>
|
||||
public static readonly CloseFillPathNonZeroWindingAndStroke Value = new CloseFillPathNonZeroWindingAndStroke();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
private CloseFillPathNonZeroWindingAndStroke()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Symbol;
|
||||
|
@@ -3,27 +3,41 @@
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <summary>
|
||||
/// Fill the path, using the even-odd rule to determine the region to fill.
|
||||
/// </summary>
|
||||
internal class FillPathEvenOddRule : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "f*";
|
||||
|
||||
/// <summary>
|
||||
/// The instance of the <see cref="FillPathEvenOddRule"/> operation.
|
||||
/// </summary>
|
||||
public static readonly FillPathEvenOddRule Value = new FillPathEvenOddRule();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
private FillPathEvenOddRule()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Symbol;
|
||||
|
@@ -3,27 +3,41 @@
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <summary>
|
||||
/// Fill and then stroke the path, using the even-odd rule to determine the region to fill.
|
||||
/// </summary>
|
||||
internal class FillPathEvenOddRuleAndStroke : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "B*";
|
||||
|
||||
/// <summary>
|
||||
/// The instance of the <see cref="FillPathEvenOddRuleAndStroke"/> operation.
|
||||
/// </summary>
|
||||
public static readonly FillPathEvenOddRuleAndStroke Value = new FillPathEvenOddRuleAndStroke();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
private FillPathEvenOddRuleAndStroke()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Symbol;
|
||||
|
@@ -3,27 +3,42 @@
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
internal class FillPathNonZeroWinding : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "f";
|
||||
|
||||
/// <summary>
|
||||
/// The instance of the <see cref="FillPathNonZeroWinding"/> operation.
|
||||
/// </summary>
|
||||
public static readonly FillPathNonZeroWinding Value = new FillPathNonZeroWinding();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
private FillPathNonZeroWinding()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Symbol;
|
||||
|
@@ -3,27 +3,41 @@
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <summary>
|
||||
/// Fill and then stroke the path, using the nonzero winding number rule to determine the region to fill.
|
||||
/// </summary>
|
||||
internal class FillPathNonZeroWindingAndStroke : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "B";
|
||||
|
||||
/// <summary>
|
||||
/// The instance of the <see cref="FillPathNonZeroWindingAndStroke"/> operation.
|
||||
/// </summary>
|
||||
public static readonly FillPathNonZeroWindingAndStroke Value = new FillPathNonZeroWindingAndStroke();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
private FillPathNonZeroWindingAndStroke()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Symbol;
|
||||
|
@@ -3,27 +3,42 @@
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <summary>
|
||||
/// Equivalent to <see cref="FillPathNonZeroWinding"/> included only for compatibility.
|
||||
/// Although PDF consumer applications must be able to accept this operator, PDF producer applications should use <see cref="FillPathNonZeroWinding"/> instead.
|
||||
/// </summary>
|
||||
internal class FillPathNonZeroWindingCompatibility : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "F";
|
||||
|
||||
/// <summary>
|
||||
/// The instance of the <see cref="FillPathEvenOddRuleAndStroke"/> operation.
|
||||
/// </summary>
|
||||
public static readonly FillPathNonZeroWindingCompatibility Value = new FillPathNonZeroWindingCompatibility();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
private FillPathNonZeroWindingCompatibility()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Symbol;
|
||||
|
@@ -4,19 +4,37 @@
|
||||
using Content;
|
||||
using Tokens;
|
||||
|
||||
/// <summary>
|
||||
/// 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 <see cref="InvokeNamedXObject"/> depends on the value of the XObject's Subtype entry, which may be Image, Form or PS.
|
||||
/// </summary>
|
||||
internal class InvokeNamedXObject : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "Do";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The name of the XObject which appears in the XObject subdictionary of the current resource dictionary.
|
||||
/// </summary>
|
||||
public NameToken Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="InvokeNamedXObject"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the XObject.</param>
|
||||
public InvokeNamedXObject(NameToken name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
{
|
||||
var xobject = resourceStore.GetXObject(Name);
|
||||
@@ -24,11 +42,16 @@
|
||||
operationContext.ApplyXObject(xobject);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
stream.WriteText($"/{Name}");
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Name} {Symbol}";
|
||||
|
@@ -3,20 +3,46 @@
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <summary>
|
||||
/// Set the non-stroking color space to DeviceCMYK and set the color to use for stroking operations.
|
||||
/// </summary>
|
||||
internal class SetNonStrokeColorDeviceCmyk : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "K";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The cyan level between 0 and 1.
|
||||
/// </summary>
|
||||
public decimal C { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The magenta level between 0 and 1.
|
||||
/// </summary>
|
||||
public decimal M { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The yellow level between 0 and 1.
|
||||
/// </summary>
|
||||
public decimal Y { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The key level between 0 and 1.
|
||||
/// </summary>
|
||||
public decimal K { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="SetNonStrokeColorDeviceCmyk"/>.
|
||||
/// </summary>
|
||||
/// <param name="c">The cyan level.</param>
|
||||
/// <param name="m">The magenta level.</param>
|
||||
/// <param name="y">The yellow level.</param>
|
||||
/// <param name="k">The key level.</param>
|
||||
public SetNonStrokeColorDeviceCmyk(decimal c, decimal m, decimal y, decimal k)
|
||||
{
|
||||
C = c;
|
||||
@@ -25,15 +51,27 @@
|
||||
K = k;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{C} {M} {Y} {K} {Symbol}";
|
||||
|
@@ -3,28 +3,45 @@
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <summary>
|
||||
/// Set the gray level for non-stroking operations.
|
||||
/// </summary>
|
||||
internal class SetNonStrokeColorDeviceGray : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "g";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The gray level between 0 (black) and 1 (white).
|
||||
/// </summary>
|
||||
public decimal Gray { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="SetNonStrokeColorDeviceGray"/>.
|
||||
/// </summary>
|
||||
/// <param name="gray">The gray level.</param>
|
||||
public SetNonStrokeColorDeviceGray(decimal gray)
|
||||
{
|
||||
Gray = gray;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
stream.WriteNumberText(Gray, Symbol);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Gray} {Symbol}";
|
||||
|
@@ -3,18 +3,40 @@
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <summary>
|
||||
/// Set RGB color for non-stroking operations.
|
||||
/// </summary>
|
||||
internal class SetNonStrokeColorDeviceRgb : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "rg";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The red level between 0 and 1.
|
||||
/// </summary>
|
||||
public decimal R { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The green level between 0 and 1.
|
||||
/// </summary>
|
||||
public decimal G { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The blue level between 0 and 1.
|
||||
/// </summary>
|
||||
public decimal B { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="SetNonStrokeColorDeviceRgb"/>.
|
||||
/// </summary>
|
||||
/// <param name="r">The red level.</param>
|
||||
/// <param name="g">The green level.</param>
|
||||
/// <param name="b">The blue level.</param>
|
||||
public SetNonStrokeColorDeviceRgb(decimal r, decimal g, decimal b)
|
||||
{
|
||||
R = r;
|
||||
@@ -22,10 +44,12 @@
|
||||
B = b;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(R);
|
||||
@@ -38,6 +62,7 @@
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{R} {G} {B} {Symbol}";
|
||||
|
@@ -3,20 +3,46 @@
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <summary>
|
||||
/// Set the stroking color space to DeviceCMYK and set the color to use for stroking operations.
|
||||
/// </summary>
|
||||
internal class SetStrokeColorDeviceCmyk : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "K";
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The cyan level between 0 and 1.
|
||||
/// </summary>
|
||||
public decimal C { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The magenta level between 0 and 1.
|
||||
/// </summary>
|
||||
public decimal M { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The yellow level between 0 and 1.
|
||||
/// </summary>
|
||||
public decimal Y { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The key level between 0 and 1.
|
||||
/// </summary>
|
||||
public decimal K { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="SetStrokeColorDeviceCmyk"/>.
|
||||
/// </summary>
|
||||
/// <param name="c">The cyan level.</param>
|
||||
/// <param name="m">The magenta level.</param>
|
||||
/// <param name="y">The yellow level.</param>
|
||||
/// <param name="k">The key level.</param>
|
||||
public SetStrokeColorDeviceCmyk(decimal c, decimal m, decimal y, decimal k)
|
||||
{
|
||||
C = c;
|
||||
@@ -25,15 +51,27 @@
|
||||
K = k;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{C} {M} {Y} {K} {Symbol}";
|
||||
|
@@ -8,6 +8,9 @@
|
||||
/// </summary>
|
||||
internal class SetStrokeColorDeviceGray : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "G";
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -35,10 +38,7 @@
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(Gray);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
stream.WriteNumberText(Gray, Symbol);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@@ -8,6 +8,9 @@
|
||||
/// </summary>
|
||||
internal class SetStrokeColorDeviceRgb : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "RG";
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Move to the next line and show a text string.
|
||||
/// </summary>
|
||||
internal class MoveToNextLineShowText : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "'";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The text to show as a <see cref="string"/>.
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public string Text { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The text to show as hex bytes.
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public byte[] Bytes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="MoveToNextLineShowText"/>.
|
||||
/// </summary>
|
||||
/// <param name="text">The text to show.</param>
|
||||
public MoveToNextLineShowText(string text)
|
||||
{
|
||||
Text = text;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="MoveToNextLineShowText"/>.
|
||||
/// </summary>
|
||||
/// <param name="hexBytes">The bytes of the text to show.</param>
|
||||
public MoveToNextLineShowText(byte[] hexBytes)
|
||||
{
|
||||
Bytes = hexBytes;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
{
|
||||
var move = MoveToNextLine.Value;
|
||||
@@ -37,11 +61,23 @@
|
||||
showText.Run(operationContext, resourceStore);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Text} {Symbol}";
|
||||
|
Reference in New Issue
Block a user