Beispiel #1
0
 internal override void writeTo(Stream ostr, PdfWriter writer)
 {
     if (dicBytes == null)
     {
         toPdf(writer);
     }
     ostr.Write(dicBytes, 0, dicBytes.Length);
     ostr.Write(STARTSTREAM, 0, STARTSTREAM.Length);
     if (length > 0)
     {
         PdfEncryption crypto = writer.Encryption;
         if (offset < 0)
         {
             if (crypto == null)
             {
                 ostr.Write(bytes, 0, bytes.Length);
             }
             else
             {
                 crypto.prepareKey();
                 byte[] buf = new byte[length];
                 Array.Copy(bytes, 0, buf, 0, length);
                 crypto.encryptRC4(buf);
                 ostr.Write(buf, 0, buf.Length);
             }
         }
         else
         {
             byte[] buf = new byte[Math.Min(length, 4092)];
             RandomAccessFileOrArray file = writer.getReaderFile(reader);
             file.seek(offset);
             int size = length;
             if (crypto != null)
             {
                 crypto.prepareKey();
             }
             while (size > 0)
             {
                 int r = file.read(buf, 0, Math.Min(size, buf.Length));
                 size -= r;
                 if (crypto != null)
                 {
                     crypto.encryptRC4(buf, 0, r);
                 }
                 ostr.Write(buf, 0, r);
             }
         }
     }
     ostr.Write(ENDSTREAM, 0, ENDSTREAM.Length);
 }
Beispiel #2
0
 public int read()
 {
     return(file.read());
 }