/// <summary> /// Registers a new <see cref="IXRefSection"/> into Cross-Reference Table. /// </summary> /// <param name="section">The Cross-Reference section to add.</param> public void AddSection(IXRefSection section) { if (section == null) { throw new ArgumentNullException(nameof(section)); } var entries = section.Entries; if (entries == null) { return; } foreach (var entry in entries) { if (!internalDictionary.ContainsKey(entry.Key)) { internalDictionary.Add(entry.Key, entry.Value); } } }
/// <summary> /// Instanciates a new PDF Cross-Reference Table with an initial <see cref="IXRefSection"/>. /// </summary> /// <param name="section">The initial Cross-Reference section.</param> /// <param name="size">The total number of entries in the file’s cross-reference table, /// as defined by the combination of the original section and all update sections.</param> public XRefTable(IXRefSection section, int size) { if (section == null) { throw new ArgumentNullException(nameof(section)); } var entries = section.Entries; if (entries == null) { throw new NullReferenceException("Section's entries dictionary cannot be null"); } internalDictionary = new Dictionary <int, PdfObjectReferenceBase>(); this.size = size; foreach (var entry in entries) { internalDictionary.Add(entry.Key, entry.Value); } }