Decrypting strings in my PDF encrypted with custom security

64 views
Skip to first unread message

rajku...@gmail.com

unread,
Oct 18, 2013, 4:32:15 PM10/18/13
to
Scenario:
  User want to update the string using pdfnet when we use PDF encryption/decryption.

Sample code:

SDFDoc ddd = new SDFDoc(Encdata)
LoadAllStringObj();
 for (int i = 0; i < lstObj.Count; i++)
 {
    Obj objCurrent = (Obj) lstObj[i];
    DecryptString(objCurrent);
 }
 public void DecryptString(Obj objString)
 {
   try
   {
      byte[] data = new Decryptor.Decrypt(GetData(objString.GetRawStream(false)));
        objString.SetString(data);
    }
    catch (Exception e)
    {

    }
}
Question :

   When user invoke the objString.SetSting it throws exception?
Exception:
{System.Runtime.InteropServices.COMException (0x80004005): Unspecified error
   at pdftron.SDF.Obj.SetString(Byte[] value)

How to resolve this error.Anybody knows the answer please reply.
Note:
   We are PDFNet for Windows phone 8 SDF.

Support

unread,
Oct 18, 2013, 4:32:44 PM10/18/13
to
 
Looking at your code you are calling GetRawStream() on a string object. This method can only be invoked on stream objects (you want to use GetBuffer() instead). For details please refer to Obj documentation (http://www.pdftron.com/pdfnet/html/classpdftron_1_1SDF_1_1Obj.html).
Reply all
Reply to author
Forward
0 new messages