2017-09-11 50 views
0

嘗試使用下面的代碼在離子2應用程序中打開離線pdf,但代碼在cleverdox查看器中打開pdf文件而不是Adobe Reader,我怎樣才能設置adobe讀者默認在這裏使PDF功能。提前致謝。如何在離子2應用程序在Adobe閱讀器中打開離線2應用程序

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

回答

0

嘗試openWith()像下面,

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

不知道,如果你有這個決心,但這裏是固定的,我的問題:

確保你正在使用文檔Viewer插件的最新版本。

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的代碼的問題是,他添加了一個函數應該是一個嵌套的對象。欲瞭解更多信息,請參閱以下網址:https://github.com/sitewaerts/cordova-plugin-document-viewer

希望對未來的任何人都有幫助。

相關問題