В приложении Ionic PDF не отображается внутри iframe на Android, но отображается в эмуляторе - PullRequest
0 голосов
/ 05 июня 2019

Я показываю PDF-файл внутри iframe в моем приложении ionic 4.Это прекрасно работает в эмуляторе (ионная лаборатория), но когда я помещаю приложение на свое устройство Android (PH-1), вместо PDF появляется пустой экран.

Есть ли что-то особенное, что мне нужно сделать?отобразить PDF в моем приложении ionic 4?

Я пытался добавить различные вещи в мой config.xml, но ничего не работает.

html файл

<ion-header>
  <ion-toolbar>
    <ion-buttons slot="start">
      <ion-back-button defaultHref="/"></ion-back-button>
    </ion-buttons>
    <ion-title>{{information.name}}</ion-title>
  </ion-toolbar>
</ion-header>

<ion-content>
  <iframe name= "eventsPage" [src]="this.mysite" width="100%" height="95%">
  </iframe>
</ion-content>

tsfile

import { Component, OnInit } from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {GetProtocolsService} from '../../services/get-protocols.service';
import { DomSanitizer } from '@angular/platform-browser';

@Component({
  selector: 'app-protocol-details',
  templateUrl: './protocol-details.page.html',
  styleUrls: ['./protocol-details.page.scss'],
})
export class ProtocolDetailsPage implements OnInit {

  information = null;
  protocols = null;

  mysite = null;

  constructor(private activatedRoute: ActivatedRoute, private protocolService: GetProtocolsService, private router: Router,
              private sanitizer: DomSanitizer) { }

  ngOnInit() {
    // Get the ID that was passed with the URL
    let id = this.activatedRoute.snapshot.paramMap.get('id');

    console.log('Details');

    this.protocolService.getProtocols().subscribe(result => {
      console.log('getHospitals1 executed')
      this.protocols = result;
      console.log('result', result);
      this.information = this.filterArr(id)[0];
      console.log('information', this.information);
      this.mysite = this.sanitizer.bypassSecurityTrustResourceUrl('../../../assets/pdf/' + this.information.pdf.toString());
    });
  }

  filterArr(search) {
    // Get the real array forst of all
    let arr = this.protocols;

    return arr.filter(oneObj => oneObj.id.indexOf(search) >= 0);
  }

}

Я бы ожидал, что он отобразит PDF, но вместо этого я получаю пустой экран, когда на самом устройстве Android.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...