On Thu, 2022-01-27 at 16:04 +0100, Christian Sakowski wrote: > Hi, > > i am using 0.9.7. However, i have activated OpenSSL and now i am > getting ePdfError_InternalLogic while writing an encrypted pdf file: > > PoDoFo::PdfMemDocument doc1; > > doc1.Load(inPath); > doc1.SetEncrypted(pass1, pass2); > doc1.Write(outPath); //-> ePdfError_InternalLogic
Hi, does it print any detailed error on the console? A backtrace of the exception? Anything than the generic "it doesn't work" will help to diagnose. You can search the source code and see where and why it failed, if the detailed error is not useful. I do not have any test code for this, my only code creates a mem document, then sets the encryption on it and only then draws to the document and writes it to the stream. Something like (this is inefficient, only a test code from a distant past): PdfEncrypt *encrypt; encrypt = PdfEncrypt::CreatePdfEncrypt("", "owner", 0, algo, keyLength); PdfMemDocument *memDocument = new PdfMemDocument(); memDocument->SetEncrypted(*encrypt); delete encrypt; drawPage(memDocument); memDocument->Write(....); delete memDocument; I think it should work to encrypt existing document, thus I guess you maybe picked an unsupported algorithm or something like that. The pairs for 'algo' and 'keyLength' from the above I used are: PdfEncrypt::ePdfEncryptAlgorithm_RC4V1, PdfEncrypt::ePdfKeyLength_40 PdfEncrypt::ePdfEncryptAlgorithm_RC4V2, PdfEncrypt::ePdfKeyLength_128 PdfEncrypt::ePdfEncryptAlgorithm_AESV2, PdfEncrypt::ePdfKeyLength_128 PdfEncrypt::ePdfEncryptAlgorithm_AESV3, PdfEncrypt::ePdfKeyLength_256 where some can fail due to being disabled in the OpenSSL due to being considered insecure. Bye, zyx _______________________________________________ Podofo-users mailing list Podofo-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/podofo-users