Images-to-PDF
Images-to-PDF copied to clipboard
Merging in view files not working with encyption
The merge function in the view files segment can't use encrypted input files.
Steps to reproduce
- Create a password protected pdf
- got to "View Files"
- Select some pdfs including the encrypted one
- click on the merge icon
- input a valid name an click ok
Expected behaviour
A promt for the password of a pdf appears
Actual behaviour
the snackbar plops up with the message that it couldn't access the PDFs
Would you like to work on the issue?
when no one else takes it and everything else i'm currently working on here is done
We can check all pdf files for encryption and create a prompt for password only if any PDF is encrypted. We can check if a pdf is encrpyted using Apache PDFBox library - https://pdfbox.apache.org/
Sample Code:
try { document = PDDocument.load( "C:\abc.pdf");
if(document.isEncrypted())
{
//Then the pdf file is encrypeted.
// Display a prompt for password of the file.
}
}
Hope it helps !
Thank you for providing the code pointers for this library.
But, we also have a encryption utility here which can check if document is encrypted: https://github.com/Swati4star/Images-to-PDF/blob/master/app/src/main/java/swati4star/createpdf/util/PDFEncryptionUtility.java#L127
I would like to work on this issue. I have a doubt regarding the expected behaviour. If we are trying to merge more than 1 password encrypted files then should there be a prompt asking to unlock each and every pdf which is password protected before merging? @Swati4star @McModknower can any of you clarify me this so that I can start the work?
Yeah @HaripriyaB So, whenever user selects a encrypted file, we can show a promt "This PDF is password protected. Please enter your password to select this" and a edittext to allow user to enter password. Add 2 options to this dialog: "Submit" and "Remove File".
If the password is incorrect, show the above prompt again.
Yeah @HaripriyaB So, whenever user selects a encrypted file, we can show a promt "This PDF is password protected. Please enter your password to select this" and a edittext to allow user to enter password. Add 2 options to this dialog: "Submit" and "Remove File".
If the password is incorrect, show the above prompt again.
Thanks @Swati4star 😊 I'll start working on it and if I need some more clarification I'll reach out to you.
I have a doubt. When I tried to removePassword(already existing function) of a file it creates a new file which is the decrypted version of that file and the encrypted file still exists. I want to ask if there is any way to decrypt the file while merging in runtime? If not then I'm planning to implement it as follows:
- Remove password of the file and add the newly created file to the list of files to be merged
- Remove the encrypted file from the list fo files to merge.
- After merging, the decrypted files will be deleted from the list of files present. So, After merging there will be one merged file and no other change done to any of the files.
@Swati4star Pls confirm.
@HaripriyaB your approach sounds good. In the 1st step, i hope we don't show to user that we are doing all this in background
Hii @Swati4star . Wanted to work on this issue and would soon raise a PR with the changes. Could you please assign this issue to me?