Exemple #1
0
 /// <summary>
 /// Creates a new TBookmark instance.
 /// </summary>
 /// <param name="aTitle">Title of the bookmark item.</param>
 /// <param name="aDestination">Page where the bookmark points to.</param>
 /// <param name="aChildrenCollapsed">If true all children from this bookmark will be collapsed.</param>
 public TBookmark(string aTitle, TPdfDestination aDestination, bool aChildrenCollapsed)
 {
     FTitle             = aTitle;
     FDestination       = aDestination;
     FChildrenCollapsed = aChildrenCollapsed;
     FTextColor         = ColorUtil.FromArgb(0, 0, 0);
     FTextStyle         = TBookmarkStyle.None;
     FChildren          = new TBookmarkList();
 }
Exemple #2
0
        /// <summary>
        /// Returns a deep copy of this object.
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            TBookmarkList Result = new TBookmarkList();

            for (int i = 0; i < Count; i++)
            {
                Result.Add((TBookmark)this[i].Clone());
            }

            return(Result);
        }
Exemple #3
0
 internal TBodySection(bool aCompress)
 {
     Compress  = aCompress;
     Bookmarks = new TBookmarkList();
 }
Exemple #4
0
        internal void SaveBookmarkObjects(TPdfStream DataStream, TXRefSection XRef, TBookmarkList bmks, int ParentId, int ObjectId, ref int FirstId, ref int LastId, ref int AllOpenCount)
        {
            int PreviousId = -1;

            for (int i = 0; i < bmks.Count; i++)
            {
                TBookmark b = bmks[i];
                AllOpenCount++;

                int NextId = -1;
                if (i < bmks.Count - 1)
                {
                    NextId = XRef.GetNewObject(DataStream);
                }
                LastId = ObjectId;
                if (FirstId == -1)
                {
                    FirstId = ObjectId;
                }

                int FirstChildId   = -1;
                int LastChildId    = -1;
                int ChildOpenCount = 0;
                if (b.FChildren.Count > 0)
                {
                    FirstChildId = XRef.GetNewObject(DataStream);
                    int ChildLastId = -1;
                    SaveBookmarkObjects(DataStream, XRef, b.FChildren, ObjectId, FirstChildId, ref FirstId, ref ChildLastId, ref ChildOpenCount);
                    if (!b.ChildrenCollapsed)
                    {
                        AllOpenCount += ChildOpenCount;
                    }
                    LastChildId = ChildLastId;
                }


                XRef.SetObjectOffset(ObjectId, DataStream);
                TIndirectRecord.SaveHeader(DataStream, ObjectId);
                TDictionaryRecord.BeginDictionary(DataStream);
                TDictionaryRecord.SaveUnicodeKey(DataStream, TPdfToken.TitleName, b.Title);
                TDictionaryRecord.SaveKey(DataStream, TPdfToken.ParentName, TIndirectRecord.GetCallObj(ParentId));
                if (PreviousId >= 0)
                {
                    TDictionaryRecord.SaveKey(DataStream, TPdfToken.PrevName, TIndirectRecord.GetCallObj(PreviousId));
                }

                if (NextId >= 0)
                {
                    TDictionaryRecord.SaveKey(DataStream, TPdfToken.NextName, TIndirectRecord.GetCallObj(NextId));
                }

                if (FirstChildId >= 0)
                {
                    TDictionaryRecord.SaveKey(DataStream, TPdfToken.FirstName, TIndirectRecord.GetCallObj(FirstChildId));
                }

                if (LastChildId >= 0)
                {
                    TDictionaryRecord.SaveKey(DataStream, TPdfToken.LastName, TIndirectRecord.GetCallObj(LastChildId));
                }
                if (ChildOpenCount > 0)
                {
                    if (b.ChildrenCollapsed)
                    {
                        TDictionaryRecord.SaveKey(DataStream, TPdfToken.CountName, -ChildOpenCount);
                    }
                    else
                    {
                        TDictionaryRecord.SaveKey(DataStream, TPdfToken.CountName, ChildOpenCount);
                    }
                }


                if (b.Destination != null)
                {
                    TDictionaryRecord.SaveKey(DataStream, TPdfToken.DestName, GetDestStr(b.Destination));
                }

                if (b.TextColor.R != 0 || b.TextColor.G != 0 || b.TextColor.B != 0)
                {
                    TDictionaryRecord.SaveKey(DataStream, TPdfToken.CName, TPdfTokens.GetString(TPdfToken.OpenArray) + PdfConv.ToString(b.TextColor) + TPdfTokens.GetString(TPdfToken.CloseArray));
                }

                if (b.TextStyle != TBookmarkStyle.None)
                {
                    int k = 0;
                    if ((b.TextStyle & TBookmarkStyle.Italic) != 0)
                    {
                        k |= 1;
                    }
                    if ((b.TextStyle & TBookmarkStyle.Bold) != 0)
                    {
                        k |= 2;
                    }
                    TDictionaryRecord.SaveKey(DataStream, TPdfToken.FName, k);
                }

                TDictionaryRecord.EndDictionary(DataStream);
                TIndirectRecord.SaveTrailer(DataStream);

                PreviousId = ObjectId;
                ObjectId   = NextId;
            }
        }