iTextSharp.text.pdf.PRStream.SetData C# (CSharp) Метод

SetData() публичный Метод

public SetData ( byte data ) : void
data byte
Результат void
        public void SetData(byte[] data)
        {
            SetData(data, true);
        }

Same methods

PRStream::SetData ( byte data, bool compress ) : void
PRStream::SetData ( byte data, bool compress, int compressionLevel ) : void

Usage Example

Пример #1
0
 /// <summary>
 /// Parses a stream object and removes OCGs. </summary>
 /// <param name="stream">	a stream object </param>
 /// <param name="resources">	the resources dictionary of that object (containing info about the OCGs) </param>
 public virtual void Parse(PRStream stream, PdfDictionary resources) {
     baos = new MemoryStream();
     properties = resources.GetAsDict(PdfName.PROPERTIES);
     xobj = new HashSet2<PdfName>();
     PdfDictionary xobjects = resources.GetAsDict(PdfName.XOBJECT);
     if (xobjects != null) {
         // remove XObject (form or image) that belong to an OCG that needs to be removed
         foreach (PdfName name in xobjects.Keys) {
             PRStream xobject = (PRStream) xobjects.GetAsStream(name);
             PdfDictionary oc = xobject.GetAsDict(PdfName.OC);
             if (oc != null) {
                 PdfString ocname = oc.GetAsString(PdfName.NAME);
                 if (ocname != null && ocgs.Contains(ocname.ToString())) {
                     xobj.Add(name);
                 }
             }
         }
         foreach (PdfName name in xobj) {
             xobjects.Remove(name);
         }
     }
     // parse the content stream
     byte[] contentBytes = PdfReader.GetStreamBytes(stream);
     PRTokeniser tokeniser = new PRTokeniser(new RandomAccessFileOrArray(contentBytes));
     PdfContentParser ps = new PdfContentParser(tokeniser);
     List<PdfObject> operands = new List<PdfObject>();
     while (ps.Parse(operands).Count > 0) {
         PdfLiteral @operator = (PdfLiteral) operands[operands.Count - 1];
         ProcessOperator(this, @operator, operands);
     }
     baos.Flush();
     baos.Close();
     stream.SetData(baos.GetBuffer());
 }