/// <summary> /// Create a new <see cref="TrailerDictionary"/>. /// </summary> /// <param name="dictionary">The parsed dictionary from the document.</param> internal TrailerDictionary(DictionaryToken dictionary) { if (dictionary == null) { throw new ArgumentNullException(nameof(dictionary)); } Size = dictionary.GetInt(NameToken.Size); PreviousCrossReferenceOffset = dictionary.GetLongOrDefault(NameToken.Prev); if (!dictionary.TryGet(NameToken.Root, out IndirectReferenceToken rootReference)) { throw new PdfDocumentFormatException($"No root token was found in the trailer dictionary: {dictionary}."); } Root = rootReference.Data; if (dictionary.TryGet(NameToken.Info, out IndirectReferenceToken reference)) { Info = reference.Data; } if (dictionary.TryGet(NameToken.Id, out ArrayToken arr)) { var ids = new List <string>(arr.Data.Count); foreach (var token in arr.Data) { if (token is StringToken str) { ids.Add(str.Data); } else if (token is HexToken hex) { ids.Add(hex.Data); } } Identifier = ids; } else { Identifier = EmptyArray <string> .Instance; } if (dictionary.TryGet(NameToken.Encrypt, out var encryptionToken)) { EncryptionToken = encryptionToken; } }