- Posts: 6
- Thank you received: 0
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
- scott2srikanth
- Topic Author
- Offline
- New Member
-
Less
More
10 years 8 months ago #9232
by scott2srikanth
Use of EncryptAs method was created 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.
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.
- scott2srikanth
- Topic Author
- Offline
- New Member
-
Less
More
- Posts: 6
- Thank you received: 0
10 years 8 months ago #9237
by scott2srikanth
Replied by scott2srikanth on topic Use of EncryptAs method
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.
I have premium licence and still facing the same issue.
I need to make PDF read only to prevent modifying by others.
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.
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.
- scott2srikanth
- Topic Author
- Offline
- New Member
-
Less
More
- Posts: 6
- Thank you received: 0
10 years 8 months ago - 10 years 8 months ago #9247
by scott2srikanth
Replied by scott2srikanth on topic Use of EncryptAs method
Thanks for the response.
Still facing the issue.
This is the code
Input pdf : test.pdf.
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?
Still facing the issue.
This is the code
Input pdf : test.pdf.
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
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.
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.
Time to create page: 0.387 seconds