public IActionResult GetCharacterSheetById(int id) { try { const string src = @"Assets\InputPdfs\EmptyPassport.pdf"; var des = $@"Assets\OutputPdfs\FilledPassport{id}.pdf"; var oldFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), src); var newFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), des); _pdfService.CreateCharacterSheetById(id, oldFile, newFile); var fileBytes = System.IO.File.ReadAllBytes(newFile); return(File(fileBytes, "application/pdf", "CharacterSheet.pdf")); } catch (Exception e) { return(BadRequest(e.Message)); } }