Пример #1
0
        /// <summary>
        /// Adds the specified annotation to the collection.
        /// </summary>
        /// <param name="annotation">Annotation to be added.</param>
        public void Add(Annotation annotation)
        {
            if (annotation == null)
            {
                throw new ArgumentNullException();
            }

            Annotation copy = annotation.Clone(_owner, _page);

            _annotations.Add(copy);
            _array.AddItem(copy.Dictionary);

            if (annotation is MarkupAnnotation)
            {
                PopupAnnotation popup = (annotation as MarkupAnnotation).Popup;
                if (popup != null)
                {
                    Annotation popupClone = popup.Clone(_owner, _page);
                    (popupClone as PopupAnnotation).SetParent(copy);

                    copy.Dictionary.AddItem("Popup", popupClone.Dictionary);
                    _array.AddItem(popupClone.Dictionary);
                }
            }
            else if (annotation is Field)
            {
                if (_owner != null)
                {
                    _owner.AddField(copy as Field);
                }
            }
        }
Пример #2
0
        internal Page Clone(IDocumentEssential owner)
        {
            if (_owner == null)
            {
                _owner = owner;
                if (_onClosed != null)
                {
                    _onClosed.ApplyOwner(owner);
                }
                if (_onOpened != null)
                {
                    _onOpened.ApplyOwner(owner);
                }

                if (_dictionary["Annots"] as PDFArray != null)
                {
                    for (int i = 0; i < Annotations.Count; ++i)
                    {
                        Annotations[i].ApplyOwner(owner);
                        if (Annotations[i] is Field)
                        {
                            _owner.AddField(Annotations[i] as Field);
                        }
                    }
                }

                return(this);
            }

            PDFDictionary pageDictionary = PageBase.Copy(GetDictionary());
            Page          page           = new Page(pageDictionary, owner);

            if (_dictionary["Annots"] as PDFArray != null)
            {
                page.Annotations = Annotations.Clone(owner, this);
            }

            if (OnClosed != null)
            {
                page.OnClosed = OnClosed;
            }
            if (OnOpened != null)
            {
                page.OnOpened = OnOpened;
            }

            page._id = _id;
            return(page);
        }