mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-15 19:54:52 +08:00
#26 make almost all operators public
This commit is contained in:
@@ -1,29 +1,44 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.ClippingPaths
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
internal class ModifyClippingByEvenOddIntersect : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public class ModifyClippingByEvenOddIntersect : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "W*";
|
||||
|
||||
/// <summary>
|
||||
/// The instance of the <see cref="ModifyClippingByEvenOddIntersect"/> operation.
|
||||
/// </summary>
|
||||
public static readonly ModifyClippingByEvenOddIntersect Value = new ModifyClippingByEvenOddIntersect();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
private ModifyClippingByEvenOddIntersect()
|
||||
{
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Symbol;
|
||||
|
@@ -1,29 +1,44 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.ClippingPaths
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
internal class ModifyClippingByNonZeroWindingIntersect : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public class ModifyClippingByNonZeroWindingIntersect : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "W";
|
||||
|
||||
/// <summary>
|
||||
/// The instance of the <see cref="EndPath"/> operation.
|
||||
/// </summary>
|
||||
public static readonly ModifyClippingByNonZeroWindingIntersect Value = new ModifyClippingByNonZeroWindingIntersect();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
private ModifyClippingByNonZeroWindingIntersect()
|
||||
{
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Symbol;
|
||||
|
@@ -1,12 +1,12 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Close and stroke the path.
|
||||
/// </summary>
|
||||
internal class CloseAndStrokePath : IGraphicsStateOperation
|
||||
public class CloseAndStrokePath : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
@@ -26,7 +26,7 @@
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
operationContext.StrokePath(true);
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Close, fill, and then stroke the path, using the even-odd rule to determine the region to fill.
|
||||
/// </summary>
|
||||
@@ -26,7 +26,7 @@
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Close, fill, and then stroke the path, using the nonzero winding number rule to determine the region to fill.
|
||||
/// </summary>
|
||||
@@ -26,7 +26,7 @@
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -1,12 +1,12 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// End path without filling or stroking.
|
||||
/// </summary>
|
||||
internal class EndPath : IGraphicsStateOperation
|
||||
public class EndPath : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
@@ -26,7 +26,7 @@
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -1,12 +1,12 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Fill the path, using the even-odd rule to determine the region to fill.
|
||||
/// </summary>
|
||||
internal class FillPathEvenOddRule : IGraphicsStateOperation
|
||||
public class FillPathEvenOddRule : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
@@ -26,7 +26,7 @@
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Fill and then stroke the path, using the even-odd rule to determine the region to fill.
|
||||
/// </summary>
|
||||
@@ -26,7 +26,7 @@
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -1,13 +1,13 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <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
|
||||
public class FillPathNonZeroWinding : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
@@ -27,7 +27,7 @@
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -1,12 +1,12 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Fill and then stroke the path, using the nonzero winding number rule to determine the region to fill.
|
||||
/// </summary>
|
||||
internal class FillPathNonZeroWindingAndStroke : IGraphicsStateOperation
|
||||
public class FillPathNonZeroWindingAndStroke : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
@@ -26,7 +26,7 @@
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -1,13 +1,13 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <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
|
||||
public class FillPathNonZeroWindingCompatibility : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
@@ -27,7 +27,7 @@
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -1,22 +1,54 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.General
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using Content;
|
||||
using Tokens;
|
||||
|
||||
internal class SetColorRenderingIntent : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Set the color rendering intent in the graphics state.
|
||||
/// </summary>
|
||||
public class SetColorRenderingIntent : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "ri";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <summary>
|
||||
/// The rendering intent for CIE-based colors.
|
||||
/// </summary>
|
||||
public NameToken RenderingIntent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create new <see cref="SetColorRenderingIntent"/>.
|
||||
/// </summary>
|
||||
/// <param name="renderingIntent">The rendering intent.</param>
|
||||
public SetColorRenderingIntent(NameToken renderingIntent)
|
||||
{
|
||||
RenderingIntent = renderingIntent ?? throw new ArgumentNullException(nameof(renderingIntent));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
stream.WriteText($"/{RenderingIntent.Data} {Symbol}");
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{RenderingIntent} {Symbol}";
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,31 +1,50 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.General
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
internal class SetFlatnessTolerance : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public class SetFlatnessTolerance : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "i";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The flatness tolerance controls the maximum permitted distance in device pixels
|
||||
/// between the mathematically correct path and an approximation constructed from straight line segments.
|
||||
/// </summary>
|
||||
public decimal Tolerance { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create new <see cref="SetFlatnessTolerance"/>.
|
||||
/// </summary>
|
||||
/// <param name="tolerance">The flatness tolerance.</param>
|
||||
public SetFlatnessTolerance(decimal tolerance)
|
||||
{
|
||||
Tolerance = tolerance;
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
operationContext.GetCurrentState().Flatness = Tolerance;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
stream.WriteNumberText(Tolerance, Symbol);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Tolerance} {Symbol}";
|
||||
|
@@ -2,18 +2,36 @@
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using Content;
|
||||
using Core;
|
||||
|
||||
internal class SetLineCap : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Set the line cap style in the graphics state.
|
||||
/// </summary>
|
||||
public class SetLineCap : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "J";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The cap style.
|
||||
/// </summary>
|
||||
public LineCapStyle Cap { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Create a new <see cref="T:UglyToad.PdfPig.Graphics.Operations.General.SetLineCap" />.
|
||||
/// </summary>
|
||||
public SetLineCap(int cap) : this((LineCapStyle)cap) { }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="SetLineCap"/>.
|
||||
/// </summary>
|
||||
public SetLineCap(LineCapStyle cap)
|
||||
{
|
||||
if (cap < 0 || (int)cap > 2)
|
||||
@@ -24,19 +42,19 @@
|
||||
Cap = cap;
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
operationContext.GetCurrentState().CapStyle = Cap;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal((int)Cap);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
stream.WriteNumberText((int)Cap, Symbol);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{(int) Cap} {Symbol}";
|
||||
|
@@ -1,32 +1,71 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.General
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
using Core;
|
||||
|
||||
internal class SetLineDashPattern : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Set the line dash pattern in the graphics state.
|
||||
/// </summary>
|
||||
public class SetLineDashPattern : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "d";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The line dash pattern.
|
||||
/// </summary>
|
||||
public LineDashPattern Pattern { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="SetLineDashPattern"/>.
|
||||
/// </summary>
|
||||
public SetLineDashPattern(decimal[] array, int phase)
|
||||
{
|
||||
Pattern = new LineDashPattern(phase, array);
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
operationContext.GetCurrentState().LineDashPattern = Pattern;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Pattern.Array} {Pattern.Phase} {Symbol}";
|
||||
|
@@ -2,18 +2,31 @@
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using Content;
|
||||
using Core;
|
||||
|
||||
internal class SetLineJoin : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
public class SetLineJoin : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "j";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The line join style.
|
||||
/// </summary>
|
||||
public LineJoinStyle Join { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="SetLineJoin"/>.
|
||||
/// </summary>
|
||||
public SetLineJoin(int join) : this((LineJoinStyle)join) { }
|
||||
/// <summary>
|
||||
/// Create a new <see cref="SetLineJoin"/>.
|
||||
/// </summary>
|
||||
public SetLineJoin(LineJoinStyle join)
|
||||
{
|
||||
if (join < 0 || (int)join > 2)
|
||||
@@ -24,19 +37,19 @@
|
||||
Join = join;
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
operationContext.GetCurrentState().JoinStyle = Join;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal((int)Join);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
stream.WriteNumberText((int)Join, Symbol);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{(int)Join} {Symbol}";
|
||||
|
@@ -1,36 +1,50 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.General
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
internal class SetLineWidth : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Set the line width in the graphics state.
|
||||
/// </summary>
|
||||
public class SetLineWidth : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "w";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The line width.
|
||||
/// </summary>
|
||||
public decimal Width { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="SetLineWidth"/>.
|
||||
/// </summary>
|
||||
/// <param name="width">The line width.</param>
|
||||
public SetLineWidth(decimal width)
|
||||
{
|
||||
Width = width;
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var currentState = operationContext.GetCurrentState();
|
||||
|
||||
currentState.LineWidth = Width;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(Width);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
stream.WriteNumberText(Width, Symbol);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Width} {Symbol}";
|
||||
|
@@ -1,33 +1,50 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.General
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
internal class SetMiterLimit : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Set the miter limit in the graphics state.
|
||||
/// </summary>
|
||||
public class SetMiterLimit : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "M";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public decimal Limit { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="SetMiterLimit"/>.
|
||||
/// </summary>
|
||||
public SetMiterLimit(decimal limit)
|
||||
{
|
||||
Limit = limit;
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var currentState = operationContext.GetCurrentState();
|
||||
|
||||
currentState.MiterLimit = Limit;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
stream.WriteNumberText(Limit, Symbol);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Limit} {Symbol}";
|
||||
|
@@ -1,14 +1,27 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
internal interface IGraphicsStateOperation
|
||||
/// <summary>
|
||||
/// An operation with associated data from a content stream.
|
||||
/// </summary>
|
||||
public interface IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol representing the operator in the content stream.
|
||||
/// </summary>
|
||||
string Operator { get; }
|
||||
|
||||
void Run(IOperationContext operationContext, IResourceStore resourceStore);
|
||||
|
||||
/// <summary>
|
||||
/// Writes the operator and any operands as valid PDF content to the stream.
|
||||
/// </summary>
|
||||
/// <param name="stream">The stream to write to.</param>
|
||||
void Write(Stream stream);
|
||||
|
||||
/// <summary>
|
||||
/// Applies the operation to the current context with the provided resources.
|
||||
/// </summary>
|
||||
/// <param name="operationContext"></param>
|
||||
void Run(IOperationContext operationContext);
|
||||
}
|
||||
}
|
@@ -1,16 +1,17 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using Content;
|
||||
using Tokens;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <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.
|
||||
/// The effect of <see cref="T:UglyToad.PdfPig.Graphics.Operations.InvokeNamedXObject" /> depends on the value of the XObject's Subtype entry, which may be Image, Form or PS.
|
||||
/// </summary>
|
||||
internal class InvokeNamedXObject : IGraphicsStateOperation
|
||||
public class InvokeNamedXObject : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
@@ -31,15 +32,13 @@
|
||||
/// <param name="name">The name of the XObject.</param>
|
||||
public InvokeNamedXObject(NameToken name)
|
||||
{
|
||||
Name = name;
|
||||
Name = name ?? throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var xobject = resourceStore.GetXObject(Name);
|
||||
|
||||
operationContext.ApplyXObject(xobject);
|
||||
operationContext.ApplyXObject(Name);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@@ -1,21 +1,47 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.PathConstruction
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
using Geometry;
|
||||
|
||||
internal class AppendDualControlPointBezierCurve : IGraphicsStateOperation
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
public class AppendDualControlPointBezierCurve : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "c";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The first control point.
|
||||
/// </summary>
|
||||
public PdfPoint ControlPoint1 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The second control point.
|
||||
/// </summary>
|
||||
public PdfPoint ControlPoint2 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The end point.
|
||||
/// </summary>
|
||||
public PdfPoint End { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="AppendDualControlPointBezierCurve"/>.
|
||||
/// </summary>
|
||||
/// <param name="x1">Control point 1 x coordinate.</param>
|
||||
/// <param name="y1">Control point 1 y coordinate.</param>
|
||||
/// <param name="x2">Control point 2 x coordinate.</param>
|
||||
/// <param name="y2">Control point 2 y coordinate.</param>
|
||||
/// <param name="x3">End point x coordinate.</param>
|
||||
/// <param name="y3">End point y coordinate.</param>
|
||||
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)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
operationContext.CurrentPath.BezierCurveTo(ControlPoint1.X, ControlPoint1.Y,
|
||||
ControlPoint2.X, ControlPoint2.Y,
|
||||
@@ -31,6 +58,7 @@
|
||||
operationContext.CurrentPosition = End;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(ControlPoint1.X);
|
||||
@@ -49,6 +77,7 @@
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{ControlPoint1.X} {ControlPoint1.Y} {ControlPoint2.X} {ControlPoint2.Y} {End.X} {End.Y} {Symbol}";
|
||||
|
@@ -1,26 +1,48 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.PathConstruction
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
using Geometry;
|
||||
|
||||
internal class AppendEndControlPointBezierCurve : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
public class AppendEndControlPointBezierCurve : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "y";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The first control point.
|
||||
/// </summary>
|
||||
public PdfPoint ControlPoint1 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The end point and second control point.
|
||||
/// </summary>
|
||||
public PdfPoint End { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="AppendEndControlPointBezierCurve"/>.
|
||||
/// </summary>
|
||||
/// <param name="x1">Control point 1 x coordinate.</param>
|
||||
/// <param name="y1">Control point 1 y coordinate.</param>
|
||||
/// <param name="x3">Control point 2/End x coordinate.</param>
|
||||
/// <param name="y3">Control point 2/End y coordinate.</param>
|
||||
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)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
operationContext.CurrentPath.BezierCurveTo(ControlPoint1.X, ControlPoint1.Y,
|
||||
End.X,
|
||||
@@ -30,6 +52,7 @@
|
||||
operationContext.CurrentPosition = End;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(ControlPoint1.X);
|
||||
@@ -44,6 +67,7 @@
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{ControlPoint1.X} {ControlPoint1.Y} {End.X} {End.Y} {Symbol}";
|
||||
|
@@ -1,21 +1,44 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.PathConstruction
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
using Geometry;
|
||||
|
||||
internal class AppendRectangle : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
/// <remarks>
|
||||
/// Append a rectangle to the current path as a complete subpath.
|
||||
/// </remarks>
|
||||
public class AppendRectangle : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "re";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The lower left corner.
|
||||
/// </summary>
|
||||
public PdfPoint LowerLeft { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The width of the rectangle.
|
||||
/// </summary>
|
||||
public decimal Width { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The height of the rectangle.
|
||||
/// </summary>
|
||||
public decimal Height { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="AppendRectangle"/>.
|
||||
/// </summary>
|
||||
/// <param name="x">The x coordinate of the lower left corner.</param>
|
||||
/// <param name="y">The y coordinate of the lower left corner.</param>
|
||||
/// <param name="width">The width of the rectangle.</param>
|
||||
/// <param name="height">The height of the rectangle.</param>
|
||||
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)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
operationContext.BeginSubpath();
|
||||
operationContext.CurrentPath.Rectangle(LowerLeft.X, LowerLeft.Y, Width, Height);
|
||||
operationContext.CurrentPath.ClosePath();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(LowerLeft.X);
|
||||
@@ -45,6 +70,7 @@
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{LowerLeft.X} {LowerLeft.Y} {Width} {Height} {Symbol}";
|
||||
|
@@ -1,26 +1,48 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.PathConstruction
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
using Geometry;
|
||||
|
||||
internal class AppendStartControlPointBezierCurve : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
public class AppendStartControlPointBezierCurve : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "v";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The second control point.
|
||||
/// </summary>
|
||||
public PdfPoint ControlPoint2 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The last point on the curve.
|
||||
/// </summary>
|
||||
public PdfPoint End { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="AppendStartControlPointBezierCurve"/>.
|
||||
/// </summary>
|
||||
/// <param name="x2">The x coordinate of the second control point.</param>
|
||||
/// <param name="y2">The y coordinate of the second control point.</param>
|
||||
/// <param name="x3">The x coordinate of the end point.</param>
|
||||
/// <param name="y3">The y coordinate of the end point.</param>
|
||||
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)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
operationContext.CurrentPath.BezierCurveTo(operationContext.CurrentPosition.X,
|
||||
operationContext.CurrentPosition.Y,
|
||||
@@ -31,6 +53,7 @@
|
||||
operationContext.CurrentPosition = End;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(ControlPoint2.X);
|
||||
@@ -45,6 +68,7 @@
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{ControlPoint2.X} {ControlPoint2.Y} {End.X} {End.Y} {Symbol}";
|
||||
|
@@ -1,28 +1,45 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.PathConstruction
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
using Geometry;
|
||||
|
||||
internal class AppendStraightLineSegment : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Append a straight line segment from the current point to the point (x, y).
|
||||
/// </summary>
|
||||
public class AppendStraightLineSegment : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "l";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The end point of the line.
|
||||
/// </summary>
|
||||
public PdfPoint End { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="AppendStraightLineSegment"/>.
|
||||
/// </summary>
|
||||
/// <param name="x">The x coordinate of the line's end point.</param>
|
||||
/// <param name="y">The y coordinate of the line's end point.</param>
|
||||
public AppendStraightLineSegment(decimal x, decimal y)
|
||||
{
|
||||
End = new PdfPoint(x, y);
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
operationContext.CurrentPath.LineTo(End.X, End.Y);
|
||||
operationContext.CurrentPosition = End;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(End.X);
|
||||
@@ -33,6 +50,7 @@
|
||||
stream.WriteWhiteSpace();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{End.X} {End.Y} {Symbol}";
|
||||
|
@@ -1,28 +1,45 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.PathConstruction
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
using Geometry;
|
||||
|
||||
internal class BeginNewSubpath : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Begin a new subpath by moving the current point to coordinates (x, y), omitting any connecting line segment.
|
||||
/// </summary>
|
||||
public class BeginNewSubpath : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "m";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The point to begin the new subpath at.
|
||||
/// </summary>
|
||||
public PdfPoint Point { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="BeginNewSubpath"/>.
|
||||
/// </summary>
|
||||
/// <param name="x">The x coordinate.</param>
|
||||
/// <param name="y">The y coordinate.</param>
|
||||
public BeginNewSubpath(decimal x, decimal y)
|
||||
{
|
||||
Point = new PdfPoint(x, y);
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
operationContext.BeginSubpath();
|
||||
operationContext.CurrentPosition = Point;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(Point.X);
|
||||
@@ -33,6 +50,7 @@
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Point.X} {Point.Y} {Symbol}";
|
||||
|
@@ -1,31 +1,45 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.PathConstruction
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
internal class CloseSubpath : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public class CloseSubpath : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "h";
|
||||
|
||||
/// <summary>
|
||||
/// The instance of the <see cref="CloseSubpath"/> operation.
|
||||
/// </summary>
|
||||
public static readonly CloseSubpath Value = new CloseSubpath();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
private CloseSubpath()
|
||||
{
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
operationContext.CurrentPath.ClosePath();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Symbol;
|
||||
|
@@ -1,12 +1,12 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Set the non-stroking color space to DeviceCMYK and set the color to use for stroking operations.
|
||||
/// </summary>
|
||||
internal class SetNonStrokeColorDeviceCmyk : IGraphicsStateOperation
|
||||
public class SetNonStrokeColorDeviceCmyk : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
@@ -52,7 +52,7 @@
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Set the gray level for non-stroking operations.
|
||||
/// </summary>
|
||||
@@ -31,7 +31,7 @@
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -1,12 +1,12 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Set RGB color for non-stroking operations.
|
||||
/// </summary>
|
||||
internal class SetNonStrokeColorDeviceRgb : IGraphicsStateOperation
|
||||
public class SetNonStrokeColorDeviceRgb : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
@@ -45,7 +45,7 @@
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Set the stroking color space to DeviceCMYK and set the color to use for stroking operations.
|
||||
/// </summary>
|
||||
@@ -52,7 +52,7 @@
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Set the gray level for stroking operations.
|
||||
/// </summary>
|
||||
@@ -31,7 +31,7 @@
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -1,12 +1,12 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Set RGB color for stroking operations.
|
||||
/// </summary>
|
||||
internal class SetStrokeColorDeviceRgb : IGraphicsStateOperation
|
||||
public class SetStrokeColorDeviceRgb : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
@@ -45,7 +45,7 @@
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -2,20 +2,31 @@
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using Content;
|
||||
using PdfPig.Core;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Modify the current transformation matrix by concatenating the specified matrix.
|
||||
/// </summary>
|
||||
internal class ModifyCurrentTransformationMatrix : IGraphicsStateOperation
|
||||
public class ModifyCurrentTransformationMatrix : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "cm";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The 6 values for the transformation matrix.
|
||||
/// </summary>
|
||||
public decimal[] Value { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="ModifyCurrentTransformationMatrix"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The 6 transformation matrix values.</param>
|
||||
public ModifyCurrentTransformationMatrix(decimal[] value)
|
||||
{
|
||||
if (value == null)
|
||||
@@ -30,7 +41,8 @@
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var newMatrix = TransformationMatrix.FromArray(Value);
|
||||
|
||||
@@ -41,6 +53,7 @@
|
||||
operationContext.GetCurrentState().CurrentTransformationMatrix = newCtm;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(Value[0]);
|
||||
@@ -59,6 +72,7 @@
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Value[0]} {Value[1]} {Value[2]} {Value[3]} {Value[4]} {Value[5]} {Symbol}";
|
||||
|
@@ -2,24 +2,32 @@
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Restore the graphics state by removing the most recently saved state from the stack and making it the current state.
|
||||
/// </summary>
|
||||
internal class Pop : IGraphicsStateOperation
|
||||
public class Pop : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "Q";
|
||||
|
||||
/// <summary>
|
||||
/// The instance of the <see cref="Pop"/> operation.
|
||||
/// </summary>
|
||||
public static readonly Pop Value = new Pop();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
private Pop()
|
||||
{
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var currentStackSize = operationContext.StackSize;
|
||||
if (currentStackSize > 1)
|
||||
@@ -32,12 +40,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Symbol;
|
||||
|
@@ -1,33 +1,44 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.SpecialGraphicsState
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Save the current graphics state on the graphics state stack.
|
||||
/// </summary>
|
||||
internal class Push : IGraphicsStateOperation
|
||||
public class Push : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "q";
|
||||
|
||||
/// <summary>
|
||||
/// The instance of the <see cref="Push"/> operation.
|
||||
/// </summary>
|
||||
public static readonly Push Value = new Push();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
private Push()
|
||||
{
|
||||
}
|
||||
|
||||
public void Run(IOperationContext context, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext context)
|
||||
{
|
||||
context.PushState();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Symbol;
|
||||
|
@@ -1,31 +1,44 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
internal class StrokePath : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Stroke the path.
|
||||
/// </summary>
|
||||
public class StrokePath : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "S";
|
||||
|
||||
/// <summary>
|
||||
/// The instance of the <see cref="StrokePath"/> operation.
|
||||
/// </summary>
|
||||
public static readonly StrokePath Value = new StrokePath();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
private StrokePath()
|
||||
{
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
operationContext.StrokePath(false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Symbol;
|
||||
|
@@ -1,35 +1,46 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.TextObjects
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
using PdfPig.Core;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Begin a text object, initializing the text matrix and the text line matrix to the identity matrix. Text objects cannot be nested.
|
||||
/// </summary>
|
||||
internal class BeginText : IGraphicsStateOperation
|
||||
public class BeginText : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "BT";
|
||||
|
||||
/// <summary>
|
||||
/// The instance of the <see cref="BeginText"/> operation.
|
||||
/// </summary>
|
||||
public static readonly BeginText Value = new BeginText();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
private BeginText()
|
||||
{
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
operationContext.TextMatrices.TextMatrix = TransformationMatrix.Identity;
|
||||
operationContext.TextMatrices.TextLineMatrix = TransformationMatrix.Identity;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Symbol;
|
||||
|
@@ -1,35 +1,46 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.TextObjects
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
using PdfPig.Core;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// End a text object, discarding the text matrix.
|
||||
/// </summary>
|
||||
internal class EndText : IGraphicsStateOperation
|
||||
public class EndText : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "ET";
|
||||
|
||||
/// <summary>
|
||||
/// The instance of the <see cref="EndText"/> operation.
|
||||
/// </summary>
|
||||
public static readonly EndText Value = new EndText();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
private EndText()
|
||||
{
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
operationContext.TextMatrices.TextMatrix = TransformationMatrix.Identity;
|
||||
operationContext.TextMatrices.TextLineMatrix = TransformationMatrix.Identity;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Symbol;
|
||||
|
@@ -1,8 +1,8 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.TextPositioning
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Move to the start of the next line.
|
||||
/// </summary>
|
||||
@@ -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.
|
||||
/// </remarks>
|
||||
internal class MoveToNextLine : IGraphicsStateOperation
|
||||
public class MoveToNextLine : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "T*";
|
||||
|
||||
/// <summary>
|
||||
/// The instance of the <see cref="MoveToNextLine"/> operation.
|
||||
/// </summary>
|
||||
public static readonly MoveToNextLine Value = new MoveToNextLine();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
private MoveToNextLine()
|
||||
{
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var tdOperation = new MoveToNextLineWithOffset(0, -1 * operationContext.GetCurrentState().FontState.Leading);
|
||||
|
||||
tdOperation.Run(operationContext, resourceStore);
|
||||
tdOperation.Run(operationContext);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Symbol;
|
||||
|
@@ -1,35 +1,51 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.TextPositioning
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
using PdfPig.Core;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Move to the start of the next line offset by Tx Ty.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Performs the following operation:
|
||||
/// 1 0 0<br/>
|
||||
/// Tm = Tlm = 0 1 0 * Tlm<br/>
|
||||
/// 1 0 0<br />
|
||||
/// Tm = Tlm = 0 1 0 * Tlm<br />
|
||||
/// tx ty 1
|
||||
/// </remarks>
|
||||
internal class MoveToNextLineWithOffset : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "Td";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The x value of the offset.
|
||||
/// </summary>
|
||||
public decimal Tx { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The y value of the offset.
|
||||
/// </summary>
|
||||
public decimal Ty { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="MoveToNextLineWithOffset"/>.
|
||||
/// </summary>
|
||||
/// <param name="tx">The x offset.</param>
|
||||
/// <param name="ty">The y offset.</param>
|
||||
public MoveToNextLineWithOffset(decimal tx, decimal ty)
|
||||
{
|
||||
Tx = tx;
|
||||
Ty = ty;
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var currentTextLineMatrix = operationContext.TextMatrices.TextLineMatrix;
|
||||
|
||||
@@ -41,6 +57,7 @@
|
||||
operationContext.TextMatrices.TextMatrix = transformed;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(Tx);
|
||||
@@ -51,6 +68,7 @@
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Tx} {Ty} {Symbol}";
|
||||
|
@@ -1,17 +1,21 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.TextPositioning
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
using TextState;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
internal class MoveToNextLineWithOffsetSetLeading : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "TD";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
public decimal Tx { get; }
|
||||
@@ -24,17 +28,19 @@
|
||||
Ty = ty;
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
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);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(Tx);
|
||||
@@ -45,6 +51,7 @@
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Tx} {Ty} {Symbol}";
|
||||
|
@@ -2,16 +2,20 @@
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using Content;
|
||||
using PdfPig.Core;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Set the text matrix and the text line matrix.
|
||||
/// </summary>
|
||||
internal class SetTextMatrix : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "Tm";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
public decimal[] Value { get; }
|
||||
@@ -25,8 +29,9 @@
|
||||
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var newMatrix = TransformationMatrix.FromArray(Value);
|
||||
|
||||
@@ -34,6 +39,7 @@
|
||||
operationContext.TextMatrices.TextLineMatrix = newMatrix;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(Value[0]);
|
||||
@@ -52,6 +58,7 @@
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Value[0]} {Value[1]} {Value[2]} {Value[3]} {Value[4]} {Value[5]} {Symbol}";
|
||||
|
@@ -3,14 +3,14 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Content;
|
||||
using TextPositioning;
|
||||
using Util.JetBrains.Annotations;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Move to the next line and show a text string.
|
||||
/// </summary>
|
||||
internal class MoveToNextLineShowText : IGraphicsStateOperation
|
||||
public class MoveToNextLineShowText : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
@@ -51,14 +51,14 @@
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@@ -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
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
public class MoveToNextLineShowTextWithSpacing : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "\"";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The word spacing.
|
||||
/// </summary>
|
||||
public decimal WordSpacing { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The character spacing.
|
||||
/// </summary>
|
||||
public decimal CharacterSpacing { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The bytes of the text.
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public byte[] Bytes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The text to show.
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public string Text { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="MoveToNextLineShowTextWithSpacing"/>.
|
||||
/// </summary>
|
||||
/// <param name="wordSpacing">The word spacing.</param>
|
||||
/// <param name="characterSpacing">The character spacing.</param>
|
||||
/// <param name="text">The text to show.</param>
|
||||
public MoveToNextLineShowTextWithSpacing(decimal wordSpacing, decimal characterSpacing, string text)
|
||||
{
|
||||
WordSpacing = wordSpacing;
|
||||
@@ -29,6 +54,12 @@
|
||||
Text = text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="MoveToNextLineShowTextWithSpacing"/>.
|
||||
/// </summary>
|
||||
/// <param name="wordSpacing">The word spacing.</param>
|
||||
/// <param name="characterSpacing">The character spacing.</param>
|
||||
/// <param name="hexBytes">The bytes of the text to show.</param>
|
||||
public MoveToNextLineShowTextWithSpacing(decimal wordSpacing, decimal characterSpacing, byte[] hexBytes)
|
||||
{
|
||||
WordSpacing = wordSpacing;
|
||||
@@ -36,24 +67,27 @@
|
||||
Bytes = hexBytes;
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
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);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{WordSpacing} {CharacterSpacing} {Text} {Symbol}";
|
||||
|
@@ -2,11 +2,11 @@
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using Content;
|
||||
using IO;
|
||||
using Util;
|
||||
using Util.JetBrains.Annotations;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Show a text string
|
||||
/// </summary>
|
||||
@@ -15,43 +15,61 @@
|
||||
/// <para>
|
||||
/// 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 <see cref="Fonts.Cmap.CMap"/> of the font defines the mapping from code to glyph.
|
||||
/// For these composite fonts, the <see cref="T:UglyToad.PdfPig.Fonts.Cmap.CMap" /> of the font defines the mapping from code to glyph.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The grouping of character codes in arguments to this operator does not have any impact on the meaning; for example:<br/>
|
||||
/// (Abc) Tj is equivalent to (A) Tj (b) Tj (c) Tj<br/>
|
||||
/// The grouping of character codes in arguments to this operator does not have any impact on the meaning; for example:<br />
|
||||
/// (Abc) Tj is equivalent to (A) Tj (b) Tj (c) Tj<br />
|
||||
/// However grouping character codes makes the document easier to search and extract text from.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
internal class ShowText : IGraphicsStateOperation
|
||||
public class ShowText : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "Tj";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The text string to show.
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public string Text { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The bytes of the string to show.
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public byte[] Bytes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="ShowText"/>.
|
||||
/// </summary>
|
||||
public ShowText(string text)
|
||||
{
|
||||
Text = text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="ShowText"/>.
|
||||
/// </summary>
|
||||
public ShowText(byte[] hexBytes)
|
||||
{
|
||||
Bytes = hexBytes;
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var input = new ByteArrayInputBytes(Text != null ? OtherEncodings.StringAsLatin1Bytes(Text) : Bytes);
|
||||
|
||||
operationContext.ShowText(input);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
if (Text == null && Bytes != null)
|
||||
@@ -65,6 +83,7 @@
|
||||
stream.WriteNewLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Text} {Symbol}";
|
||||
|
@@ -3,17 +3,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Content;
|
||||
using Tokens;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
internal class ShowTextsWithPositioning : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "TJ";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The array elements.
|
||||
/// </summary>
|
||||
public IReadOnlyList<IToken> Array { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="ShowTextsWithPositioning"/>.
|
||||
/// </summary>
|
||||
/// <param name="array">The array elements.</param>
|
||||
public ShowTextsWithPositioning(IReadOnlyList<IToken> array)
|
||||
{
|
||||
if (array == null)
|
||||
@@ -33,11 +50,13 @@
|
||||
Array = array;
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
operationContext.ShowPositionedText(Array);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
@@ -1,40 +1,51 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.TextState
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Set the character spacing to a number expressed in unscaled text space units.
|
||||
/// Initial value: 0.
|
||||
/// </summary>
|
||||
internal class SetCharacterSpacing : IGraphicsStateOperation
|
||||
public class SetCharacterSpacing : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "Tc";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The character spacing.
|
||||
/// </summary>
|
||||
public decimal Spacing { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="SetCharacterSpacing"/>.
|
||||
/// </summary>
|
||||
/// <param name="spacing">The character spacing.</param>
|
||||
public SetCharacterSpacing(decimal spacing)
|
||||
{
|
||||
Spacing = spacing;
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var currentState = operationContext.GetCurrentState();
|
||||
|
||||
currentState.FontState.CharacterSpacing = Spacing;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(Spacing);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
stream.WriteNumberText(Spacing, Symbol);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Spacing} {Symbol}";
|
||||
|
@@ -2,14 +2,23 @@
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using Content;
|
||||
using Tokens;
|
||||
using Util.JetBrains.Annotations;
|
||||
|
||||
internal class SetFontAndSize : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public class SetFontAndSize : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "Tf";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
@@ -24,13 +33,19 @@
|
||||
/// </summary>
|
||||
public decimal Size { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="SetFontAndSize"/>.
|
||||
/// </summary>
|
||||
/// <param name="font">The font name.</param>
|
||||
/// <param name="size">The font size.</param>
|
||||
public SetFontAndSize(NameToken font, decimal size)
|
||||
{
|
||||
Font = font ?? throw new ArgumentNullException(nameof(font));
|
||||
Size = size;
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var currentState = operationContext.GetCurrentState();
|
||||
|
||||
@@ -38,16 +53,15 @@
|
||||
currentState.FontState.FontName = Font;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Font} {Size} {Symbol}";
|
||||
|
@@ -1,33 +1,47 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.TextState
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
internal class SetHorizontalScaling : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
public class SetHorizontalScaling : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "Tz";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// A number specifying the percentage of the normal width.
|
||||
/// </summary>
|
||||
public decimal Scale { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="SetHorizontalScaling"/>.
|
||||
/// </summary>
|
||||
/// <param name="scale">The horizontal scaling percentage.</param>
|
||||
public SetHorizontalScaling(decimal scale)
|
||||
{
|
||||
Scale = scale;
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var currentState = operationContext.GetCurrentState();
|
||||
|
||||
currentState.FontState.HorizontalScaling = Scale;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
stream.WriteNumberText(Scale, Symbol);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Scale} {Symbol}";
|
||||
|
@@ -1,33 +1,50 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.TextState
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
internal class SetTextLeading : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Set the text leading.
|
||||
/// </summary>
|
||||
public class SetTextLeading : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "TL";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The text leading in unscaled text space units.
|
||||
/// </summary>
|
||||
public decimal Leading { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="SetTextLeading"/>.
|
||||
/// </summary>
|
||||
/// <param name="leading">The text leading.</param>
|
||||
public SetTextLeading(decimal leading)
|
||||
{
|
||||
Leading = leading;
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var currentState = operationContext.GetCurrentState();
|
||||
|
||||
currentState.FontState.Leading = Leading;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
stream.WriteNumberText(Leading, Symbol);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Leading} {Symbol}";
|
||||
|
@@ -1,34 +1,50 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.TextState
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
using Core;
|
||||
|
||||
internal class SetTextRenderingMode : IGraphicsStateOperation
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Set the text rendering mode.
|
||||
/// </summary>
|
||||
public class SetTextRenderingMode : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
public const string Symbol = "Tr";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
public RenderingMode Mode { get; }
|
||||
/// <summary>
|
||||
/// The text rendering mode to set.
|
||||
/// </summary>
|
||||
public TextRenderingMode Mode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="SetTextRenderingMode"/>.
|
||||
/// </summary>
|
||||
public SetTextRenderingMode(int mode)
|
||||
{
|
||||
Mode = (RenderingMode)mode;
|
||||
Mode = (TextRenderingMode)mode;
|
||||
}
|
||||
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var currentState = operationContext.GetCurrentState();
|
||||
|
||||
currentState.FontState.RenderingMode = Mode;
|
||||
currentState.FontState.TextRenderingMode = Mode;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
stream.WriteNumberText((int)Mode, Symbol);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Mode} {Symbol}";
|
||||
|
@@ -1,12 +1,12 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.TextState
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Set text rise.
|
||||
/// </summary>
|
||||
internal class SetTextRise : IGraphicsStateOperation
|
||||
public class SetTextRise : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
@@ -31,7 +31,7 @@
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var currentState = operationContext.GetCurrentState();
|
||||
|
||||
|
@@ -1,12 +1,11 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.TextState
|
||||
{
|
||||
using System.IO;
|
||||
using Content;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the word spacing.
|
||||
/// </summary>
|
||||
internal class SetWordSpacing : IGraphicsStateOperation
|
||||
public class SetWordSpacing : IGraphicsStateOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
@@ -33,7 +32,7 @@
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext, IResourceStore resourceStore)
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var currentState = operationContext.GetCurrentState();
|
||||
|
||||
|
Reference in New Issue
Block a user