/// <summary>
 /// Add a new entry to the dictionary.
 /// </summary>
 /// <param name="key">The name to be used as the key for the new dictionary entry.</param>
 /// <param name="value">The value of the new dictionary entry.  If this parameter is null, a <see cref="PdfNull" /> instance will be used for the entry value.</param>
 /// <exception cref="ArgumentNullException">Thrown if the key parameter is null.</exception>
 /// <exception cref="ArgumentException">Thrown if the dictionary already contains an entry with an equal key.</exception>
 public void Add(PdfName key, IPdfPrimitiveObject value)
 {
     if (key == null)
     {
         throw new ArgumentNullException(nameof(key));
     }
     if (value == null)
     {
         value = PdfNull.Value;
     }
     lock (_contents)
     {
         if (_contents.ContainsKey(key))
         {
             throw new ArgumentException(Resources.Primitives_PdfDictionary_Add_Duplicate_Key_Error, nameof(key));
         }
         _contents.Add(key, value);
     }
 }
        private static void WriteObj(ref int runningCount, List <byte> byteList, IPdfPrimitiveObject obj)
        {
            int objLength = obj.ByteLength;

            if (runningCount + objLength > 254)
            {
                byteList.Add(0xa);
                runningCount = 0;
            }
            obj.WriteTo(byteList);
            if (objLength > 254)
            {
                byteList.Add(0xa);
                runningCount = 0;
            }
            else
            {
                runningCount += objLength;
            }
        }