documentID is missing

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

documentID is missing

mursitorhan
when I want to sign a puclic key encrypted pdf, I get an excepiton because of the documentID is null.

for pdfreader I used this construction.
 PdfReader reader = new PdfReader(src,
            getPublicCertificate("resources/encryption/foobar.cer"), getPrivateKey());


I got an exception at the time of  PreClose phase
           
            Dictionary<PdfName, int> exc = new Dictionary<PdfName, int>();
            exc[PdfName.CONTENTS] = csize * 2 + 2;
            sap.PreClose(exc);

is there any idea that what is the possible problem of me?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: documentID is missing

mursitorhan
I think documentID is set only when user or owner password setup is required but in my situation SetupByEncryptionKey is called and this method does not anything about documentID
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: documentID is missing

mursitorhan
I am not sure it is correct but the problem is gone when
 in PdfStamperImp class I chanced Close method as below

  ......
 
            PdfObject fileID = null;
            if (crypto != null) {
                if (append) {
                    encryption = reader.GetCryptoRef();
                } else {
                    PdfIndirectObject encryptionObject = AddToBody(crypto.GetEncryptionDictionary(), false);
                    encryption = encryptionObject.IndirectReference;
                }
                try
                {
                    fileID = crypto.FileID;
                }
//I added this part to generate a documentID
                catch (Exception)
                {
                    fileID = PdfEncryption.CreateInfoId(PdfEncryption.CreateDocumentId());                    
                }
               
....

Loading...