I am using c# to create a pdf file and then the file is sent via response. The file seems to be created totally fine because the swagger shows the download link. Below is the controller code where a pdf file is created and then returned:
[HttpGet("generatepdf")]
public async Task<IActionResult> GeneratePDF(string AccountId, [FromQuery] InvoiceRequestDto model)
{
var document = new PdfDocument();
var rv = await service.GetAccountInvoices(model);
string htmloutput = string.Empty;
htmloutput = "<table>";
htmloutput += "<thead><tr><th>Invoice Id</th><th>Invoice Date</th><th>Invoice Due Date</th><th>Fee Type</th><th>Fee</th><th>Amount Outstanding</th><th>Status</th></tr></thead>";
htmloutput += "<tbody>";
foreach (var item in rv.Items)
{
htmloutput += "<tr><td>" + item.Id + "</td><td>" + item.Date + "</td><td>" + item.PaymentDueDate + "</td><td>" + item.AmountOutstanding + "</td><td>" + item.StatusName + "</td>";
}
htmloutput += "</tbody></table>";
string HtmlContent = htmloutput;
PdfGenerator.AddPdfPages(document, HtmlContent, PageSize.A4);
byte[]? response = null;
using (MemoryStream ms = new MemoryStream())
{
document.Save(ms);
response = ms.ToArray();
}
string Filename = "Invoice.pdf";
return File(response, "application/pdf", Filename);
}
And here is the service code at the angular end:
async getPdfList(params: any) {
return await this.ws.get(`${this.billingApiUrl}/invoice/generatepdf`,params).toPromise();
}
However, I am unable to download the pdf file from the angular js. It is throwing an error as follow:
And here is the response that I get in the network:
Any help would be more than appreciated.


You can force browser to download this file if you have file content in your response.please read the answer with this line in the above link..