Close() public method

public Close ( ) : void
return void
		/**
        * 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();
                ZOutputStream zOut = new ZOutputStream(bOut, JZlib.Z_DEFAULT_COMPRESSION);

				content.Write(zOut);

				zOut.Close();

				comAlgId = new AlgorithmIdentifier(new DerObjectIdentifier(compressionOid));
				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
 /**
  * Creates a new PDF stream object that will replace a stream
  * in a existing PDF file.
  * @param   reader  the reader that holds the existing PDF
  * @param   conts   the new content
  * @param   compressionLevel    the compression level for the content
  * @since   2.1.3 (replacing the existing constructor without param compressionLevel)
  */
 public PRStream(PdfReader reader, byte[] conts, int compressionLevel)
 {
     this.reader = reader;
     this.offset = -1;
     if (Document.Compress) {
     MemoryStream stream = new MemoryStream();
     var zip = new ZOutputStream(stream, compressionLevel);
     zip.Write(conts, 0, conts.Length);
     zip.Close();
     bytes = stream.ToArray();
     Put(PdfName.FILTER, PdfName.FLATEDECODE);
     }
     else
     bytes = conts;
     Length = bytes.Length;
 }