protected void btnGeneratePDF_Click(object sender, EventArgs e) { var pdfPath = Path.Combine(Server.MapPath("~/Templates/Test.pdf")); var pdfFormField = AssociatesType.GetFormFieldNames(pdfPath); //TextBoxes pdfFormField["Given Name Text Box"] = txtGName.Text; pdfFormField["Family Name Text Box"] = txtFName.Text; pdfFormField["Address 1 Text Box"] = txtAdd1.Text; pdfFormField["Address 2 Text Box"] = txtAdd2.Text; pdfFormField["House nr Text Box"] = txtHouseNo.Text; pdfFormField["City Text Box"] = txtCity.Text; pdfFormField["Height Formatted Field"] = txtHeight.Text; pdfFormField["Postcode Text Box"] = txtPostcode.Text; // check box pdfFormField["Language 4 Check Box"] = ChkList.SelectedValue; pdfFormField["Driving License Check Box"] = ChbDL.Checked.ToString(); // dropdown List pdfFormField["Country Combo Box"] = ddlCountry.SelectedValue; pdfFormField["Gender List Box"] = ddlGender.SelectedValue; pdfFormField["Favourite Colour List Box"] = ddlColor.SelectedValue; var pdfContents = AssociatesType.GeneratePDF(pdfPath, pdfFormField); AssociatesType.ReturnPDF(pdfContents, "Completed-Test.pdf"); }
protected void btnShowField_Click(object sender, EventArgs e) { var pdfPath = Path.Combine(Server.MapPath("~/Templates"), ddlPDFs.SelectedValue); var fieldInfo = new List <string>(); var reader = new PdfReader(pdfPath); var formFields = reader.AcroFields; foreach (DictionaryEntry entry in formFields.Fields) { var formFieldType = FieldsType.GetType(formFields.GetFieldType(entry.Key.ToString())); if (formFieldType is CheckBoxesType) { fieldInfo.Add(string.Format("{0} - {1} - Export Value; {2}", entry.Key, formFieldType, AssociatesType.GetExportValue(entry.Value as AcroFields.Item))); } else { fieldInfo.Add(string.Format("{0} - {1}", entry.Key, formFieldType)); } } reader.Close(); blFields.DataSource = fieldInfo; blFields.DataBind(); }
protected void btnGenerate_Click(object sender, EventArgs e) { var pdfPath = Path.Combine(Server.MapPath("~/Forms"), ddlPDFs.SelectedValue); var formFieldMap = AssociatesType.GetFormFieldNames(pdfPath); var count = 1; foreach (var key in new List <string>(formFieldMap.Keys)) { formFieldMap[key] = count.ToString(); count++; } var pdfContents = AssociatesType.GeneratePDF(pdfPath, formFieldMap); AssociatesType.ReturnPDF(pdfContents, ddlPDFs.SelectedValue + "-Sample.pdf"); }