如何从ionic4的内部存储加载ePub?

问题描述 投票:0回答:1

我必须从 ionic4 的内部存储设备加载 epub。

当我从资产加载 epub 时,它加载正确,但是当我从内部存储设备加载 epub 时,无法正常加载。

   this.book = ePub("assets/temp1.epub");    
   this.rendition = this.book.renderTo("area", {
    spread: "always"
  });
 this.rendition.display();  

其显示正常

     const path = this.file.externalRootDirectory + 'ePub/temp1.epub';   
this.book = await ePub(path);   
      
      this.rendition = this.book.renderTo("area", {
        spread: "always"
      });
this.rendition.display();  

无法显示

typescript cordova ionic4 hybrid-mobile-app epub.js
1个回答
0
投票

您可以使用 sdcard 文件作为 ArrayBuffer 作为 ePub() 的参数来获取此内容

 this.file.readAsArrayBuffer(this.file.externalRootDirectory + '/appname/'+ '/', filename).then(arrayBuffer => {
        var book = ePub(arrayBuffer);
        var rendition = book.renderTo("area", { method: "default", width: "100%", height: "100%" });
      }).catch(err => { });
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.