mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
fix bug where hex tokens for document identifier lost bytes due to encoding
This commit is contained in:
@@ -42,9 +42,27 @@
|
||||
{
|
||||
this.encryptionDictionary = encryptionDictionary;
|
||||
|
||||
var documentIdBytes = trailerDictionary.Identifier != null && trailerDictionary.Identifier.Count == 2 ?
|
||||
OtherEncodings.StringAsLatin1Bytes(trailerDictionary.Identifier[0])
|
||||
: EmptyArray<byte>.Instance;
|
||||
byte[] documentIdBytes;
|
||||
|
||||
if (trailerDictionary.Identifier != null && trailerDictionary.Identifier.Count == 2)
|
||||
{
|
||||
var token = trailerDictionary.Identifier[0];
|
||||
|
||||
switch (token)
|
||||
{
|
||||
case HexToken hex:
|
||||
documentIdBytes = hex.Bytes.ToArray();
|
||||
break;
|
||||
default:
|
||||
documentIdBytes = OtherEncodings.StringAsLatin1Bytes(token.Data);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
documentIdBytes = EmptyArray<byte>.Instance;
|
||||
}
|
||||
|
||||
password = password ?? string.Empty;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user