コード例 #1
0
ファイル: PdfHelper.cs プロジェクト: amolaher67/pdfformDemo
 public static List <PdfFormfields> GetTemplatefields(InitialLoadModel model)
 {
     return(new List <PdfFormfields>()
     {
         new PdfFormfields()
         {
             Key = "txt_Initial", Value = model.Initials
         },
         new PdfFormfields()
         {
             Key = "txt_Surname", Value = model.Surname
         },
         new PdfFormfields()
         {
             Key = "txt_SouthAfricanID", Value = model.IDNumber
         },
         new PdfFormfields()
         {
             Key = "txt_EmailAddres", Value = model.EmailAddress
         },
         new PdfFormfields()
         {
             Key = "txt_ContactNumber", Value = model.ContactNumber
         },
         new PdfFormfields()
         {
             Key = "txt_grossMonthlyIncome", Value = model.GrossMonthlyIncome
         },
         new PdfFormfields()
         {
             Key = "rb_LegalQuestion.1", Value = model.ApplicantCreditEvaluation11?.ToString()
         },
         new PdfFormfields()
         {
             Key = "rb_LegalQuestion.2", Value = model.ApplicantCreditEvaluation2?.ToString()
         },
         new PdfFormfields()
         {
             Key = "rb_LegalQuestion.3", Value = model.ApplicantCreditEvaluation3?.ToString()
         },
         new PdfFormfields()
         {
             Key = "rb_LegalQuestion.4", Value = model.ApplicantCreditEvaluation5?.ToString()
         },
     });
 }
コード例 #2
0
        public async Task <IActionResult> PdfGenerator(InitialLoadModel model)
        {
            var list = PdfHelper.GetTemplatefields(model);

            var path = PdfHelper.GeneratePdfFromExisingValues(list);

            if (path == null)
            {
                return(Content("filename not present"));
            }

            var memory = new MemoryStream();

            using (var stream = new FileStream(path, FileMode.Open))
            {
                await stream.CopyToAsync(memory);
            }
            memory.Position = 0;
            return(File(memory, GetContentType(path), Path.GetFileName(path)));
        }
コード例 #3
0
        public IActionResult PdfGenerator()
        {
            var model = new InitialLoadModel();

            return(View(model));
        }