Ejemplo n.º 1
0
 /// <summary>
 /// Returns a System.String that represents the current Bytescout.PDF.ColorGray.
 /// </summary>
 /// <returns cref="string" href="http://msdn.microsoft.com/en-us/library/system.string.aspx">A System.String that represents the current Bytescout.PDF.ColorGray.</returns>
 public override string ToString()
 {
     return(StringUtility.GetString(_g * 1.0f / 255));
 }
Ejemplo n.º 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);
        }