Пример #1
0
        private void parsePage(PDFArray arr, IDocumentEssential owner)
        {
            IPDFObject page = arr[0];

            if (page == null)
            {
                return;
            }
            if (page is PDFNumber)
            {
                _page = owner.GetPage((int)(page as PDFNumber).GetValue());
            }
            else if (page is PDFDictionary)
            {
                _page = owner.GetPage(page as PDFDictionary);
            }
            else
            {
                _page = null;
            }

            arr.RemoveItem(0);
            if (_page != null)
            {
                arr.Insert(0, _page.GetDictionary());
            }
            else
            {
                arr.Insert(0, new PDFNull());
            }
        }
Пример #2
0
        /// <summary>
        /// Gets or sets the element at the specified index.
        /// </summary>
        /// <param name="index" href="http://msdn.microsoft.com/en-us/library/system.int32.aspx">The zero-based index of the element to get or set.</param>
        /// <returns cref="PointF" href="http://msdn.microsoft.com/en-us/library/system.drawing.pointf.aspx">The element at the specified index.</returns>
        public PointF this[int index]
        {
            get
            {
                if (index < 0 || index >= _array.Count / 2)
                {
                    throw new IndexOutOfRangeException();
                }
                PDFNumber numberX = _array[index * 2] as PDFNumber;
                PDFNumber numberY = _array[index * 2 + 1] as PDFNumber;
                if (numberX == null)
                {
                    numberX = new PDFNumber(0);
                }
                if (numberY == null)
                {
                    numberY = new PDFNumber(0);
                }
                float numX = (float)numberX.GetValue();
                float numY = (float)numberY.GetValue();
                if (_page != null)
                {
                    numX = numX - _page.PageRect.Left;
                    numY = _page.PageRect.Bottom - numY;
                }
                return(new PointF(numX, numY));
            }
            set
            {
                if (index < 0 || index >= _array.Count / 2)
                {
                    throw new IndexOutOfRangeException();
                }
                if (_page != null)
                {
                    value.X = value.X + _page.PageRect.Left;
                    value.Y = _page.PageRect.Bottom - value.Y;
                }
                _array.RemoveItem(index * 2);
                _array.RemoveItem(index * 2);
                _array.Insert(index * 2, new PDFNumber(value.Y));
                _array.Insert(index * 2, new PDFNumber(value.X));

                if (ChangedPointsArray != null)
                {
                    ChangedPointsArray(this);
                }
            }
        }
Пример #3
0
        private void addFirstq(PDFArray contents)
        {
            MemoryStream ms = new MemoryStream(2);

            ms.WriteByte((byte)'q');
            ms.WriteByte((byte)'\r');
            PDFDictionaryStream q = new PDFDictionaryStream(new PDFDictionary(), ms);

            contents.Insert(0, q);
        }
Пример #4
0
        private void addItem(PDFArray array, IPDFObject key, IPDFObject value)
        {
            if (array == null)
            {
                return;
            }

            int number = (int)(key as PDFNumber).GetValue();

            for (int i = 0; i < array.Count; i += 2)
            {
                PDFNumber val = array[i] as PDFNumber;

                if (i + 2 < array.Count)
                {
                    PDFNumber val_next = array[i + 2] as PDFNumber;

                    if (val != null && val_next != null &&
                        ((int)val.GetValue()) <= number && number < ((int)val_next.GetValue()))
                    {
                        array.Insert(i + 2, key);
                        array.Insert(i + 3, value);
                        return;
                    }
                }
                else
                {
                    if (val != null && ((int)val.GetValue()) <= number)
                    {
                        array.AddItem(key);
                        array.AddItem(value);
                        return;
                    }
                    else
                    {
                        array.Insert(i, key);
                        array.Insert(i + 1, value);
                        return;
                    }
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Inserts an element at the specified index to the collection.
        /// </summary>
        /// <param name="index" href="http://msdn.microsoft.com/en-us/library/system.int32.aspx">The zero-based index at which the element is to be inserted.</param>
        /// <param name="item">The element to insert.</param>
        public void Insert(int index, OptionalContentGroupItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException();
            }
            if (index < 0 || index > Count)
            {
                throw new IndexOutOfRangeException();
            }

            _items.Insert(index, item);
            _array.Insert(index, item.GetObject());
        }
Пример #6
0
        /// <summary>
        /// Inserts a layer at the specified index to the collection.
        /// </summary>
        /// <param name="index" href="http://msdn.microsoft.com/en-us/library/system.int32.aspx">The zero-based index at which the outline is to be inserted.</param>
        /// <param name="layer">Layer to insert.</param>
        public void Insert(int index, Layer layer)
        {
            if (layer == null)
            {
                throw new ArgumentNullException("page");
            }
            if (index < 0 || index > Count)
            {
                throw new IndexOutOfRangeException();
            }

            _layers.Insert(index, layer);
            _array.Insert(index, layer.GetDictionary());
        }
Пример #7
0
        /// <summary>
        /// Inserts an element into the collection at the specified index.
        /// </summary>
        /// <param name="index" href="http://msdn.microsoft.com/en-us/library/system.int32.aspx">The zero-based index at which item should be inserted.</param>
        /// <param name="value" href="http://msdn.microsoft.com/en-us/library/system.string.aspx">The object to insert.</param>
        public void Insert(int index, string value)
        {
            if (index < 0 || index > Count)
            {
                throw new IndexOutOfRangeException();
            }
            if (value == null)
            {
                value = "";
            }

            _items.Insert(index, new PDFString(value));

            if (AddedChoiceItem != null)
            {
                AddedChoiceItem(this, new AddedChoiceItemEvent(value));
            }

            if (ChangedChoiceItems != null)
            {
                ChangedChoiceItems(this);
            }
        }