Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF
  • Page:
  • 1
  • 2

TOPIC:

Use of EncryptAs method 8 years 9 months ago #9232

  • scott2srikanth
  • scott2srikanth's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 6
  • Thank you received: 0
Hi,
Currently I am working on PDF protection to prevent editing and modifying the PDF by others.
So, I am using Document.EncryptAs() method by following code.

byte file_id[] = new byte[32];
//file_id="MyKeysABCDEFGHIJKLMNOPQRSTUVWXYZ".getBytes();
//int ret=m_doc.Open(path, null);
System.out.println("Encpryt : "+ m_doc.EncryptAs(f.getAbsolutePath(), null, "OPASS", 3, 0, file_id ));
With the above code it returns true and able to encrypt the file but not able to open it.
It is asking to provide password to open it, but the user password is null

What is the problem in the above code ? Is their any default password provided.

Please Log in or Create an account to join the conversation.

Use of EncryptAs method 8 years 9 months ago #9237

  • scott2srikanth
  • scott2srikanth's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 6
  • Thank you received: 0
is it a bug?
I have premium licence and still facing the same issue.
I need to make PDF read only to prevent modifying by others.

Please Log in or Create an account to join the conversation.

Use of EncryptAs method 8 years 9 months ago #9239

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
tested, seems OK.
1. do not pass same path to Document Open and EncryptAs, these codes are invalid:

Document doc = new Document();
doc.Open("/sdcard/test.pdf", null);
doc.EncryptAs("/sdcard/test.pdf", null, ......);

2. do not pass other password when opening Encrypted PDF file.
if u using null to encrypt PDF file, just pass null to open encrypted PDF file.
if problems remain, u can send your PDF files to our service mail.

Please Log in or Create an account to join the conversation.

Last edit: by radaee.

Use of EncryptAs method 8 years 9 months ago #9247

  • scott2srikanth
  • scott2srikanth's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 6
  • Thank you received: 0
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"

File Attachment:

File Name: Encrypt.pdf
File Size:2 KB

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?
Attachments:

Please Log in or Create an account to join the conversation.

Last edit: by scott2srikanth.

Use of EncryptAs method 8 years 9 months ago #9254

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
just fixed, it set incorrect file ID from native lib.

Please Log in or Create an account to join the conversation.

Use of EncryptAs method 8 years 9 months ago #9255

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
we'll upload a new version later.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Powered by Kunena Forum