0

I need some help, I dont have any idea how to convert blob to pdf and show it in iframe I got this response from BackEnd (not copy all)

PK

! Gæ2[Content_Types].xml´Ko!÷úFl+§ªª<΢©6RS©[wlá!¸Nâß;O5éÈLk³i¸s>X_?ºxµ³%»Z®XV:¥í®d?o¿,Þ³"¢°JÔÎBÉÙõæõ«õíÑC,HmcÉöþçQîÁ¸t,U*@z ;î¼;àoW«w\:qÛ¬?A%5¨¹#!9+>vý¨ ïk-R7U>©»ó°{!Ô¦ nÓo§%Mû´"@Oà=Xõbýø¤lûĽöñM?ï´A+(nDÀoÂtAqåäÁPÄòôtL乪ÒF}ãæ#­¬©cÅmOqÈCDg~ksWgã¦Ô{0[DùÉ­5ÄËt¾éx@$AÞ9ðÛÙ(þ0OTΡuc5Fë$XapN"HgólvT ò¡ I¤=áüê/ÎxÖ×%¿3Oyb[CÞ: áÁùo2é6ÝóühmNERÏöt¤¿!üÇB£^øYÇâHÖgú?ë_³»£üB7áÏ6¯*ãÖGæoo¼ßÿÿPK !¿@ar_rels/.rels¬ÛJÄ0ïß!ä~îz@dÓ½aïDêÉ´6©î¾½qµ°Ô{>¾Éz³³={Ãw/3tÊkãZÉêûÅ gÀiè½CÉ÷ø¦:?[?bRgBbâäQ¸"©-¤Ât¹Óøhò1¶"zŪ,¯EüÍàÕɶZò¸ÕÕûÿcò!æéH&ßÕ[$ɵW¹"¹8.tyºo£ðΫÁ¢£c^¸#tõ´0et5§yûÇ)¥åJãÄÏ»Zè¯òÍjÞ7DÝ`þÈj¾{ÅKÀöSH~JõÿÿPK !

all i have tried is use

this._endpointService.getData('/myGet')
           .then((res:any) => {
            let blob = new Blob([res.error.text], { type: 'application/pdf' })
            var fileURL = URL.createObjectURL(blob);

            this.tryDoctype = blob
})

then i dont know what's next i must do.

yudistira nugraha
  • 173
  • 2
  • 4
  • 13

1 Answers1

1

Please try below:

//import this ref
this._endpointService.getData('/myGet')
           .then((res:any) => {
    //change in response
    let blob = new Blob([res.error.text.blob()], { type: 'application/pdf' })
    let fileURL = URL.createObjectURL(blob);

    //if you have any error then try this
    //this.tryDoctype = this.sanitizer.bypassSecurityTrustResourceUrl(fileURL);

    this.tryDoctype = fileURL;
})

Assign fileURL to Iframe

  <iframe *ngIf="tryDoctype" [src]="tryDoctype" width="950" height="600"></iframe>
Ron Rebennack
  • 2,666
  • 1
  • 22
  • 17
Niraj
  • 775
  • 7
  • 20