Beispiel #1
0
        private IActionResult GenerateFileAction(long id, bool includeFileName)
        {
            IDictionary <string, string> placeholderValues = HttpContext.Request.Query.ToDictionary(kv => kv.Key, kv => kv.Value.ToString());
            string templateContent = mTemplateService.GetTemplateContent(id);

            string filePath = mTemplateProcessor.TransformToPdf(templateContent, placeholderValues);

            byte[] fileContent = System.IO.File.ReadAllBytes(filePath);

            string fileDownloadName = includeFileName ? System.IO.Path.GetFileName(filePath) : null;

            return(File(fileContent, "application/pdf", fileDownloadName));
        }