2018-01-10 19:49:32 +00:00
|
|
|
|
namespace UglyToad.PdfPig.Graphics.Operations.TextShowing
|
2017-11-22 18:41:34 +00:00
|
|
|
|
{
|
2018-12-02 16:14:55 +00:00
|
|
|
|
using System.IO;
|
2017-12-02 14:11:20 +00:00
|
|
|
|
using TextPositioning;
|
|
|
|
|
|
using TextState;
|
|
|
|
|
|
using Util.JetBrains.Annotations;
|
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <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
|
2017-11-22 18:41:34 +00:00
|
|
|
|
{
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The symbol for this operation in a stream.
|
|
|
|
|
|
/// </summary>
|
2017-11-22 18:41:34 +00:00
|
|
|
|
public const string Symbol = "\"";
|
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <inheritdoc />
|
2017-11-22 18:41:34 +00:00
|
|
|
|
public string Operator => Symbol;
|
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The word spacing.
|
|
|
|
|
|
/// </summary>
|
2017-11-22 18:41:34 +00:00
|
|
|
|
public decimal WordSpacing { get; }
|
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The character spacing.
|
|
|
|
|
|
/// </summary>
|
2017-11-22 18:41:34 +00:00
|
|
|
|
public decimal CharacterSpacing { get; }
|
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The bytes of the text.
|
|
|
|
|
|
/// </summary>
|
2017-12-02 14:11:20 +00:00
|
|
|
|
[CanBeNull]
|
|
|
|
|
|
public byte[] Bytes { get; }
|
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The text to show.
|
|
|
|
|
|
/// </summary>
|
2017-12-02 14:11:20 +00:00
|
|
|
|
[CanBeNull]
|
2017-11-22 18:41:34 +00:00
|
|
|
|
public string Text { get; }
|
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <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>
|
2017-11-26 22:19:42 +00:00
|
|
|
|
public MoveToNextLineShowTextWithSpacing(decimal wordSpacing, decimal characterSpacing, string text)
|
2017-11-22 18:41:34 +00:00
|
|
|
|
{
|
|
|
|
|
|
WordSpacing = wordSpacing;
|
|
|
|
|
|
CharacterSpacing = characterSpacing;
|
|
|
|
|
|
Text = text;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <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>
|
2017-12-02 14:11:20 +00:00
|
|
|
|
public MoveToNextLineShowTextWithSpacing(decimal wordSpacing, decimal characterSpacing, byte[] hexBytes)
|
|
|
|
|
|
{
|
|
|
|
|
|
WordSpacing = wordSpacing;
|
|
|
|
|
|
CharacterSpacing = characterSpacing;
|
|
|
|
|
|
Bytes = hexBytes;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public void Run(IOperationContext operationContext)
|
2017-12-02 14:11:20 +00:00
|
|
|
|
{
|
|
|
|
|
|
var setWordSpacing = new SetWordSpacing(WordSpacing);
|
|
|
|
|
|
var setCharacterSpacing = new SetCharacterSpacing(CharacterSpacing);
|
|
|
|
|
|
var moveToNextLine = MoveToNextLine.Value;
|
|
|
|
|
|
var showText = Text != null ? new ShowText(Text) : new ShowText(Bytes);
|
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
setWordSpacing.Run(operationContext);
|
|
|
|
|
|
setCharacterSpacing.Run(operationContext);
|
|
|
|
|
|
moveToNextLine.Run(operationContext);
|
|
|
|
|
|
showText.Run(operationContext);
|
2017-12-02 14:11:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <inheritdoc />
|
2018-12-02 16:14:55 +00:00
|
|
|
|
public void Write(Stream stream)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new System.NotImplementedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <inheritdoc />
|
2017-11-22 18:41:34 +00:00
|
|
|
|
public override string ToString()
|
|
|
|
|
|
{
|
|
|
|
|
|
return $"{WordSpacing} {CharacterSpacing} {Text} {Symbol}";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|