ngx-print
ngx-print copied to clipboard
Replace about:blank with hostname in footer on chrome
I need pages number in the printed document. One way to do it is to print with Headers and footers
(an option to enable in the print dialog of Chrome and Firefox).
But this option also prints the URL (in this case, it is a popup with about:blank
). I found a way to replace it with the hostname of the page from which the popup is called, but it doesn't work on Firefox (about:blank
is not replaced by the hostname). This solution is not perfect, but it is better than about:blank
for Chrome.
Here is a snippet that replaces about:blank
with the hostname for chrome:
const popupWin = window.open(window.location.host, "", "top=0,left=0,height=auto,width=auto");
popupWin.document.open();
popupWin.document.write(`...`);
popupWin.document.close();
popupWin.history.replaceState({}, "", "/");
Would you accept a PR for this, even if it only works on Chrome ?