try handling malformed operators where operands are not provided #355

This commit is contained in:
Eliot Jones 2021-08-08 11:36:43 -04:00
parent 2df5ec9b10
commit a3e316958a

View File

@ -20,7 +20,7 @@ namespace UglyToad.PdfPig.Graphics
using System.Linq;
using System.Reflection;
using Tokens;
using UglyToad.PdfPig.Graphics.Operations.PathPainting;
using Operations.PathPainting;
internal class ReflectionGraphicsStateOperationFactory : IGraphicsStateOperationFactory
{
@ -271,8 +271,18 @@ namespace UglyToad.PdfPig.Graphics
throw new InvalidOperationException($"Tried to create a move to next line and show text operation with operand type: {operands[0]?.GetType().Name ?? "null"}");
}
case MoveToNextLineWithOffset.Symbol:
if (operands.Count < 2)
{
return null;
}
return new MoveToNextLineWithOffset(OperandToDecimal(operands[0]), OperandToDecimal(operands[1]));
case MoveToNextLineWithOffsetSetLeading.Symbol:
if (operands.Count < 2)
{
return null;
}
return new MoveToNextLineWithOffsetSetLeading(OperandToDecimal(operands[0]), OperandToDecimal(operands[1]));
case PaintShading.Symbol:
return new PaintShading((NameToken)operands[0]);