예제 #1
0
 /// <summary>
 /// Gets a cross reference entry from an object identifier.
 /// Returns null if no object with the specified ID exists in the object table.
 /// </summary>
 public PdfReference this[PdfObjectID objectID]
 {
     get
     {
         PdfReference iref;
         ObjectTable.TryGetValue(objectID, out iref);
         return(iref);
     }
 }
예제 #2
0
 /// <summary>
 /// Indicates whether this instance and a specified object are equal.
 /// </summary>
 public override bool Equals(object obj)
 {
     if (obj is PdfObjectID)
     {
         PdfObjectID id = (PdfObjectID)obj;
         if (_objectNumber == id._objectNumber)
         {
             return(_generationNumber == id._generationNumber);
         }
     }
     return(false);
 }
예제 #3
0
 /// <summary>
 /// Compares the current object id with another object.
 /// </summary>
 public int CompareTo(object obj)
 {
     if (obj is PdfObjectID)
     {
         PdfObjectID id = (PdfObjectID)obj;
         if (_objectNumber == id._objectNumber)
         {
             return(_generationNumber - id._generationNumber);
         }
         return(_objectNumber - id._objectNumber);
     }
     return(1);
 }
예제 #4
0
        /// <summary>
        /// Finds a page by its id. Transforms it to PdfPage if necessary.
        /// </summary>
        internal PdfPage FindPage(PdfObjectID id)  // TODO: public?
        {
            PdfPage page = null;

            foreach (PdfItem item in PagesArray)
            {
                PdfReference reference = item as PdfReference;
                if (reference != null)
                {
                    PdfDictionary dictionary = reference.Value as PdfDictionary;
                    if (dictionary != null && dictionary.ObjectID == id)
                    {
                        page = dictionary as PdfPage ?? new PdfPage(dictionary);
                        break;
                    }
                }
            }
            return(page);
        }
예제 #5
0
        /// <summary>
        /// Sets the object and generation number.
        /// Setting the object identifier makes this object an indirect object, i.e. the object gets
        /// a PdfReference entry in the PdfReferenceTable.
        /// </summary>
        internal void SetObjectID(int objectNumber, int generationNumber)
        {
            PdfObjectID objectID = new PdfObjectID(objectNumber, generationNumber);

            // TODO: check imported
            if (_iref == null)
            {
                _iref = _document._irefTable[objectID];
            }
            if (_iref == null)
            {
                // ReSharper disable once ObjectCreationAsStatement because the new object is set to this object
                // in the constructor of PdfReference.
                new PdfReference(this);
                Debug.Assert(_iref != null);
                _iref.ObjectID = objectID;
            }
            _iref.Value    = this;
            _iref.Document = _document;
        }
예제 #6
0
 /// <summary>
 /// Indicates whether the specified object identifier is in the table.
 /// </summary>
 public bool Contains(PdfObjectID objectID)
 {
     return(ObjectTable.ContainsKey(objectID));
 }