Example #1
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);
 }
Example #2
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);
 }
Example #3
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);
        }
Example #4
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;
        }