Yckeb
Yckeb

Reputation: 84

Print data in Angular2

I want to print some data that I have in a variable. The code I have is:

    public printData(data) {
      let printContents, popupWin;
      printContents = data;
      popupWin = window.open('', '_blank','resizable=yes,top=0,left=0,height=100%,width=auto');
      popupWin.document.write(`
        <html>
          <head>
            <title>Print</title>
          </head>
          <body onload="window.print();window.close()">${printContents}</body>
          </html>`
      );
    popupWin.document.close();
}

It works fine but i get something like this:

enter image description here

and i don't want the want the window behind the printer options. I want to show the user only:

enter image description here

Is there any way to do this?

Thank you in advance.

Upvotes: 0

Views: 900

Answers (1)

Dresoy Ravelo
Dresoy Ravelo

Reputation: 36

You could use a IFrame, remember not to use window.open in this case...

Upvotes: 1

Related Questions