Пример #1
0
        public object Clone()
        {
            PDFDictionary dict      = ResourcesBase.Copy(_dictionary);
            Resources     resources = new Resources(dict, false);

            return(resources);
        }
Пример #2
0
        internal static PDFDictionaryStream Copy(PDFDictionaryStream dictStream)
        {
            Stream stream = dictStream.GetStream();

            byte[] buf = new byte[stream.Length];
            stream.Position = 0;
            stream.Read(buf, 0, buf.Length);

            MemoryStream newStream = new MemoryStream();

            newStream.Write(buf, 0, buf.Length);

            PDFDictionary dict    = dictStream.Dictionary;
            PDFDictionary newDict = new PDFDictionary();

            string[] keys = { "Type", "Subtype", "FormType", "BBox", "Matrix", "Ref", "Metadata", "LastModified", "Name" };
            for (int i = 0; i < keys.Length; ++i)
            {
                IPDFObject obj = dict[keys[i]];
                if (obj != null)
                {
                    newDict.AddItem(keys[i], obj.Clone());
                }
            }

            PDFDictionary resources = dict["Resources"] as PDFDictionary;

            if (resources != null)
            {
                newDict.AddItem("Resources", ResourcesBase.Copy(resources));
            }

            PDFDictionary group = dict["Group"] as PDFDictionary;

            if (group != null)
            {
                newDict.AddItem("Group", GroupBase.Copy(group));
            }

            // PieceInfo, OPI, OC - still unknown
            // StructParent, StructParents - do not

            IPDFObject filter = dict["Filter"];

            if (filter != null)
            {
                newDict.AddItem("Filter", filter.Clone());
            }

            IPDFObject decodeParms = dict["DecodeParms"];

            if (decodeParms != null)
            {
                newDict.AddItem("DecodeParms", decodeParms.Clone());
            }

            return(new PDFDictionaryStream(newDict, newStream));
        }