#21 add a test for accented characters and fill in more writing methods for content stream operators

the output is currently incorrect for accented characters
This commit is contained in:
Eliot Jones
2018-12-14 18:33:01 +00:00
parent 924fc7b37f
commit 39786ac00a
12 changed files with 81 additions and 13 deletions

View File

@@ -5,6 +5,9 @@
using Content;
using PdfPig.Core;
/// <summary>
/// Modify the current transformation matrix by concatenating the specified matrix.
/// </summary>
internal class ModifyCurrentTransformationMatrix : IGraphicsStateOperation
{
public const string Symbol = "cm";

View File

@@ -4,9 +4,13 @@
using System.IO;
using Content;
/// <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 const string Symbol = "Q";
public static readonly Pop Value = new Pop();
public string Operator => Symbol;
@@ -30,7 +34,8 @@
public void Write(Stream stream)
{
throw new NotImplementedException();
stream.WriteText(Symbol);
stream.WriteNewLine();
}
public override string ToString()

View File

@@ -3,6 +3,9 @@
using System.IO;
using Content;
/// <summary>
/// Save the current graphics state on the graphics state stack.
/// </summary>
internal class Push : IGraphicsStateOperation
{
public const string Symbol = "q";
@@ -14,11 +17,6 @@
{
}
public override string ToString()
{
return Symbol;
}
public void Run(IOperationContext context, IResourceStore resourceStore)
{
context.PushState();
@@ -26,7 +24,13 @@
public void Write(Stream stream)
{
throw new System.NotImplementedException();
stream.WriteText(Symbol);
stream.WriteNewLine();
}
public override string ToString()
{
return Symbol;
}
}
}

View File

@@ -4,6 +4,9 @@
using Content;
using PdfPig.Core;
/// <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 const string Symbol = "BT";

View File

@@ -4,6 +4,9 @@
using Content;
using PdfPig.Core;
/// <summary>
/// End a text object, discarding the text matrix.
/// </summary>
internal class EndText : IGraphicsStateOperation
{
public const string Symbol = "ET";

View File

@@ -30,7 +30,8 @@
public void Write(Stream stream)
{
throw new System.NotImplementedException();
stream.WriteText(Symbol);
stream.WriteNewLine();
}
public override string ToString()

View File

@@ -4,6 +4,10 @@
using Content;
using TextState;
/// <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
{
public const string Symbol = "TD";
@@ -33,7 +37,12 @@
public void Write(Stream stream)
{
throw new System.NotImplementedException();
stream.WriteDecimal(Tx);
stream.WriteWhiteSpace();
stream.WriteDecimal(Ty);
stream.WriteWhiteSpace();
stream.WriteText(Symbol);
stream.WriteNewLine();
}
public override string ToString()

View File

@@ -5,6 +5,9 @@
using Content;
using PdfPig.Core;
/// <summary>
/// Set the text matrix and the text line matrix.
/// </summary>
internal class SetTextMatrix : IGraphicsStateOperation
{
public const string Symbol = "Tm";
@@ -33,7 +36,20 @@
public void Write(Stream stream)
{
throw new NotImplementedException();
stream.WriteDecimal(Value[0]);
stream.WriteWhiteSpace();
stream.WriteDecimal(Value[1]);
stream.WriteWhiteSpace();
stream.WriteDecimal(Value[2]);
stream.WriteWhiteSpace();
stream.WriteDecimal(Value[3]);
stream.WriteWhiteSpace();
stream.WriteDecimal(Value[4]);
stream.WriteWhiteSpace();
stream.WriteDecimal(Value[5]);
stream.WriteWhiteSpace();
stream.WriteText(Symbol);
stream.WriteNewLine();
}
public override string ToString()

View File

@@ -3,6 +3,10 @@
using System.IO;
using Content;
/// <summary>
/// Set the character spacing to a number expressed in unscaled text space units.
/// Initial value: 0.
/// </summary>
internal class SetCharacterSpacing : IGraphicsStateOperation
{
public const string Symbol = "Tc";
@@ -25,7 +29,10 @@
public void Write(Stream stream)
{
throw new System.NotImplementedException();
stream.WriteDecimal(Spacing);
stream.WriteWhiteSpace();
stream.WriteText(Symbol);
stream.WriteNewLine();
}
public override string ToString()