Всякий раз, когда я нажимаю кнопку печати, открывается новое окно предварительного просмотра, но тогда объявления DFP и DFA не показываются. Они показывались в превью.
На самом деле нужны изображения DFA и DFP при предварительном просмотре.
export class PrintComponent implements OnInit {
adId = 'div-gpt-ad-1537454036303-0';
ngAfterViewInit() {
let tag = window['googletag'];
tag = window['googletag'] || { cmd: [] };
tag.cmd.push( () => {
googletag.defineSlot('/68280123/MWEB_MRP',[[970, 90]],this.adId)
.setTargeting('Status', ['CNF'])
.setTargeting('Designation', [Designation])
.setCollapseEmptyDiv(true)
.addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.pubads().collapseEmptyDivs();
googletag.enableServices();
googletag.display(this.adId);
});
}
printDfa() {
let printContents: any, popupWin: any;
document.getElementById('Msg').style.fontSize = '13px';
document.getElementById('msgId').style.fontSize = '13px';
document.getElementById('DfaAdID').style.display = 'block';
printContents = document.getElementById('print-dfa').innerHTML;
popupWin = window.open('', '_blank',
'top=0,left=0,width=1000,height=900');
popupWin.document.open();
popupWin.document.write(`
<html>
<body onload="window.print()">${printContents}</body>
</html>`
);
popupWin.document.close();
document.getElementById('DfaAdID').style.display = 'block';
}