public static CustomerDetailsModel GetPDFFromKYCForm(string path) { Stream stream = File.OpenRead(path); List <string> pdf = pdfHandler.GetPdfPagesContent(stream); var details = pdf.FirstOrDefault(); int policyFrom = details.IndexOf("Policy Number: ") + "Policy Number: ".Length; int policyTo = details.IndexOf("\nInsured"); string policyNumber = details.Substring(policyFrom, policyTo - policyFrom); int insuredFrom = details.IndexOf("Insured Name: ") + "Insured Name: ".Length; int insuredTo = details.IndexOf("\nAddress"); string insuredname = details.Substring(insuredFrom, insuredTo - insuredFrom); int addressFrom = details.IndexOf("Address: ") + "Address: ".Length; int addressTo = details.IndexOf("\nPhone"); string address = details.Substring(addressFrom, addressTo - addressFrom); int phoneFrom = details.IndexOf("Phone: ") + "Phone: ".Length; int phoneTo = details.IndexOf("\nEmail"); string phone = details.Substring(phoneFrom, phoneTo - phoneFrom); int emailFrom = details.IndexOf("Email: ") + "Email: ".Length; int emailTo = details.IndexOf("\nRegistration"); string email = details.Substring(emailFrom, emailTo - emailFrom); int registrationFrom = details.IndexOf("Registration Number: ") + "Registration Number: ".Length; int registrationTo = details.IndexOf("\nEngine"); string registrationNumber = details.Substring(registrationFrom, registrationTo - registrationFrom); int engineFrom = details.IndexOf("Engine Number: ") + "Engine Number: ".Length; int engineTo = details.IndexOf("\nChassis"); string engineNumber = details.Substring(engineFrom, engineTo - engineFrom); int chassisFrom = details.IndexOf("Chassis: ") + "Chassis: ".Length; int chassisTo = details.IndexOf("\nMake/Model"); string chassis = details.Substring(chassisFrom, chassisTo - chassisFrom); int makeModelFrom = details.IndexOf("Make/Model: ") + "Make/Model: ".Length; int makeModelTo = details.IndexOf("\nType"); string makeModel = details.Substring(makeModelFrom, makeModelTo - makeModelFrom); int typeOfBodyFrom = details.IndexOf("Type of Body: ") + "Type of Body: ".Length; int typeOfBodyTo = details.IndexOf("\nYear"); string typeOfBody = details.Substring(typeOfBodyFrom, typeOfBodyTo - typeOfBodyFrom); int yearOfManufactureFrom = details.IndexOf("Year of Manufacture: ") + "Year of Manufacture: ".Length; int yearOfManufactureTo = details.IndexOf("\nSeating "); string yearOfManufacture = details.Substring(yearOfManufactureFrom, yearOfManufactureTo - yearOfManufactureFrom); int seatingCapacityFrom = details.IndexOf("Seating Capacity: ") + "Seating Capacity: ".Length; int seatingcapacityTo = details.IndexOf("\nPrevious policy year"); string seatingCapacity = details.Substring(seatingCapacityFrom, seatingcapacityTo - seatingCapacityFrom); int previousPolicyYearFrom = details.IndexOf("Previous policy year: ") + "Previous policy year: ".Length; int previousPolicyYearTo = details.IndexOf("\nPrevious policy company name"); string previousPolicyYear = details.Substring(previousPolicyYearFrom, previousPolicyYearTo - previousPolicyYearFrom); int previousPolicyCompanyNameFrom = details.IndexOf("Previous policy company name: ") + "Previous policy company name: ".Length; int previousPolicyCompanyNameTo = details.IndexOf("\nVehicle Category"); string previousPolicyCompamnyName = details.Substring(previousPolicyCompanyNameFrom, previousPolicyCompanyNameTo - previousPolicyCompanyNameFrom); int vehicleCategoryFrom = details.IndexOf("Vehicle Category: ") + "Vehicle Category: ".Length; int vehicleCategoryTo = details.IndexOf("\nVehicle Sub-Category"); string vehicleCategory = details.Substring(vehicleCategoryFrom, vehicleCategoryTo - vehicleCategoryFrom); int vehicleSubCategoryFrom = details.IndexOf("Vehicle Sub-Category: ") + "Vehicle Sub-Category: ".Length; int vehicleSubCategoryTo = details.IndexOf("\nPrevious Policy RED"); string vehicleSubCategory = details.Substring(vehicleSubCategoryFrom, vehicleSubCategoryTo - vehicleSubCategoryFrom); int previousPolicyREDFrom = details.IndexOf("Previous Policy RED: ") + "Previous Policy RED: ".Length; int previousPolicyREDTo = details.IndexOf("\nSalutation"); string previousPolicyRED = details.Substring(previousPolicyREDFrom, previousPolicyREDTo - previousPolicyREDFrom); int hypothecationFrom = details.IndexOf("Salutation: ") + "Salutation: ".Length; int hypothecationTo = details.IndexOf("\nHypothecation"); string hypothecation = details.Substring(hypothecationFrom, hypothecationTo - hypothecationFrom); int rtoFrom = details.IndexOf("Hypothecation: ") + "Hypothecation: ".Length; int rtoTo = details.IndexOf("\nRTO"); string rto = details.Substring(rtoFrom, rtoTo - rtoFrom); int NCB_NCDFrom = details.IndexOf("RTO: ") + "RTO: ".Length; int NCB_NCDTo = details.IndexOf("\nNCB/NCD"); string ncb_ncd = details.Substring(NCB_NCDFrom, NCB_NCDTo - NCB_NCDFrom); CustomerDetailsModel cModel = new CustomerDetailsModel(); cModel.PolicyNumber = policyNumber; cModel.InsuredName = insuredname; cModel.Address = address; cModel.Phone = phone; cModel.Email = email; cModel.RegistrationNumber = registrationNumber; cModel.EngineNumber = engineNumber; cModel.Chassis = chassis; cModel.Make_Model = makeModel; cModel.TypeOfBody = typeOfBody; cModel.YearOfManufacture = yearOfManufacture; cModel.SeatingCapacity = seatingCapacity; cModel.PreviousPolicyYear = previousPolicyYear; cModel.PreviousPolicyCompanyName = previousPolicyCompamnyName; cModel.VehicleCategory = vehicleCategory; cModel.VehicleSubCategory = vehicleSubCategory; cModel.PreviousPolicyRED = previousPolicyRED; cModel.Hypothecation = hypothecation; cModel.RTO = rto; cModel.NCB = ncb_ncd; return(cModel); }