2017-09-11 8 views
0

ionic 2アプリケーションでオフラインpdfを開くために以下のコードを試していますが、コードはAdobe Readerの代わりにcleverdoxビューアでpdfファイルを開きますデフォルトではpdfを機能させるためにここに読者を追加します。前もって感謝します。Adob​​e Readerでionic 2アプリケーションのオフラインpdfを開く方法

open() 
 
    { 
 
    const options: DocumentViewerOptions = { 
 
    title: 'My PDF' 
 
    } 
 
    this.document.viewDocument('file:///android_asset/www/assets/test.pdf', 'application/pdf', options) 
 
}

答えて

0

あなたは、これが解決してしまった場合は考え

open() 
    { 
    const options: DocumentViewerOptions = { 
    title: 'My PDF', 
    openWith() { 
    enabled: true 
    } 
    } 
    this.document.viewDocument('file:///android_asset/www/assets/test.pdf', 'application/pdf', options) 
} 
+0

エラー: '{title:string; openWith():void; } 'は' DocumentViewerOptions '型に割り当てられません。プロパティ 'openWith'の型は互換性がありません。タイプ '()=> void'はタイプ '{enabled:boolean; } '。プロパティ 'enabled'は '()=> void'型ではありません。 –

1

、以下のような)(openWithを試していないが、ここで私のために問題を修正するものです。

あなたのことを確認してくださいドキュメントビューアプラグインの最新バージョンを使用しています。

open() { 
    const options: DocumentViewerOptions = { 
    title: 'My PDF', 
    openWith: { enabled: true }, //this will allow you to open the document with an external application 
    // any more options 
    }; 
    this.document.viewDocument('file:///android_asset/www/assets/test.pdf', 'application/pdf', options); 
} 

@ rj7のコードの問題は、ネストされたオブジェクトでなければならないものに関数を追加したことです。この機能に取り入れることができるオプションの詳細については、次のURLを参照してください。https://github.com/sitewaerts/cordova-plugin-document-viewer

将来に立ち往生する人に役立つことを望みます。

関連する問題