0

I'm using Launcher.Default.OpenAsync(OpenFileRequest request) to open a PDF file in an external PDF editor. The file loads correctly, but to edit the document this external app asks you to make a copy and edit over that copy, not the original file. I can edit the original file if I open the PDF using the device (Galaxy Tab S6 Lite) file explorer but it's not possible to do the same if I open the same file from my MAUI app.

I see OpenFileRequest constructor asks for a ReadOnlyFile. Is there a way I could create an "OpenFileRequest" with write permissions, or an alternative way to launch the document editor with the file so I can edit it without having to create a copy?

Example code:

var filename = "example.pdf";
var file = new ReadOnlyFile(filename);
var openFileRequest = new OpenFileRequest("PDF Document", file);
await Launcher.Default.OpenAsync(openFileRequest);

1 Answers1

0

I have tried to edit the pdf file with the Pdf Editor in some other apps. But all of them need to save as another file. So it seems only the file explorer can edit the original file.

In addition, the ReadOnlyFile is inherited from the FileBase. So you can try:

var filename = "example.pdf";
var file = new ReadOnlyFile(filename);
var openFileRequest = new OpenFileRequest("PDF Document", file as FileBase);
await Launcher.Default.OpenAsync(openFileRequest);

Actually, the other app doesn't have the permission to write the file in your app. You can refer to this case which is about editing pdf with external application does not overwrite existing file.

I can't find any native android api about grant the others app the write permission of the existing file. This should be the android permission limit.

Liyun Zhang - MSFT
  • 8,271
  • 1
  • 2
  • 14