pwlin / cordova-plugin-file-opener2

A File Opener Plugin for Cordova
MIT License
314 stars 583 forks source link

pdf opened in an external app cannot save changes #323

Closed ToMoAxi closed 1 year ago

ToMoAxi commented 2 years ago

Expected Behaviour

I open a pdf with the file-opener2 plugin and the acrobat reader can save its changes.

Actual Behaviour

The pdf opens correctly but the changes (for example, the signature) are not saved. I used Adobe Acrobat v21.6.0.18197

The file exists in the directory.

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Android 11 Cordova 9.0.0 Android Platform 8.0.0

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

via AVD

Plugin version

3.0.5

Sample Code that illustrates the problem

// externalDataDirectory = file:///storage/emulated/0/Android/data/[APP_ID]/files/
window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory, function (dir) {
    dir.getFile("15-07-21-174005_000010009647_SR.pdf", {}, function (file) {
        // nativeURL = file:///storage/emulated/0/Android/data/[APP_ID]/files/15-07-21-174005_000010009647_SR.pdf
        // also tried file.toInternalURL() = "cdvfile://localhost/files-external/15-07-21-174005_000010009647_SR.pdf"
        cordova.plugins.fileOpener2.open(file.nativeURL, "application/pdf", {
            success: function () {
                ...
            },
            error: function (oError) {
                ...
            },
        });
    }, function (oError) {
        ...
    });
});

config.xml from the app:

<access origin="*"/>
<allow-intent href="*" />
<allow-navigation href="*" />

<platform name="android">
    <icon src="www/offlineRes/img/mobile-icons/logo-header.png" density="xhdpi"/>
    <preference name="android-minSdkVersion" value="21"/> <!--Android 4.1-->
    <preference name="android-targetSdkVersion" value="29"/>
    <preference name="AndroidExtraFilesystems" value="files,files-external,documents,sdcard,cache,cache-external,root"/>
    <preference name="AndroidPersistentFileLocation" value="Internal" />
    <preference name="AndroidPersistentFileLocation" value="Compatibility" />
    <preference name="loadUrlTimeoutValue" value="700000"/>

    <custom-config-file parent="/*" target="AndroidManifest.xml">
        <uses-permission android:name="android.permission.CAMERA"/>
        <uses-feature android:name="android.hardware.camera"/>
        <uses-feature android:name="android.hardware.camera.autofocus"/>
    </custom-config-file>
    <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
        <application android:usesCleartextTraffic="true" />
        <application android:networkSecurityConfig="@xml/network_security_config" />
    </edit-config>
    <resource-file src="merges/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
</platform>

<allow-navigation href="http://*/*"/>
shnist commented 1 year ago

hi, this is a duplicate of #164 . The plugin doesn't support the editing of files. I think I will update the README to make this clear.