I wrote Asp.net application in which web browser can download pdf file from a server and open the pdf file in new tab. The program code is ok functionally but the height of the window size of the pdf is very small.
Does enyone have any idea? It would be really helpful if anyone comments on this problem or have any idea........
The code is written below. Asp.Net Controller
[HttpPost]
public IActionResult DownloadPdf(){
var stream = new FileStream( pdfPath, FileMode.Open );
return ControllerBase.File( stream, "application/pdf", pdfName);
}
Asp.Net _Layout.cshtml
<head>
<link rel="stylesheet" href="~/css/common.css" />
.........another codes......
</head>
<body>
<main>@RenderBody()</main>
</body>
Asp.Net DownloadPdf.cshtml
<button id="download">Download</button>
Javascript
$("#downloadPdf").click(function(){
let response = await fetch( DownloadPdf",{
method: "POST",
}
let blob = await response.blob();
let url = (window.URL || window.webkitURL).createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.target = "_blank";
a.rel = "noopener noreferrer";
a.id = 1;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}