离子2离线pdf视图

时间:2017-08-16 19:10:03

标签: angular typescript ionic2 ionic3

我开发了一个离子3应用程序,可以从远程服务器检索书籍信息。该应用可以阅读谷歌文档iframe中嵌入的pdf书籍。目前它在线工作。

视图-book.html

<ion-header>

  <ion-navbar>
    <ion-title>View book</ion-title>
  </ion-navbar>

</ion-header>


<ion-content padding>

 <iframe width="100%" height="100%" [src]="pdfUrl" frameborder="0" allowfullscreen>
</iframe>


</ion-content>

视图-book.ts

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import {SafeResourceUrl, DomSanitizer} from '@angular/platform-browser';

import { Storage } from '@ionic/storage';

@IonicPage()
@Component({
  selector: 'page-view-book',
  templateUrl: 'view-book.html',
})
export class ViewBookPage {
    book: any;
    pdfUrl: SafeResourceUrl;

  constructor(private domSanitizer: DomSanitizer, 
              public navCtrl: NavController, 
              public navParams: NavParams) {

    this.book = navParams.data.book;
    // get url of pdf and embed in iframe from google docs
    this.pdfUrl = this.domSanitizer.bypassSecurityTrustResourceUrl(
        'http://docs.google.com/gview?url='+this.book+'&embedded=true');

  }

现在的问题是,我希望能够以某种方式存储谷歌文档网页或查看远程书籍而无需下载pdf,以便我可以在没有互联网的情况下离线阅读。请帮助,谢谢。

0 个答案:

没有答案