示例#1
0
 public PdfItem[] ToArray(int start, int length)
 {
   PdfItem[] items = new PdfItem[length];
   for (int i = 0, j = start; i < length; i++, j++)
     items[i] = (PdfItem)this.items[j];
   return items;
 }
    internal override void SetObject(PdfItem value)
    {
      PdfObject obj = (PdfObject)value;

      this.tbxObjectID.Text = PdfInternals.GetObjectID(obj).ToString();
      this.txtType.Text = obj.GetType().Name;

      this.lvKeys.Items.Clear();

      ListViewItem item = new ListViewItem(
        new string[3]{ExplorerProcess.GetTypeName(obj), value.ToString(), value.GetType().Name});
      this.lvKeys.Items.Add(item);
    }
    internal override void SetObject(PdfItem obj)
    {
      PdfDictionary dict = (PdfDictionary)obj;

      if (PdfInternals.GetObjectID(dict).IsEmpty)
        this.tbxObjectID.Text = "«direct»";
      else
        this.tbxObjectID.Text = PdfInternals.GetObjectID(dict).ToString();
      this.txtType.Text = dict.GetType().Name;

      this.lvKeys.Items.Clear();
      this.tbxStream.Clear();
      PdfName[] keys = dict.Elements.KeyNames;
      foreach (PdfName key in keys)
      {
        bool indirect = false;
        PdfItem tag = null;
        PdfItem value = dict.Elements[key];
        if (value == null)
        {
          throw new NotImplementedException("Value is null.");
        }
        else if (value is PdfReference)
        {
          indirect = true;
          value = ((PdfReference)value).Value;
          tag = value;
        }
        else
        {
          if (value is PdfObject)
            tag = value;
        }

        string address = "";
        if (indirect)
          address = /*((PdfObject)value).ObjectID.ToString() +*/ "---> ";
        ListViewItem item = new ListViewItem(
          new string[4]{key.Value, 
          address + value.ToString(), 
          indirect ? PdfInternals.GetObjectID((PdfObject)value).ToString() : "", 
          value.GetType().Name});
        item.Tag = tag;
        this.lvKeys.Items.Add(item);
      }

      FillStreamBox();
    }
示例#4
0
    internal override void SetObject(PdfItem obj)
    {
      PdfArray array = (PdfArray)obj;

      if (PdfInternals.GetObjectID(array).IsEmpty)
        this.tbxObjectID.Text = "«direct»";
      else
        this.tbxObjectID.Text = PdfInternals.GetObjectID(array).ToString();
      this.txtType.Text = array.GetType().Name;

      this.lvItems.Items.Clear();
      PdfItem[] items = array.Elements.Items;
      int count = items.Length;
      for (int idx = 0; idx < count; idx++)
      {
        bool indirect = false;
        PdfItem tag = null;
        PdfItem value = items[idx];
        if (value == null)
        {
          throw new NotImplementedException("Value is null.");
        }
        else if (value is PdfReference)
        {
          indirect = true;
          value = ((PdfReference)value).Value;
          tag = value;
        }
        else
        {
          if (value is PdfObject)
            tag = value;
        }

        string address = "";
        if (indirect)
          address = /*((PdfObject)value).ObjectID.ToString() +*/ "---> ";
        ListViewItem item = new ListViewItem(
          new string[4]{idx.ToString(), 
          address + value.ToString(), 
          indirect ? PdfInternals.GetObjectID((PdfObject)value).ToString() : "", 
          value.GetType().Name});
        item.Tag = tag;
        this.lvItems.Items.Add(item);
      }
    }
      /// <summary>
      /// Parse the colorspace information from the specified colorspace item.
      /// </summary>
      /// <param name="colorSpace">The external color space object to parse.</param>
      public static PdfColorSpace Parse(PdfItem colorSpace)
      {
        if (colorSpace == null)  throw new ArgumentNullException("colorSpace", "The provided color space was null.");

        Func<PdfItem, PdfColorSpace> defaultAction = (a) => { throw new Exception(String.Format("An unsupported colorspace '{0}' was provided.", GetColorSpaceName(a))); };
        IDictionary<string, Func<PdfItem, PdfColorSpace>> map = new Dictionary<string, Func<PdfItem, PdfColorSpace>> {
          // An Indexed color space is defined by a four-element array, as follows:
          //
          //   /Indexed base hival lookup
          //
          // base - an array or name that identifies the base color space in which the values in the color table are to be interpreted
          // hival - an integer that specifies the maximum valid index value. I
          // lookup - The color table is defined by the lookup parameter, which can be either a stream or (in PDF 1.2) a string
          { "/Indexed", (a) => {
            if (a == null) throw new ArgumentNullException("a", "The indexed colorspace cannot be null.");

            var array = (a as PdfArray) ?? (a.Get() as PdfArray);
            if (array == null) throw new ArgumentException("a", "The indexed colorspace not specified as an array.");
            
            PdfItem colorBase = array.Elements[1].Get(); // base
            int colors = array.Elements.GetInteger(2);   // hival
            PdfItem lookup = array.Elements[3];          // lookup
            
            // We currently only support DeviceRGB indexed color spaces.
            if ((colorBase.IsName() && ((PdfName) colorBase).Value == "/DeviceRGB")) {
              return (new PdfIndexedRGBColorSpace(lookup, colors));
            }
            throw new NotImplementedException(String.Format("The indexed colorspace '{0}' is not supported.", GetColorSpaceName(colorBase)));
          } }, 
          // Standard RGB Colorspace
          { "/DeviceRGB", (a) => new PdfRGBColorSpace() },
          // Gray Colorspace
          { "/DeviceGray", (a) => new PdfGrayColorSpace() },
          // Standard CMYK Colorspace
          { "/DeviceCMYK", (a) => {
            throw new NotImplementedException("CMYK encoded images are not supported.");
            return (new PdfCMYKColorSpace());
          } },
        };

        string name = GetColorSpaceName(colorSpace);
        var action = (map.ContainsKey(name) ? map[name] : defaultAction);
        return(action.Invoke(colorSpace));
      }
示例#6
0
//    internal virtual void UpdateDocument()
//    {
//    }
//
    internal override void SetObject(PdfItem item)
    {
      if (item != null)
      {
        MemoryStream memoryStream = new MemoryStream();
        PdfItem[] items;
        if (item is PdfObject && this.btnClosure.Checked)
        {
          PdfObject[] objects = this.explorer.Process.Document.Internals.GetClosure((PdfObject)item);
          items = new PdfItem[objects.Length];
          objects.CopyTo(items, 0);
          this.txtClosure.Text = String.Format("Closure contains {0} elements.", objects.Length);
        }
        else
        {
          this.txtClosure.Text = "";
          items = new PdfItem[1]{item};
        }
      
        for (int idx = 0; idx < items.Length; idx++)
          this.explorer.Process.Document.Internals.WriteObject(memoryStream, items[idx]);
      
        int count = (int)memoryStream.Length;
        byte[] bytes = new byte[count];
        memoryStream.Position = 0;
        memoryStream.Read(bytes, 0, count);
        char[] chars = new char[count];
      
        // Keep in mind that a PDF stream has no intrinsic encoding.
        for (int idx = 0; idx < count; idx++)
        {
          byte b = bytes[idx];
          if (b == 0)
            chars[idx] = '?';
          else
            chars[idx] = (char)bytes[idx];
        }
        string pdf = new string(chars);
        this.tbxPdf.Text = pdf;
      }
    }
        /// <summary>
        /// Adds a key/value pair to the Names array of this node.
        /// </summary>
        public void AddName(string key, PdfItem value)
        {
            PdfArray names = Elements.GetArray(Keys.Names);

            if (names == null)
            {
                names = new PdfArray();
                Elements.SetObject(Keys.Names, names);
            }

            // Insert names sorted by key.
            int i = 0;

            while (i < names.Elements.Count && string.CompareOrdinal(names.Elements.GetString(i), key) < 0)
            {
                // Entries are key / value pairs, so add 2.
                i += 2;
            }

            names.Elements.Insert(i, new PdfString(key));
            names.Elements.Insert(i + 1, value);
            _updateRequired = true;
        }
示例#8
0
        /// <summary>
        /// Initializes a new instance of the PdfRectangle class with the specified PdfArray.
        /// </summary>
        internal PdfRectangle(PdfItem item)
        {
            if (item == null || item is PdfNull)
            {
                return;
            }

            if (item is PdfReference)
            {
                item = ((PdfReference)item).Value;
            }

            PdfArray array = item as PdfArray;

            if (array == null)
            {
                throw new InvalidOperationException("");
            }

            _x1 = array.Elements.GetReal(0);
            _y1 = array.Elements.GetReal(1);
            _x2 = array.Elements.GetReal(2);
            _y2 = array.Elements.GetReal(3);
        }
示例#9
0
        internal override void WriteObject(PdfWriter writer)
        {
            // TODO: Take /Rotate into account
//#warning THHO4STLA: warum nicht new PdfRectangle(mediaBox.Y1, mediaBox.X1, mediaBox.Y2, mediaBox.X2)? - siehe auch Orientation
//#warning THHO4STLA: CropBox, BleedBox etc. auch drehen?

#if true
            // Add transparency group to prevent rendering problems of Adobe viewer
            this.transparencyUsed = true; // TODO: check XObjects
            if (this.transparencyUsed && !Elements.ContainsKey(Keys.Group))
            {
                PdfDictionary group = new PdfDictionary();
                this.elements["/Group"] = group;
                if (this.document.Options.ColorMode != PdfColorMode.Cmyk)
                {
                    group.Elements.SetName("/CS", "/DeviceRGB");
                }
                else
                {
                    group.Elements.SetName("/CS", "/DeviceCMYK");
                }
                group.Elements.SetName("/S", "/Transparency");
                group.Elements["/I"] = new PdfBoolean(false);
                group.Elements["/K"] = new PdfBoolean(false);
            }
#endif

#if DEBUG_
            PdfItem item = Elements["/MediaBox"];
            if (item != null)
            {
                item.GetType();
            }
#endif
            base.WriteObject(writer);
        }
 /// <summary>
 /// Get's the colorspace name for the specified item.
 /// </summary>
 /// <param name="colorSpace">The colorspace to inspect.</param>
 /// <returns>The PdfName of the specified item.</returns>
 private static string GetColorSpaceName(PdfItem colorSpace)
 {
     if (colorSpace == null)
     {
         return(null);
     }
     if (colorSpace.IsArray())
     {
         return(GetColorSpaceName(((PdfArray)colorSpace).Elements[0]));
     }
     if (colorSpace.IsName())
     {
         return(((PdfName)colorSpace).Value);
     }
     if (colorSpace.IsReference())
     {
         PdfReference reference = (colorSpace as PdfReference);
         if (reference != null)
         {
             return(GetColorSpaceName(reference.Value));
         }
     }
     return(null);
 }
示例#11
0
 internal virtual void SetObject(PdfItem value)
 {
 }
示例#12
0
      /// <summary>
      /// Appends the specified object to the array.
      /// </summary>
      public int Add(PdfItem value)
      {
        // TODO: ??? 
        //Debug.Assert((value is PdfObject && ((PdfObject)value).Reference == null) | !(value is PdfObject),
        //  "You try to set an indirect object directly into an array.");

        PdfObject obj = value as PdfObject;
        if (obj != null && obj.IsIndirect)
          return this.elements.Add(obj.Reference);
        return this.elements.Add(value);
      }
示例#13
0
 /// <summary>
 /// Gets the index of the specified item.
 /// </summary>
 public int IndexOf(PdfItem value)
 {
   return this.elements.IndexOf(value);
 }
示例#14
0
 /// <summary>
 /// Determines whether the specified value is in the array.
 /// </summary>
 public bool Contains(PdfItem value)
 {
   return this.elements.Contains(value);
 }
示例#15
0
      /// <summary>
      /// Appends the specified object to the array.
      /// </summary>
      public int Add(PdfItem value)
      {
        // TODO: ??? 
        Debug.Assert((value is PdfObject && ((PdfObject)value).Reference == null) | !(value is PdfObject),
          "You try to set an indirect object directly into an array.");

        return this.elements.Add(value);
      }
      /// <summary>
      /// Parse the colorspace information from the specified colorspace item.
      /// </summary>
      /// <param name="colorSpace">The external color space object to parse.</param>
      public static PdfColorSpace Parse(PdfItem colorSpace)
      {
        if (colorSpace == null)  throw new ArgumentNullException("colorSpace", "The provided color space was null.");

        Func<PdfItem, PdfColorSpace> defaultAction = (a) => { throw new Exception(String.Format("An unsupported colorspace '{0}' was provided.", GetColorSpaceName(a))); };
        IDictionary<string, Func<PdfItem, PdfColorSpace>> map = new Dictionary<string, Func<PdfItem, PdfColorSpace>> {
          // An Indexed color space is defined by a four-element array, as follows:
          //
          //   /Indexed base hival lookup
          //
          // base - an array or name that identifies the base color space in which the values in the color table are to be interpreted
          // hival - an integer that specifies the maximum valid index value. I
          // lookup - The color table is defined by the lookup parameter, which can be either a stream or (in PDF 1.2) a string
          { "/Indexed", (a) => {
            if (a == null) throw new ArgumentNullException("a", "The indexed colorspace cannot be null.");

            var array = (a as PdfArray) ?? (a.Get() as PdfArray);
            if (array == null) throw new ArgumentException("a", "The indexed colorspace not specified as an array.");
            
            PdfItem colorBase = array.Elements[1].Get(); // base
            int colors = array.Elements.GetInteger(2);   // hival
            PdfItem lookup = array.Elements[3];          // lookup
            
            // We currently only support DeviceRGB indexed color spaces.
            if ((colorBase.IsName() && ((PdfName) colorBase).Value == "/DeviceRGB")) {
              return (new PdfIndexedRGBColorSpace(lookup, colors));
            }
            throw new NotImplementedException(String.Format("The indexed colorspace '{0}' is not supported.", GetColorSpaceName(colorBase)));
          } }, 
          // Standard RGB Colorspace
          { "/DeviceRGB", (a) => new PdfRGBColorSpace() },
          // Gray Colorspace
          { "/DeviceGray", (a) => new PdfGrayColorSpace() },
          // Standard CMYK Colorspace
          { "/DeviceCMYK", (a) => {
            throw new NotImplementedException("CMYK encoded images are not supported.");
            return (new PdfCMYKColorSpace());
          } },
        };

        string name = GetColorSpaceName(colorSpace);
        var action = (map.ContainsKey(name) ? map[name] : defaultAction);
        return(action.Invoke(colorSpace));
      }
 /// <param name="colorSpace">The pdfItem representing the color space.</param>
 /// <param name="colors">The number of colors.</param>
 public PdfIndexedRGBColorSpace(PdfItem colorSpace, int colors): base(colors)
 {
   if (colorSpace == null) throw new ArgumentNullException("colorSpace", "The colorspace must be specified when creating a PdfIndexedRGBColorSpace.");
   _colorSpace = colorSpace;
 }
示例#18
0
        static void DebugCheckNonObjects(PdfItem item)
        {
            if (item is PdfName)
                return;
            if (item is PdfBoolean)
                return;
            if (item is PdfInteger)
                return;
            if (item is PdfNumber)
                return;
            if (item is PdfString)
                return;
            if (item is PdfRectangle)
                return;
            if (item is PdfNull)
                return;

            Type type = item.GetType();
            Debug.Assert(type != null, string.Format("CheckNonObjects: Add {0} to the list.", type.Name));
        }
示例#19
0
 public void Reset(PdfItem value)
 {
   this.items.Clear();
   this.cursor = 0;
   this.top = 0;
   SetNext(value);
 }
示例#20
0
 /// <summary>
 /// Adds the specified value to the dictionary.
 /// </summary>
 public void Add(object key, PdfItem value)
 {
   ((IDictionary)this).Add(key, value);
 }
示例#21
0
        /// <summary>
        /// Initializes this instance from an existing PDF document.
        /// </summary>
        void Initialize()
        {
            string title;

            if (Elements.TryGetString(Keys.Title, out title))
            {
                Title = title;
            }

            PdfReference parentRef = Elements.GetReference(Keys.Parent);

            if (parentRef != null)
            {
                PdfOutline parent = parentRef.Value as PdfOutline;
                if (parent != null)
                {
                    Parent = parent;
                }
            }

            Count = Elements.GetInteger(Keys.Count);

            PdfArray colors = Elements.GetArray(Keys.C);

            if (colors != null && colors.Elements.Count == 3)
            {
                double r = colors.Elements.GetReal(0);
                double g = colors.Elements.GetReal(1);
                double b = colors.Elements.GetReal(2);
                TextColor = XColor.FromArgb((int)(r * 255), (int)(g * 255), (int)(b * 255));
            }

            // Style directly works on dictionary element.

            PdfItem dest = Elements.GetValue(Keys.Dest);
            PdfItem a    = Elements.GetValue(Keys.A);

            Debug.Assert(dest == null || a == null, "Either destination or goto action.");

            PdfArray destArray = null;

            if (dest != null)
            {
                destArray = dest as PdfArray;
                if (destArray != null)
                {
                    SplitDestinationPage(destArray);
                }
                else
                {
                    Debug.Assert(false, "See what to do when this happened.");
                }
            }
            else if (a != null)
            {
                // The dictionary should be a GoTo action.
                PdfDictionary action = a as PdfDictionary;
                if (action != null && action.Elements.GetName(PdfAction.Keys.S) == "/GoTo")
                {
                    dest      = action.Elements[PdfGoToAction.Keys.D];
                    destArray = dest as PdfArray;
                    if (destArray != null)
                    {
                        // Replace Action with /Dest entry.
                        Elements.Remove(Keys.A);
                        Elements.Add(Keys.Dest, destArray);
                        SplitDestinationPage(destArray);
                    }
                    else
                    {
                        throw new Exception("Destination Array expected.");
                    }
                }
                else
                {
                    Debug.Assert(false, "See what to do when this happened.");
                }
            }
            else
            {
                // Neither destination page nor GoTo action.
            }

            InitializeChildren();
        }
示例#22
0
 /// <summary>
 /// Pushes the specified item onto the stack.
 /// </summary>
 public void Shift(PdfItem item)
 {
   Debug.Assert(item != null);
   this.items.Add(item);
   this.sp++;
 }
示例#23
0
 /// <summary>
 /// Replaces the last 'count' items with the specified item.
 /// </summary>
 public void Reduce(PdfItem item, int count)
 {
   Debug.Assert(item != null);
   Reduce(count);
   this.items.Add(item);
   this.sp++;
 }
示例#24
0
    /// <summary>
    /// Initializes a new instance of the PdfRectangle class with the specified PdfArray.
    /// </summary>
    internal PdfRectangle(PdfItem item)
    {
      if (item == null || item is PdfNull)
        return;

      if (item is PdfReference)
        item = ((PdfReference)item).Value;

      PdfArray array = item as PdfArray;
      if (array == null)
        throw new InvalidOperationException(PSSR.UnexpectedTokenInPdfFile);

      this.x1 = array.Elements.GetReal(0);
      this.y1 = array.Elements.GetReal(1);
      this.x2 = array.Elements.GetReal(2);
      this.y2 = array.Elements.GetReal(3);
    }
示例#25
0
 private static string RemoveFirstLast(PdfSharp.Pdf.PdfItem input)
 {
     return(input.ToString().Replace("(", "").Replace(")", "").Replace(@"\", ""));
 }
示例#26
0
      /// <summary>
      /// Sets the entry with the specified value. DON'T USE THIS FUNCTION - IT MAY BE REMOVED.
      /// </summary>
      public void SetValue(string key, PdfItem value)
      {
        Debug.Assert((value is PdfObject && ((PdfObject)value).Reference == null) | !(value is PdfObject),
          "You try to set an indirect object directly into a dictionary.");

        // HACK?
        this.elements[key] = value;
      }
示例#27
0
 /// <summary>
 /// Writes a PdfItem into the specified stream.
 /// </summary>
 // This function exists to keep PdfWriter and PdfItem.WriteObject internal.
 public void WriteObject(Stream stream, PdfItem item)
 {
   // Never write an encrypted object
   PdfWriter writer = new PdfWriter(stream, null);
   writer.Options = PdfWriterOptions.OmitStream;
   item.WriteObject(writer);
 }
示例#28
0
 public void SetNext(PdfItem value)
 {
   if (this.items.Count <= this.cursor)
     this.items.Add(null);
   this.items[this.cursor++] = value;
   this.top = cursor;
 }
示例#29
0
        /// <summary>
        /// Replace all indirect references to external objects by their cloned counterparts
        /// owned by the importer document.
        /// </summary>
        internal static void FixUpObject(PdfImportedObjectTable iot, PdfDocument owner, PdfObject value)
        {
            Debug.Assert(ReferenceEquals(iot.Owner, owner));

            PdfDictionary dict;
            PdfArray      array;

            if ((dict = value as PdfDictionary) != null)
            {
                // Set document for cloned direct objects
                if (dict.Owner == null)
                {
                    dict.Document = owner;
                }
                else
                {
                    Debug.Assert(dict.Owner == owner);
                }

                // Search for indirect references in all keys
                PdfName[] names = dict.Elements.KeyNames;
                foreach (PdfName name in names)
                {
                    PdfItem item = dict.Elements[name];
                    // Is item an iref?
                    PdfReference iref = item as PdfReference;
                    if (iref != null)
                    {
                        // Does the iref already belongs to the owner?
                        if (iref.Document == owner)
                        {
                            // Yes: fine. Happens when an already cloned object is reused.
                            continue;
                        }
                        else
                        {
                            //Debug.Assert(iref.Document == iot.Document);
                            // No: replace with iref of cloned object
                            PdfReference newXRef = iot[iref.ObjectID];
                            Debug.Assert(newXRef != null);
                            Debug.Assert(newXRef.Document == owner);
                            dict.Elements[name] = newXRef;
                        }
                    }
                    else if (item is PdfObject)
                    {
                        // Fix up inner objects
                        FixUpObject(iot, owner, (PdfObject)item);
                    }
                }
            }
            else if ((array = value as PdfArray) != null)
            {
                // Set document for cloned direct objects
                if (array.Owner == null)
                {
                    array.Document = owner;
                }
                else
                {
                    Debug.Assert(array.Owner == owner);
                }

                // Search for indirect references in all array elements
                int count = array.Elements.Count;
                for (int idx = 0; idx < count; idx++)
                {
                    PdfItem item = array.Elements[idx];
                    // Is item an iref?
                    PdfReference iref = item as PdfReference;
                    if (iref != null)
                    {
                        // Does the iref already belongs to the owner?
                        if (iref.Document == owner)
                        {
                            // Yes: fine. Happens when an already cloned object is reused.
                            continue;
                        }
                        else
                        {
                            Debug.Assert(iref.Document == iot.ExternalDocument);
                            // No: replace with iref of cloned object
                            PdfReference newXRef = iot[iref.ObjectID];
                            Debug.Assert(newXRef != null);
                            Debug.Assert(newXRef.Document == owner);
                            array.Elements[idx] = newXRef;
                        }
                    }
                    else if (item is PdfObject)
                    {
                        // Fix up inner objects
                        FixUpObject(iot, owner, (PdfObject)item);
                    }
                }
            }
        }
 /// <summary>
 /// Retrieves the raw data for the colorspace.
 /// </summary>
 /// <returns>The raw data from the PdfArray of PdfReference.</returns>
 protected virtual IEnumerable<byte> GetRawPalette(PdfItem item)
 {
   // The palette data is directly imbedded.
   if (item.IsArray()) return(GetRawPalette(item as PdfArray));
   if (item.IsReference()) return (GetRawPalette(item as PdfReference));
 
   throw new ArgumentException("The specified palette information was incorrect.", "item");
 }
示例#31
0
 /// <summary>
 /// Inserts the item the specified index.
 /// </summary>
 public void Insert(int index, PdfItem value)
 {
   this.elements.Insert(index, value);
 }
 /// <summary>
 /// Get's the colorspace name for the specified item.
 /// </summary>
 /// <param name="colorSpace">The colorspace to inspect.</param>
 /// <returns>The PdfName of the specified item.</returns>
 private static string GetColorSpaceName(PdfItem colorSpace)
 {
   if (colorSpace == null) return(null);
   if (colorSpace.IsArray()) return (GetColorSpaceName(((PdfArray)colorSpace).Elements[0]));
   if (colorSpace.IsName()) return (((PdfName) colorSpace).Value);
   if (colorSpace.IsReference()) {
     PdfReference reference = (colorSpace as PdfReference);
     if (reference != null) {
       return (GetColorSpaceName(reference.Value));
     }
   }
   return (null);
 }
示例#33
0
 /// <summary>
 /// Removes the specified value.
 /// </summary>
 public void Remove(PdfItem value)
 {
   this.elements.Remove(value);
 }
示例#34
0
 public void NavigateTo(PdfItem item)
 {
 }
 /// <param name="colorSpace">The pdfItem representing the color space.</param>
 /// <param name="colors">The number of colors.</param>
 public PdfIndexedRGBColorSpace(PdfItem colorSpace, int colors): base(colors)
 {
   if (colorSpace == null) throw new ArgumentNullException("colorSpace", "The colorspace must be specified when creating a PdfIndexedRGBColorSpace.");
   _colorSpace = colorSpace;
 }