- I'm fetching my all data from controller's Action Method(GetSelectedTemplate) to the view(GetSelectedTemplate.cshtml).and try to download the Resume Template when click on the Resume Button.2.In my view i applied the Resume Template and fetch all data inside that template. now i want to download the template with same design.(Like we fill all details in Resume and click on download button we able to see the Pdf in same design as resume template)
- I use "iTextSharp" Nuget package to download the pdf file but not able download it.
Here is controller code: (for controller code i compare different templates.Just cinsidered the "Resume_Template_1")
[HttpGet] public async Task<ActionResult> GetSelectedTemplate(int TempId) { JobSeeker objJ = new JobSeeker(); BALJobSeeker objBAL = new BALJobSeeker(); List<JobSeeker> jobSeekers = new List<JobSeeker>(); objJ.TemplateId = TempId; SqlDataReader dr = await objBAL.TemplateNameDetails(objJ); // Retrieve ViewBag data from the first action method ViewBag.BasicList = TempData["BasicList"]; ViewBag.QualificationList = TempData["QualificationList"]; ViewBag.EmployementList = TempData["EmployementList"]; ViewBag.ProjectList = TempData["ProjectList"]; ViewBag.CertificationList = TempData["CertificationList"]; ViewBag.ObjectiveBag = TempData["ObjectiveBag"]; ViewBag.SkillsExperienceList = TempData["SkillsExperienceList"]; if (await dr.ReadAsync()) { string templateName = dr["TemplateName"].ToString(); if (templateName == "Resume_Template_1") { return View("GetSelectedTemplate"); } else if (templateName == "Resume_Template_3") { return View("GetSelectedTemplate2"); } else { return HttpNotFound(); } } return View(); }
View Code: (GetSelectedTemplate.cshtml -> where i fetch all my controller data and all template code.)
<!DOCTYPE html><html lang="en"><head><title>Pillar - Bootstrap Resume/CV Template for Developers</title><!-- Meta --><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="description" content="Responsive Resume Template"><meta name="author" content="Xiaoying Riley at 3rd Wave Media"><link rel="shortcut icon" href="favicon.ico"></head><body><article class="resume-wrapper text-center position-relative"><div class="resume-wrapper-inner mx-auto text-start bg-white shadow-lg"><header class="resume-header pt-4 pt-md-0"><div class="row"> @foreach (var jobSeeker in ViewBag.BasicList) {<div class="col-block col-md-auto resume-picture-holder text-center text-md-start"><img src="@jobSeeker.Photo" alt="Image" /></div><!--//col--><div class="col"><div class="row p-4 justify-content-center justify-content-md-between"><div class="primary-info col-auto"><h1 class="name mt-0 mb-1 text-white text-uppercase text-uppercase">@jobSeeker.FullName</h1> @*<div class="title mb-3">Full Stack Developer</div>*@<ul class="list-unstyled"><li><a class="text-link" href="#"><i class="fas fa-map-marker-alt fa-fw"></i> @jobSeeker.Address</a></li><li class="mb-2"><a class="text-link" href="#"><i class="far fa-envelope fa-fw me-2" data-fa-transform="grow-3"></i>@jobSeeker.EmailId</a></li><li><a class="text-link" href="#"><i class="fas fa-mobile-alt fa-fw me-2" data-fa-transform="grow-6"></i>@jobSeeker.MobileNo</a></li></ul></div><!--//primary-info--><div class="secondary-info col-auto mt-2"><ul class="resume-social list-unstyled"><li class="mb-3"><a class="text-link" href="#"><span class="fa-container text-center me-2"><i class="fab fa-linkedin-in fa-fw"></i></span>@jobSeeker.ProfileUrl</a></li><li class="mb-3"><a class="text-link" href="#"><span class="fa-container text-center me-2"><i class="fas fa-user fa-fw"></i></span>@jobSeeker.Gender</a></li><li><a class="text-link" href="#"><span class="fa-container text-center me-2"><i class="fas fa-globe"></i></span>yourwebsite.com</a></li></ul></div><!--//secondary-info--></div><!--//row--></div><!--//col--> }</div><!--//row--></header><div class="resume-body p-5"><section class="resume-section summary-section mb-5"><h2 class="resume-section-title text-uppercase font-weight-bold pb-3 mb-3">Career Summary</h2><div class="resume-section-content"><p class="mb-0"> @ViewBag.ObjectiveBag<a class="text-reset text-link" href="https://themes.3rdwavemedia.com/resources/sketch-template/pillar-sketch-sketch-resume-template-for-developers/" target="_blank"></a></p></div></section><!--//summary-section--><div class="row"> @foreach (var jobSeeker in ViewBag.EmployementList) {<div class="col-lg-9"><section class="resume-section experience-section mb-5"><h2 class="resume-section-title text-uppercase font-weight-bold pb-3 mb-3">Work Experience</h2><div class="resume-section-content"><div class="resume-timeline position-relative"><article class="resume-timeline-item position-relative pb-5"><div class="resume-timeline-item-header mb-2"><div class="d-flex flex-column flex-md-row"><h3 class="resume-position-title font-weight-bold mb-1">@jobSeeker.Designation</h3><div class="resume-company-name ms-auto">@jobSeeker.OrganizationName</div></div><!--//row--><div class="resume-position-time">@jobSeeker.StartDate - @jobSeeker.EndDate</div></div><!--//resume-timeline-item-header--><div class="resume-timeline-item-desc"><p>@jobSeeker.JobResponsibilities</p><h4 class="resume-timeline-item-desc-heading font-weight-bold">Total Experience:</h4><p>@jobSeeker.TotalExperience</p><h4 class="resume-timeline-item-desc-heading font-weight-bold">Technologies used:</h4><ul class="list-inline"><li class="list-inline-item"><span class="badge bg-secondary badge-pill"> @foreach (var skill in jobSeeker.Skills.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { @skill.Trim(); }</span></li></ul></div><!--//resume-timeline-item-desc--></article><!--//resume-timeline-item--></div><!--//resume-timeline--></div></section><!--//experience-section--><section class="resume-section experience-section mb-5"><h2 class="resume-section-title text-uppercase font-weight-bold pb-3 mb-3">Projects </h2> @foreach (var JobSeekers in ViewBag.ProjectList) {<div class="resume-section-content"><div class="resume-timeline position-relative"><article class="resume-timeline-item position-relative pb-5"><div class="resume-timeline-item-header mb-2"><div class="d-flex flex-column flex-md-row"><h3 class="resume-position-title font-weight-bold mb-1">@JobSeekers.ProjectTitle</h3><div class="resume-company-name ms-auto">@JobSeekers.Client</div></div><!--//row--><div class="resume-position-time">@JobSeekers.StartDate - @JobSeekers.EndDate</div></div><!--//resume-timeline-item-header--><div class="resume-timeline-item-desc"><p>@JobSeekers.ProjectResponsibilities</p><h4 class="resume-timeline-item-desc-heading font-weight-bold">Project Status:@JobSeekers.Status</h4><h4 class="resume-timeline-item-desc-heading font-weight-bold">Technologies used:</h4><ul class="list-inline"> @foreach (var skill in JobSeekers.Skills.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) {<li class="list-inline-item"><span class="badge bg-secondary badge-pill">@skill.Trim()</span></li> }</ul></div><!--//resume-timeline-item-desc--></article><!--//resume-timeline-item--></div><!--//resume-timeline--></div> }</section><!--//experience-section--></div> }<div class="col-lg-3"><section class="resume-section skills-section mb-5"><h2 class="resume-section-title text-uppercase font-weight-bold pb-3 mb-3">Skills</h2> @foreach (var jobSeeker in ViewBag.SkillsExperienceList) {<div class="resume-section-content"><div class="resume-skill-item"><ul class="list-unstyled mb-4"><li class="mb-2"><div class="resume-skill-name"> @foreach (var skill in jobSeeker.ExperiencedSkills.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { @skill.Trim(); }</div><div class="progress resume-progress"> @{ int progressWidth; switch (jobSeeker.Ratings.ToLower()) { case "low": progressWidth = 20; break; case "better": progressWidth = 40; break; case "average": progressWidth = 60; break; case "good": progressWidth = 80; break; case "excellent": progressWidth = 100; break; default: progressWidth = 0; break; } }<div class="progress-bar theme-progress-bar-dark" role="progressbar" style="width: @progressWidth%" aria-valuenow="@progressWidth" aria-valuemin="0" aria-valuemax="100"></div></div></li></ul></div><!--//resume-skill-item--></div> }</section><!--//skills-section--><section class="resume-section education-section mb-5"><h2 class="resume-section-title text-uppercase font-weight-bold pb-3 mb-3">Education</h2> @foreach (var jobSeeker in ViewBag.QualificationList) {<div class="resume-section-content"><ul class="list-unstyled"><li class="mb-2"><div class="resume-degree font-weight-bold">@jobSeeker.EducationName: @jobSeeker.DegreeName @jobSeeker.Specialization</div><div class="resume-degree-org">@jobSeeker.UniversityName</div><div class="resume-degree-org">Grade: @jobSeeker.Grade</div><div class="resume-degree-time">@jobSeeker.StartYear - @jobSeeker.EndYear</div></li></ul></div> }</section><!--//education-section--><section class="resume-section reference-section mb-5"><h2 class="resume-section-title text-uppercase font-weight-bold pb-3 mb-3">Certifications</h2> @foreach (var jobSeeker in ViewBag.CertificationList) {<div class="resume-section-content"><ul class="list-unstyled resume-awards-list"><li class="mb-0 ps-4 position-relative"><i class="resume-award-icon fas fa-trophy position-absolute" data-fa-transform="shrink-2"></i><div class="resume-award-name">@jobSeeker.CertificationName</div><div class="resume-degree-time">Issuing Date:@jobSeeker.StartDate</div><div class="resume-award-desc">Issuing Authority:@jobSeeker.IssuingAuthority</div></li></ul></div> }</section><!--//interests-section--><section class="resume-section skills-section mb-5"><h2 class="resume-section-title text-uppercase font-weight-bold pb-3 mb-3">Languages</h2> @foreach (var jobSeeker in ViewBag.BasicList) {<div class="resume-section-content"><div class="resume-skill-item"><ul class="list-unstyled mb-4"> @foreach (var lang in jobSeeker.Languages.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) {<li class="list-inline-item"><span class="badge bg-secondary badge-pill">@lang.Trim()</span></li> }</ul></div></div> }</section><!--//language-section--></div></div><!--//row--></div><!--//resume-body--></div></article><button id="downloadPDF">Download PDF</button></body></html>