Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Questions about Android development and PDF

Use of EncryptAs method

More
10 years 8 months ago #9232 by scott2srikanth
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.
More
10 years 8 months ago #9237 by scott2srikanth
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.
More
10 years 8 months ago - 10 years 8 months ago #9239 by radaee
Replied by radaee on topic Use of EncryptAs method
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.
Last edit: 10 years 8 months ago by radaee.
More
10 years 8 months ago - 10 years 8 months ago #9247 by scott2srikanth
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.33 KB

Code:
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);
Code:
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:1.73 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?
Last edit: 10 years 8 months ago by scott2srikanth.
More
10 years 8 months ago #9254 by radaee
Replied by radaee on topic Use of EncryptAs method
just fixed, it set incorrect file ID from native lib.
More
10 years 8 months ago #9255 by radaee
Replied by radaee on topic Use of EncryptAs method
we'll upload a new version later.
Time to create page: 0.387 seconds
Powered by Kunena Forum