GitHub user breautek added a comment to the discussion: How do I open a saved 
PDF file on my Android device ?

PDFs are complex binaries, so a pdf viewer software is necessary.

The proper "android" way is to use an Intent to open the PDF document, which 
the user can choose a supported application of their choice (e.g. Adobe Acrobat 
Reader).

Cordova doesn't have an out-of-the-box solution to open intents in a general 
sense. A cordova plugin will need to expose a way to request for the PDF to be 
opened using an app capable of reading PDFs.

Alternatively, Mozilla as a PDF reader implementation in pure JS using an HTML 
canvas (https://mozilla.github.io/pdf.js/). This will likely be not very 
performant if I were to guess, but it could be good enough for your needs and 
probably worth looking into. The 
[getDocument](https://mozilla.github.io/pdf.js/api/) API supports data types 
like an ArrayBuffer so you'd just use the cordova file plugin to read the data 
as an `ArrayBuffer` then you should be able to pass the ArrayBuffer directly 
into mozzila's PDF library.

```javascript
function readBinaryFile(fileEntry) {

    fileEntry.file(function (file) {
        var reader = new FileReader();

        reader.onloadend = function() {
            let data = this.result; // This is the ArrayBuffer
        };

        reader.readAsArrayBuffer(file);

    }, onErrorReadFile);
}
```

GitHub link: 
https://github.com/apache/cordova/discussions/510#discussioncomment-11331311

----
This is an automatically sent email for issues@cordova.apache.org.
To unsubscribe, please send an email to: issues-unsubscr...@cordova.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to