/// <summary> /// Initializes a new stream data on this object if it does not already have one. /// </summary> /// <param name="encoding">The text encoding to use for the stream</param> /// <param name="filters">The filters set to use for writing the stream data</param> public void InitStream(IStreamFilter[] filters) { if (_disposed) { throw new InvalidOperationException("This indirect object has already been disposed"); } if (this._stream == null) { this._stream = this._factory.CreateStream(filters, this); } }
/// <summary> /// Creates a new non intialized Indirect object /// </summary> public PDFIndirectObject(IStreamFactory factory) { if (null == factory) { throw new ArgumentNullException("factory"); } this._gen = -1; this._number = -1; this._offset = -1L; this._factory = factory; this._objdata = factory.CreateStream(null, this); this._written = false; }
public virtual void ReleaseStreams(bool dispose) { if (dispose) { if (this._objdata != null) { this._objdata.Dispose(); } if (this._stream != null) { this._stream.Dispose(); } } this._objdata = null; this._stream = null; }
/// <summary> /// Writes all the file data from the current stream to the provided stream /// </summary> /// <param name="stream"></param> public void WriteTo(PDFStream stream) { long origpos = this._innerStream.Position; this._innerStream.Position = 0; long srclen = this._innerStream.Length; long destlen = stream.Length; byte[] buffer = new byte[4096]; int count = buffer.Length; while ((count = this._innerStream.Read(buffer, 0, count)) > 0) { stream.Write(buffer, 0, count); } stream.Flush(); System.Diagnostics.Debug.Assert(srclen + destlen == stream.Length); this._innerStream.Position = origpos; }
public void WriteTo(PDFStream stream) { this.WriteTo(stream.InnerStream); }