Here is the code snippet for downloading the page directly:
downloadPage(cmpName) {
let downloadContents = document.getElementById(cmpName).innerHTML;
let originalContents = document.body.innerHTML;
document.body.innerHTML = downloadContents;
// Add code here to trigger direct download instead of window.print()
document.body.innerHTML = originalContents;}
The current function works fine but there is an intermediate step involved. The project needs a direct download feature.