Exemple #1
0
        public static PdfFile Create(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            if (stream is MemoryStream)
            {
                return(new PdfMemoryStreamFile((MemoryStream)stream));
            }
            if (stream is FileStream)
            {
                return(new PdfFileStreamFile((FileStream)stream));
            }
            return(new PdfBufferFile(StreamExtensions.ToByteArray(stream)));
        }
        public override void Save(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            long offset = _stream.Position;

            try
            {
                StreamExtensions.CopyStream(_stream, stream);
            }
            finally
            {
                _stream.Position = offset;
            }
        }