Close() public method

public Close ( ) : void
return void
Ejemplo n.º 1
0
		/**
        * Generate an object that contains an CMS Compressed Data
        */
        public CmsCompressedData Generate(
            CmsProcessable	content,
            string			compressionOid)
        {
            AlgorithmIdentifier comAlgId;
            Asn1OctetString comOcts;

            try
            {
                MemoryStream bOut = new MemoryStream();
                ZDeflaterOutputStream zOut = new ZDeflaterOutputStream(bOut);

				content.Write(zOut);

				zOut.Close();

				comAlgId = new AlgorithmIdentifier(
					new DerObjectIdentifier(compressionOid),
					null);

				comOcts = new BerOctetString(bOut.ToArray());
            }
            catch (IOException e)
            {
                throw new CmsException("exception encoding data.", e);
            }

            ContentInfo comContent = new ContentInfo(CmsObjectIdentifiers.Data, comOcts);
            ContentInfo contentInfo = new ContentInfo(
                CmsObjectIdentifiers.CompressedData,
                new CompressedData(comAlgId, comContent));

			return new CmsCompressedData(contentInfo);
        }
Ejemplo n.º 2
0
 /**
  * Sets the data associated with the stream, either compressed or
  * uncompressed. Note that the data will never be compressed if
  * Document.compress is set to false.
  *
  * @param data raw data, decrypted and uncompressed.
  * @param compress true if you want the stream to be compresssed.
  * @param compressionLevel  a value between -1 and 9 (ignored if compress == false)
  * @since   iText 2.1.3
  */
 public void SetData(byte[] data, bool compress, int compressionLevel)
 {
     Remove(PdfName.FILTER);
     this.offset = -1;
     if (Document.Compress && compress) {
     MemoryStream stream = new MemoryStream();
     ZDeflaterOutputStream zip = new ZDeflaterOutputStream(stream, compressionLevel);
     zip.Write(data, 0, data.Length);
     zip.Close();
     bytes = stream.ToArray();
     this.compressionLevel = compressionLevel;
     Put(PdfName.FILTER, PdfName.FLATEDECODE);
     }
     else
     bytes = data;
     Length = bytes.Length;
 }