无法在Chrome上打开base64 pdf

时间:2019-01-14 11:26:23

标签: angular pdf view base64

我在打开/查看crhome和MS Edge上的base64 pdf文档时遇到问题。 它在Firefox上运行良好。 我正在使用angular 7,并且从DB MySql获得了pdf作为base64字符串。

这是角度代码:

@Component({
  selector: 'app-show-doc',
  templateUrl: './show-doc.component.html',
  styleUrls: ['./show-doc.component.css']
})
export class ShowDocComponent {
  lead: number;
  linha: number;
  fxNome: string;
  imagePath: Url = null;
  private data: any;
  private fileName: string;
  constructor(private dataService: DataService,
               private route: ActivatedRoute,
               private _sanitizer: DomSanitizer ) {

    this.route.paramMap.subscribe(
      param => {
        this.lead = +param.get('lead');
        this.linha = +param.get('linha');
        this.dataService.getData('doc/' + this.lead + '/' + this.linha).subscribe(
          (resp: any) => {
            const document = resp.json()[0];
            this.fxNome = document.nomedoc;
            this.imagePath = this._sanitizer.bypassSecurityTrustResourceUrl('data:application/pdf;base64,' + document.fx64);
          }
        );
      }
    );
}

}

并在html中:  <object [data]="imagePath" style="width:1100px;height:800px;"></object>

0 个答案:

没有答案