How to open PDF on android using Intent to edit file?

Viewed 376

I'm trying to use Intent on my Android app to open PDF file in another third party app (e.g. adobe reader, etc..) using the code below.

I'm able to successfully open the pdf file and edit its contents but when I exit the pdf app it generates additional copy of the PDF file with the intended changes. It doesn't save the changes on the original file itself. Any ideas why?

I have used the appropriate URI read/write permissions as below:

Intent chooserIntent = new Intent();

chooserIntent.setAction(Intent.ACTION_VIEW);
// Also tried action_edit with no luck:  chooserIntent.setAction(Intent.ACTION_EDIT);

chooserIntent.setDataAndType(contentUri, mimeType);
chooserIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
chooserIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
chooserIntent.addCategory(Intent.CATEGORY_DEFAULT);
startActivity(chooserIntent);

Any direction in the right direction is hugely appreciated. I've been stuck on this for some time. At the moment I'm opening a file called 'Test.pdf' and when I annotate and exit the file, it saves these changes as 'Test1.pdf'. If I opened it again it will generate yet another file called 'Test2.pdf'... I tried adobe reader, ezPDF with same results.

The original PDF is saved in '/storage/emulated/0/Download/Test' folder while the newly generated PDF files are saved in following directory (in case of ezPDF reader): '/storage/emulated/0/ezPDFReader/bookdata/library'

Looking forward to hearing from you, Many thanks..

0 Answers
Related