Davide.77
Davide.77

Reputation: 315

Ionic preview pdf file

I'm trying to open a pdf file in my ionic application. I'm searching on google since days but I'm not able to find a solution.

With this code I save my pdf file generated locally

async savePDF(pdfString, filename) {
    try {
        const result = await Filesystem.writeFile({
            path: '/' + filename,
            data: pdfString,
            directory: FilesystemDirectory.Data,
            encoding: FilesystemEncoding.UTF8
        })
        console.log('Wrote file', JSON.stringify(result));
    } catch(e) {
        console.error('Unable to write file', e);
    }
}

this code is working fine on my phone but "FilesystemDirectory.Data" creates a relative path and every previewer wants the full path of the pdf.

How can I retrieve the full path of the file saved?

Otherwise, How can I preview, inform the user or open the pdf file saved having the string or the Uint8Array of the file?

Please help, I cannot find any way to do this.

Thanks!

Upvotes: 0

Views: 582

Answers (1)

simonramosb
simonramosb

Reputation: 71

Im not so sure about it, but i think you can open it with the capacitor browser plugin! Works fine with online pdfs. Good luck and tell me if it works :)

Upvotes: 1

Related Questions