2
votes

I use the following code to open a pdf form. If I use Acrobat Reader it's not possible to write back to the original file. It always makes a copy which I only could guess but newer know for shure in my app.

I know that it has to be possible to edit the original because if I open a pdf from any file manager (e.g. the one from Asus) Adobe Reader edits it directly.

Xodo PDF allows direct edit. It even supports the correct ACTION_EDIT intent but I'm afraid that our users insist to use Adobe...

How can I edit the original with Adobe?

final File file = new File(Environment.getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS) + File.separator + "x.pdf");
if(file.exists())
{
    file.setWritable(true,false);
    Intent intent = new Intent(Intent.ACTION_VIEW);
    Uri contentUri = FileProvider.getUriForFile(Objects.requireNonNull(getContext()),
    BuildConfig.APPLICATION_ID + ".fileprovider", file);
    intent.setDataAndType(contentUri,"application/pdf");
    intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY|Intent.FLAG_GRANT_WRITE_URI_PERMISSION|Intent.FLAG_GRANT_READ_URI_PERMISSION);
    intent = Intent.createChooser(intent, "Open File");
    startActivity(intent);
}
1
Hi. Did you find the solution? I'm facing the same problem. ThanksFantomasMex
Xodo PDF seems to be the only solution. Our customer accepted it.With Excel it seems to be the same crap - there we use Google Sheets now...The incredible Jan
Looks like the latest Android updates completely destroyed the ACTION_EDIT intent. I can't save back to the provided file anymore. No matter what app is used to edit. Crap.The incredible Jan

1 Answers

0
votes

At the moment even Xodo doesn't work anymore but I was lucky to realized that OneDrive-PDF-Viewer does.