首页 > 解决方案 > Can't open PDF in Angular application

问题描述

I'm trying to open a PDF that I download via an API.

The API response looks like this:

enter image description here

This is my Angular print function:

print() {
  this.userService.print(this.route.parent.snapshot.paramMap.get('id'))
    .pipe(first())
    .subscribe(

      (result: any) => {
        var fileURL = URL.createObjectURL(new Blob([result], { type: "application/pdf" }));
        window.open(fileURL); 
      });

On the client side a new tab opens up with an error 'Failed to load PDF document"

标签: angular

解决方案


推荐阅读