iTextSharp.text.xml.ITextHandler.AddImage C# (CSharp) Method

AddImage() protected method

protected AddImage ( Image img ) : void
img Image
return void
        protected internal void AddImage(Image img) {
            // if there is an element on the stack...
            Object current = stack.Pop();
            // ...and it's a Chapter or a Section, the Image can be
            // added directly
            if (current is Chapter
                    || current is Section
                    || current is Cell) {
                ((ITextElementArray) current).Add(img);
                stack.Push(current);
                return;
            }
            // ...if not, we need to to a lot of stuff
            else {
                Stack newStack = new Stack();
                while (!(current is Chapter
                        || current is Section || current is Cell)) {
                    newStack.Push(current);
                    if (current is Anchor) {
                        img.Annotation = new Annotation(0, 0, 0,
                                0, ((Anchor) current).Reference);
                    }
                    current = stack.Pop();
                }
                ((ITextElementArray) current).Add(img);
                stack.Push(current);
                while (newStack.Count != 0) {
                    stack.Push(newStack.Pop());
                }
                return;
            }
        }