示例#1
0
        public void Write(SaveParameters param)
        {
            Stream stream = param.Stream;

            stream.WriteByte((byte)'<');
            stream.WriteByte((byte)'<');

            int count = _items.Count;

            for (int i = 0; i < count; ++i)
            {
                KeyValuePair <string, IPDFObject> pair = _items[i];
                PDFName.Write(stream, pair.Key);

                stream.WriteByte((byte)' ');

                IPDFObject val = pair.Value;
                if (val is PDFDictionary || val is PDFDictionaryStream)
                {
                    if (!param.WriteInheritableObjects)
                    {
                        StringUtility.WriteToStream(val.ObjNo, stream);
                        stream.WriteByte((byte)' ');
                        stream.WriteByte((byte)'0');
                        stream.WriteByte((byte)' ');
                        stream.WriteByte((byte)'R');
                    }
                    else
                    {
                        val.Write(param);
                    }
                }
                else
                {
                    val.Write(param);
                }

                if (i != count - 1)
                {
                    stream.WriteByte((byte)'\n');
                }
            }

            stream.WriteByte((byte)'>');
            stream.WriteByte((byte)'>');
        }
示例#2
0
        //internal ByteRange
        //internal Contents

        static internal int Write(SaveParameters param, PDFDictionary dict, out int[] byteRange)
        {
            int byteRangeOffset = -1;

            byteRange    = new int[4];
            byteRange[0] = 0;

            Stream stream = param.Stream;

            stream.WriteByte((byte)'<');
            stream.WriteByte((byte)'<');

            string[] keys  = dict.GetKeys();
            int      count = keys.Length;

            for (int i = 0; i < count; ++i)
            {
                string key = keys[i];
                PDFName.Write(stream, key);

                stream.WriteByte((byte)' ');

                IPDFObject val = dict[key];

                if (key == "ByteRange")
                {
                    byteRangeOffset = (int)stream.Position;
                }
                else if (key == "Contents")
                {
                    byteRange[1] = (int)stream.Position;
                }

                if (val is PDFDictionary || val is PDFDictionaryStream)
                {
                    if (!param.WriteInheritableObjects)
                    {
                        StringUtility.WriteToStream(val.ObjNo, stream);
                        stream.WriteByte((byte)' ');
                        stream.WriteByte((byte)'0');
                        stream.WriteByte((byte)' ');
                        stream.WriteByte((byte)'R');
                    }
                    else
                    {
                        val.Write(param);
                    }
                }
                else
                {
                    val.Write(param);
                }

                if (key == "ByteRange")
                {
                    for (int j = 0; j < 30; j++)
                    {
                        stream.WriteByte((byte)' ');
                    }
                }
                else if (key == "Contents")
                {
                    byteRange[2] = (int)stream.Position;
                }

                if (i != count - 1)
                {
                    stream.WriteByte((byte)'\n');
                }
            }

            stream.WriteByte((byte)'>');
            stream.WriteByte((byte)'>');

            return(byteRangeOffset);
        }