Skip to content

Commit 5f02a7c

Browse files
committed
Allow uints(PdfUInteger) when calling ReadInt to support some encrypted file header reading.
This allows reading of uints by ReadInt and converts them to negative integers. This allows for reading some headers with other encryption options, even if we don't support that encryption type (useful if pdf still has read access without). Should not break most existing code unless code expected an exception for reading uints and was catching it.
1 parent a365c19 commit 5f02a7c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

PdfSharpCore/Pdf/PdfDictionary.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,9 @@ public int GetInteger(string key, bool create)
407407
if (integerObject != null)
408408
return integerObject.Value;
409409

410+
PdfUInteger uinteger = obj as PdfUInteger;
411+
if (uinteger != null)
412+
return (int)uinteger.Value;
410413
throw new InvalidCastException("GetInteger: Object is not an integer.");
411414
}
412415

0 commit comments

Comments
 (0)