求解:载入 PDF 时发生错误。 PDF.js v2.3.200 (build: 4ae3f9fc) 信息:Failed to fetch

论坛 期权论坛 期权     
匿名技术用户   2021-1-10 19:14   14101   0

采用的是http://blog.lookpeakfans.xyz/2018/07/22/preview-pdf/这篇文章中的第二种方案:

求解:载入 PDF 时发生错误。 PDF.js v2.3.200 (build: 4ae3f9fc) 信息:Failed to fetch

没找到以上的解决方案。。。

换了一种方案,我把核心代码列出来如下:(我的是从上个页面带过来的pdfUrl,在子页面直接预览的)

html文件中:

    <ng-container app-slot-content-box>
        <section class="pdf-content" id="pdf-content">
              <iframe [src]="pdfUrl" width='100%' height='100%' frameborder='1' ></iframe>
        </section>
    </ng-container>

ts文件:


import { DomSanitizer } from '@angular/platform-browser';
。
。
。
pdfUrl;
constructor(
     public sanitizer: DomSanitizer
) {
  activatedRoute.queryParams.subscribe(queryParams => {
      if (queryParams && queryParams.pdfPath) {
           this.pdfUrl = this.sanitizer.bypassSecurityTrustResourceUrl(queryParams.pdfPath);
      } else {
           this.pdfUrl = '';
      }
    });
}

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP