I've been attempting to download a webpage directly using window.print() but it seems to skip the print window part. It does open the desired url, but refuse to load on the pdf print window and immediately closes the print window. Here's my code:
const onPrint = () => {
const url = "https://www.google.com";
window.open(url)?.print();
}
<a onClick={() => onPrint()}>Click me to download</a>
I also tried to use iframe but it says "google.com refused to connect", I'm aware that sites like Google, Yahoo, etc. won't allow iframes. I'm thinking of auto start download as it get to the external webpage but I'm not sure what should I do..
P/S: I'm using Reactjs to develop my webapp.