Ejemplo n.º 1
0
        public async Task <IActionResult> ExportAsPdf()
        {
            var products = await _dispatcher.DispatchAsync(new GetProductsQuery());

            var model = products.ToModels();

            var template = Path.Combine(Environment.CurrentDirectory, $"Templates/ProductList.cshtml");
            var html     = await _htmlGenerator.GenerateAsync(template, model);

            var pdf = await _pdfConverter.ConvertAsync(html);

            return(File(pdf, MediaTypeNames.Application.Octet, "Products.pdf"));
        }