Exemple #1
0
        protected override void SaveExtraKeys(TPdfStream DataStream, TXRefSection XRef, bool Compress)
        {
            Debug.Assert(DataStream.Compress == false); //It shouldn't be turned on at this place.
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.LengthName, FunctionData(Compress).Length.ToString(CultureInfo.InvariantCulture));
            if (NeedsCompression(Compress))
            {
                TStreamRecord.SetFlateDecode(DataStream);
            }

            TDictionaryRecord.SaveKey(DataStream, TPdfToken.SizeName, PdfConv.ToString(Size, true));
            TDictionaryRecord.SaveKey(DataStream, TPdfToken.BitsPerSampleName, 8);
        }
Exemple #2
0
        public void WriteFunctionObject(TPdfStream DataStream, TXRefSection XRef, bool Compress)
        {
            XRef.SetObjectOffset(GetFunctionObjId(DataStream, XRef), DataStream);
            TIndirectRecord.SaveHeader(DataStream, FunctionObjId);
            TDictionaryRecord.BeginDictionary(DataStream);

            TDictionaryRecord.SaveKey(DataStream, TPdfToken.FunctionTypeName, FunctionType);
            if (Domain != null)
            {
                TDictionaryRecord.SaveKey(DataStream, TPdfToken.DomainName, PdfConv.ToString(Domain, true));
            }

            if (Range != null)
            {
                TDictionaryRecord.SaveKey(DataStream, TPdfToken.RangeName, PdfConv.ToString(Range, true));
            }

            SaveExtraKeys(DataStream, XRef, Compress);

            TDictionaryRecord.EndDictionary(DataStream);
            SaveStream(DataStream, XRef, Compress);

            TIndirectRecord.SaveTrailer(DataStream);
        }
Exemple #3
0
 protected override void SaveExtraKeys(TPdfStream DataStream, TXRefSection XRef, bool Compress)
 {
     TDictionaryRecord.SaveKey(DataStream, TPdfToken.C0Name, PdfConv.ToString(C0, true));
     TDictionaryRecord.SaveKey(DataStream, TPdfToken.C1Name, PdfConv.ToString(C1, true));
     TDictionaryRecord.SaveKey(DataStream, TPdfToken.NName, PdfConv.DoubleToString(N));
 }
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;
            }
        }