I need to return a pdf and download it on the machine. But when you return the pdf, Blob does not recognize it.
$http.post($rootScope.raiz_ws + "/pdf/PdfCompraVenda", listProdutos)
.then(function (response) {
console.log(response);
var file = new Blob([response], {type: 'application/pdf'});
saveAs(blob, "RelatórioCompraVenda.pdf");
});
[HttpPost]
[Route("PdfCompraVenda")]
public HttpResponseMessage Gerar(PdfLista listProdutos)
{
// criação do pdf no caminho
// retorno abaixo
var path = @"C:\ERNetwork\ERNAdm\Relatorios\RelatórioCompraVenda.pdf";
HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
var stream = new FileStream(path, FileMode.Open);
result.Content = new StreamContent(stream);
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
//result.Content.Headers.ContentDisposition.FileName = Path.GetFileName(path);
result.Content.Headers.ContentDisposition.FileName = Path.GetFileName(path);
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
return result;
}