Display PDF File : Error: "FileOpener" plugin is not implemented on android

I’am trying to display a pdf in my Ionic Angular Standalone app but when I run the app on the Android Emulator, I get the following error :

Capacitor/Console com.test.READPDF I File: https://localhost/944.e705025d73dcc28e.js - Line 1 - Msg: Error opening file Error: "FileOpener" plugin is not implemented on android

Here are the steps I followed :

  • ionic start ReadPDF (Angular, Standalone, Blank)
  • npm install @capacitor-community/file-opener
  • npx cap sync

My code :

import { Component } from '@angular/core';
import { IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/angular/standalone';
import { FileOpener, FileOpenerOptions } from '@capacitor-community/file-opener';

@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
  standalone: true,
  imports: [IonHeader, IonToolbar, IonTitle, IonContent],
})
export class HomePage {
  constructor() {}

  async openPDF() {
    try {
      const fileOpenerOptions: FileOpenerOptions = {
        filePath: 'file://../../assets/contract.pdf',
        contentType: 'application/pdf',
        openWithDefault: true,
      };
      await FileOpener.open(fileOpenerOptions);
    } catch (e) {
      console.log('Error opening file', e);
    }
  }
}

And then I run :

  • ionic build

  • ionic cap sync

  • ionic cap open android

And then I get the error when I call the function in the app through a button

What am I doing wrong ?
Thanks for your help !

Hi, I had the same issue, turned out I had "@capawesome-team/capacitor-file-opener": "6.1.0", and "@capacitor-community/file-opener": "6.0.0", installed. Removing "@capawesome-team/capacitor-file-opener": "6.1.0", solved the issue for me

1 Like