Thanks for the response.
Still facing the issue.
This is the code
Input pdf : test.pdf.
File Attachment:
File Name:
test.pdf
File Size:1 KB
APDirectory dir=new APDirectory();
// Source PDF
String path1 = "test.pdf";
final File f = new File(dir.rootDirectory(getApplicationContext()),path1);
//Target encrypted PDF
String path2 = "Encrypt.pdf";
final File f2= new File(dir.rootDirectory(getApplicationContext()),path2);
// Opening the file and encrypting the PDF with permissions
Document doc=new Document();
doc.Open(f.getAbsolutePath(),null);
System.out.println("Log - Encrypt : "+doc.EncryptAs(f2.getAbsolutePath(), "andy", "andy", 3, 0, new byte[32]));
doc.Close();
//Opening the encrypted PDF.
Intent intent=new Intent(getApplicationContext(),PDFReaderAct.class);
intent.putExtra( "PDFPath", f2.getAbsolutePath() );
intent.putExtra( "PDFPswd", "andy" );//password
startActivityForResult(intent,0);
Output :
Log - Encrypt : true
But in PDFReaderAct class m_doc.Open(PDFPath, PDFPswd) returns -1
Output pdf is "Encrypt.pdf"
Tried to open with external PDF viewers, it is asking to enter password but when I enter "andy" as password, says incorrect password.
The files test.pdf and Encrypt.pdf are located in internal storage memory(Downloads folder).
Please correct me if I am any where doing wrong?