예제 #1
0
 private void Write(PdfNumber pdfNumber)
 {
     if (pdfNumber.HasContent())
     {
         WriteBytes(pdfNumber.GetInternalContent());
     }
     else
     {
         if (pdfNumber.IsDoubleNumber())
         {
             WriteDouble(pdfNumber.GetValue());
         }
         else
         {
             WriteInteger(pdfNumber.IntValue());
         }
     }
 }
예제 #2
0
        /// <summary>
        /// Adds a new
        /// <c>PdfOutline</c>
        /// with specified parameters as a child to existing
        /// <c>PdfOutline</c>
        /// and put it to specified position in the existing
        /// <c>PdfOutline</c>
        /// children list.
        /// </summary>
        /// <param name="title">an outline title</param>
        /// <param name="position">
        /// a position in the current outline child List where a new outline should be added.
        /// If the position equals -1, then the outline will be put in the end of children list.
        /// </param>
        /// <returns>just created outline</returns>
        public virtual iText.Kernel.Pdf.PdfOutline AddOutline(String title, int position)
        {
            if (position == -1)
            {
                position = children.Count;
            }
            PdfDictionary dictionary = new PdfDictionary();

            iText.Kernel.Pdf.PdfOutline outline = new iText.Kernel.Pdf.PdfOutline(title, dictionary, this);
            dictionary.Put(PdfName.Title, new PdfString(title, PdfEncodings.UNICODE_BIG));
            dictionary.Put(PdfName.Parent, content);
            if (children.Count > 0)
            {
                if (position != 0)
                {
                    PdfDictionary prevContent = children[position - 1].GetContent();
                    dictionary.Put(PdfName.Prev, prevContent);
                    prevContent.Put(PdfName.Next, dictionary);
                }
                if (position != children.Count)
                {
                    PdfDictionary nextContent = children[position].GetContent();
                    dictionary.Put(PdfName.Next, nextContent);
                    nextContent.Put(PdfName.Prev, dictionary);
                }
            }
            if (position == 0)
            {
                content.Put(PdfName.First, dictionary);
            }
            if (position == children.Count)
            {
                content.Put(PdfName.Last, dictionary);
            }
            PdfNumber count = this.content.GetAsNumber(PdfName.Count);

            if (count == null || count.GetValue() != -1)
            {
                content.Put(PdfName.Count, new PdfNumber(children.Count + 1));
            }
            children.Add(position, outline);
            return(outline);
        }