简体   繁体   中英

Diplay blob as pdf in popup/dialog html, typescript

I am working on typescript and html to show the result of webservice call as pdf in popup/dialog in same page.

I can open this pdf in a new tab with window.open(url) method. I am facing challenges to display the same in popup.

Your help is appreciated.

The code to display in new window:

     this.http.post(pdfServiceUrl, body)
      .subscribe(pdfData => {            
        var pdfResult = pdfData['_body'];
        var blob = new Blob([pdfResult], {type: 'application/pdf'});
        fileURL = URL.createObjectURL(blob);
        var pdfWindow = window.open(fileURL, );
      });

HTML code for dialog:

<dialog id="favDialog">
    <div>
      <h4 style=" align-content: center;"> PDF Data </h4>
    </div>     
    <div id="results"></div>
    <menu>
      <button class="button"  id="cancel" type="reset">OK</button>
    </menu>
  </dialog>

Corresponding ts code I tried to display in dialog:

var favDialog = <any>document.getElementById('favDialog');
favDialog.fileURL= fileURL;
favDialog.showModal();

This displays only "PDF Data" and a "ok" button in popup.

Apologies for the formatting as javascript for posting the question is blocked with error: "Stack Overflow requires external JavaScript from another domain, which is blocked or failed to load."

您可以使用对我也非常有用的标签。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM