handle hex registry and ordering. decrypt hex tokens #34

cid fonts may contain a registry, ordering and supplement to identify the font. we were checking for string registry and ordering tokens but failing on hex tokens.

for encrypted documents we now decrypt hex data.
This commit is contained in:
Eliot Jones
2019-06-23 13:27:32 +01:00
parent 0f103554fb
commit ff9e2ad83f
2 changed files with 21 additions and 1 deletions

View File

@@ -358,6 +358,16 @@
break;
}
case HexToken hexToken:
{
var data = hexToken.Bytes.ToArray();
var decrypted = DecryptData(data, reference);
token = new HexToken(Hex.GetString(decrypted).ToCharArray());
break;
}
case DictionaryToken dictionary:
{
// PDFBOX-2936: avoid orphan /CF dictionaries found in US govt "I-" files

View File

@@ -322,7 +322,17 @@
if (token is IndirectReferenceToken obj)
{
return DirectObjectFinder.Get<StringToken>(obj, pdfScanner).Data;
if (DirectObjectFinder.TryGet(obj, pdfScanner, out StringToken stringToken))
{
return stringToken.Data;
}
if (DirectObjectFinder.TryGet(obj, pdfScanner, out HexToken hexToken))
{
return hexToken.Data;
}
throw new PdfDocumentFormatException($"Could not get key for name: {keyName} in {dictionary}.");
}
return string.Empty;