fix bug with compact font format font matrix reading and where endstream token is missed if immediately following 'e'

This commit is contained in:
Eliot Jones
2019-05-10 20:02:29 +01:00
parent 3396820d49
commit 03af28ed6d
3 changed files with 11 additions and 5 deletions

View File

@@ -13,7 +13,7 @@
//[Fact] //[Fact]
//public void Tests() //public void Tests()
//{ //{
// var files = new[] { @"C:\Users\eliot\Downloads\Encrypted1.pdf" }; // var files = Directory.GetFiles(@"C:\temp\pdfs");
// foreach (var file in files) // foreach (var file in files)
// { // {

View File

@@ -71,12 +71,18 @@
{ {
var array = ToArray(operands); var array = ToArray(operands);
if (array.Length != 4) if (array.Length == 4)
{
dictionary.FontMatrix = TransformationMatrix.FromArray(array);
}
else if (array.Length == 6)
{
dictionary.FontMatrix = TransformationMatrix.FromArray(array);
}
else
{ {
throw new InvalidOperationException($"Expected four values for the font matrix, instead got: {array}."); throw new InvalidOperationException($"Expected four values for the font matrix, instead got: {array}.");
} }
dictionary.FontMatrix = TransformationMatrix.FromArray(array);
} }
break; break;
case 8: case 8:

View File

@@ -304,7 +304,7 @@
endStreamPosition = 0; endStreamPosition = 0;
endObjPosition = 0; endObjPosition = 0;
commonPartPosition = 0; commonPartPosition = (inputBytes.CurrentByte == commonPart[0]) ? 1 : 0;
} }
binaryWrite.Write(inputBytes.CurrentByte); binaryWrite.Write(inputBytes.CurrentByte);