/// <summary> /// Created By : Ashwajit Bansod /// Created Date : 12-April-2019 /// Created For : to save pdf form details. /// </summary> /// <param name="obj"></param> /// <returns></returns> public bool SavePDFData(PDFSaveModel obj) { var objModel = new PDFSaveModel(); bool isSaved = false; try { if (obj != null) { string Action = "I"; var saveData = _workorderems.spSeteformTrack(Action, null, obj.ModuleId, obj.FormId, obj.LocationId, obj.UserId, null, obj.FileName, null, "Y"); isSaved = true; } else { isSaved = false; } } catch (Exception ex) { } return(isSaved); }
public ActionResult Index(CharitableContributionForm obj) { eTracLoginModel ObjLoginModel = null; long UserId = 0; long LocationId = 0; var objModel = new PDFSaveModel(); if (Session != null && Session["eTrac"] != null) { ObjLoginModel = (eTracLoginModel)(Session["eTrac"]); if (LocationId > 0) { LocationId = ObjLoginModel.LocationID; } } try { string pdfTemplate = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings["PDFPath"]), "Content/PDFForms/CharitableContributionRequestForm.pdf"); string FileName = ObjLoginModel.UserId + "_" + DateTime.Now.Ticks.ToString() + "_" + Convert.ToString("CharitableContributionRequestForm"); obj.FileName = FileName; ViewBag.FileName = FileName; var newFile = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings["PDFForm"]), "PDFFormAfterFilling/" + FileName + ".pdf"); //@"D:\Project\eTrac\WorkOrderEMS\Content\PDFForms\PDFFormAfterFilling\" + FileName + ".pdf"; PdfReader pdfReader = new PdfReader(pdfTemplate); PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream( newFile, FileMode.Create)); AcroFields pdfFormFields = pdfStamper.AcroFields; objModel.UserId = ObjLoginModel.UserId; objModel.LocationId = ObjLoginModel.LocationID; objModel.FileName = FileName; var savePDF = _IMainPDFFormManager.SavePDFData(objModel); // set form pdfFormFields // The first worksheet and W-4 form //pdfFormFields.SetFieldProperty("names", "textsize", 4f, null); pdfFormFields.SetField("Services of America Inc accounting department accountseliteparkingofamericacom Please write", obj.NonProfitOrganization); pdfFormFields.SetField("Name of nonprofit organization", obj.MailingAddress); pdfFormFields.SetField("undefined", obj.ContactPerson); pdfFormFields.SetField("Contact person", obj.PhoneNumber); pdfFormFields.SetField("Phone number", obj.NameOfEvent); pdfFormFields.SetField("Name of event", obj.DateOfEvent); pdfFormFields.SetField("Date of event", obj.DateOfEvent); pdfFormFields.SetField("Federal Tax ID", obj.FederalTaxID); pdfFormFields.SetField("Contribution requested eg funds food services", obj.ContributionRequested); pdfFormFields.SetField("Estimated number of attendees at event or people receiving donation", obj.EstimatedNumberOfAttendees); pdfFormFields.SetField("malefemale age special interests sports education child welfare etc 1", obj.DescribeTheDemographic); pdfFormFields.SetField("malefemale age special interests sports education child welfare etc 2", obj.DescribeTheDemographic1); pdfFormFields.SetField("press releases interviews 1", obj.publicityIsPlanned); pdfFormFields.SetField("press releases interviews 2", obj.publicityIsPlanned1); pdfFormFields.SetField("What opportunities will be available to display the Elite Parking Services logo 1", obj.opportunitiesDescription); pdfFormFields.SetField("What opportunities will be available to display the Elite Parking Services logo 2", obj.opportunitiesDescription1); // report by reading values from completed PDF string sTmp = "Charitable Contribution Request Form Completed for " + pdfFormFields.GetField("Services of America Inc accounting department accountseliteparkingofamericacom Please write") + " " + pdfFormFields.GetField("Mailing address"); //MessageBox.Show(sTmp, "Finished"); // flatten the form to remove editting options, set it to false // to leave the form open to subsequent manual edits pdfStamper.FormFlattening = false; // close the pdf //foreach (System.Collections.DictionaryEntry de in pdfReader.AcroFields.Fields) //{ // pdfFormFields.SetFieldProperty(de.Key.ToString(), // "setfflags", // PdfFormField.FF_READ_ONLY, // null); //} //pdfStamper.AcroFields.SetFieldProperty(); //pdfFormFields.GetField(pdfDoc, true).FlattenFields(); pdfStamper.Close(); } catch (Exception ex) { ViewBag.Message = ex.Message; ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger; } var objData = new CharitableContributionForm(); return(View("PDFView")); }