pdf未在cordova themeableBrowser中打开 [英] pdf is not opening in cordova themeableBrowser

查看:752
本文介绍了pdf未在cordova themeableBrowser中打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到一些教程,在离子2中打开pdf,不应该向用户下载。所以我发现了这个 Git hub repo

I saw some tutorial, in ionic 2 to open the pdf which should not be downloadable to user. So i found this Git hub repo.

现在当我下载项目并运行示例应用程序时... pdf未在中打开主题浏览器 ..

Now when I download the project and when I run the sample app.. the pdf is not opening in themeableBrowser..

它具有以下所有浏览器功能:

It has all browser feature like :

但是当我尝试 inAppBrowser 一切正常。但我需要使用 themeableBrowser 因为我需要一个pdf不应该是可下载的。如果有人清楚我的这个问题,为什么这不是在android平台上打开。

But when I tried inAppBrowser it works fine. But I need to work with themeableBrowser becasue i need a pdf should not be a downloadable. if any one clear this issue of mine why this is not opening in android platform.

你可以下载回购,你可以使用它。

you can download the repo and you can use that.

请帮帮我。它是我发现工作的唯一来源..
谢谢

please help me out. its a only source that i found to work.. Thanks

推荐答案

离子文档你可以使用这个 themeablebrowser 这是与您尝试使用的cordova themeablebrowser相同。

As stated on the ionic docs you can use this themeablebrowser which is same as the cordova themeablebrowser you are trying to use.

以下是工作代码片段:

In home.html 档案:

<ion-header>
  <ion-navbar>
    <ion-title>
      Ionic Blank
    </ion-title>
  </ion-navbar>
</ion-header>

<ion-content>
    <button ion-button (click)="test()">Test browser</button>
</ion-content>

home.ts 文件:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { InAppBrowser } from '@ionic-native';
import { ThemeableBrowser, ThemeableBrowserOptions, ThemeableBrowserObject } from '@ionic-native/themeable-browser';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

    constructor(public navCtrl: NavController, private themeableBrowser: ThemeableBrowser) {

  }

  test() {
      const options: ThemeableBrowserOptions = {
          statusbar: {
              color: '#ffffffff'
          },
          toolbar: {
              height: 44,
              color: '#f0f0f0ff'
          },
          title: {
              color: '#003264ff',
              showPageTitle: true
          },
          backButton: {
              image: 'back',
              imagePressed: 'back_pressed',
              align: 'left',
              event: 'backPressed'
          },
          forwardButton: {
              image: 'forward',
              imagePressed: 'forward_pressed',
              align: 'left',
              event: 'forwardPressed'
          },
          closeButton: {
              image: 'close',
              imagePressed: 'close_pressed',
              align: 'left',
              event: 'closePressed'
          },
          customButtons: [
              {
                  image: 'share',
                  imagePressed: 'share_pressed',
                  align: 'right',
                  event: 'sharePressed'
              }
          ],
          menu: {
              image: 'menu',
              imagePressed: 'menu_pressed',
              title: 'Test',
              cancel: 'Cancel',
              align: 'right',
              items: [
                  {
                      event: 'helloPressed',
                      label: 'Hello World!'
                  },
                  {
                      event: 'testPressed',
                      label: 'Test!'
                  }
              ]
          },
          backButtonCanClose: true
      };

      const browser: ThemeableBrowserObject = this.themeableBrowser.create('https://docs.google.com/viewerng/viewer?url=www.pdf995.com/samples/pdf.pdf', '_blank', options);
  }

}

以及 app.module.ts 文件添加 ThemeableBrowser 来自 @ ionic-native / themeable-browser 给提供者。

And in app.module.ts file add ThemeableBrowser from @ionic-native/themeable-browser to the providers.

添加 app.module.ts 后,文件应如下所示:

After adding your app.module.ts file should look like:

import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { ThemeableBrowser } from '@ionic-native/themeable-browser';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';

@NgModule({
  declarations: [
    MyApp,
    HomePage
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    ThemeableBrowser,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}

这是您在启动的离子应用程序中为主题所需的所有添加内容浏览器工作。

Thats all the additions you need in your started ionic app for your themeable browser to work.

在Android模拟器上测试过。

这篇关于pdf未在cordova themeableBrowser中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆