private void button1_Click(object sender, EventArgs e) { //Load a pdf document string input = @"..\..\..\..\..\..\Data\DeleteFormField.pdf"; PdfDocument doc = new PdfDocument(); doc.LoadFromFile(input); //Get pdf forms PdfFormWidget formWidget = doc.Form as PdfFormWidget; //Find the particular form field and delete it for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++) { PdfField field = formWidget.FieldsWidget.List[i] as PdfField; if (field is PdfTextBoxFieldWidget) { PdfTextBoxFieldWidget textbox = field as PdfTextBoxFieldWidget; if (textbox.Name == "password2") { formWidget.FieldsWidget.Remove(textbox); } } } string output = "DeleteFormField.pdf"; //Save the pdf document doc.SaveToFile(output); //Launch the file PDFDocumentViewer(output); }
private void button1_Click(object sender, EventArgs e) { //pdf file string input = "..\\..\\..\\..\\..\\..\\..\\Data\\FormField.pdf"; //open pdf document PdfDocument doc = new PdfDocument(input); //get pdf form PdfFormWidget formWidget = doc.Form as PdfFormWidget; //find the particular form field and delete it for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++) { PdfField field = formWidget.FieldsWidget.List[i] as PdfField; if (field is PdfTextBoxFieldWidget) { PdfTextBoxFieldWidget textbox = field as PdfTextBoxFieldWidget; if (textbox.Name == "password2") { formWidget.FieldsWidget.Remove(textbox); } } } string output = "DeleteFormField.pdf"; //save pdf document doc.SaveToFile(output); //Launching the Pdf file PDFDocumentViewer(output); }
private void button1_Click(object sender, EventArgs e) { //Load a pdf document string input = @"..\..\..\..\..\..\Data\RadioButton.pdf"; PdfDocument pdf = new PdfDocument(); pdf.LoadFromFile(input); //Get pdf forms PdfFormWidget formWidget = pdf.Form as PdfFormWidget; //Find the radio button field and select the second item for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++) { PdfField field = formWidget.FieldsWidget.List[i] as PdfField; if (field is PdfRadioButtonListFieldWidget) { PdfRadioButtonListFieldWidget radioButton = field as PdfRadioButtonListFieldWidget; if (radioButton.Name == "RadioButton") { radioButton.SelectedIndex = 1; } } } String result = "SelectRadioButtonItem_out.pdf"; //Save the document pdf.SaveToFile(result); //Launch the Pdf file PDFDocumentViewer(result); }
private void button1_Click(object sender, EventArgs e) { //Pdf file path string input = @"..\..\..\..\..\..\Data\FormField.pdf"; //Open pdf document PdfDocument pdf = new PdfDocument(); pdf.LoadFromFile(input); PdfFormWidget form = pdf.Form as PdfFormWidget; for (int i = 0; i < form.FieldsWidget.List.Count; i++) { PdfField field = form.FieldsWidget.List[i] as PdfField; if (field is PdfTextBoxFieldWidget) { PdfTextBoxFieldWidget textbox = field as PdfTextBoxFieldWidget; //Find the textbox named total if (textbox.Name == "TextBox1") { textbox.Text = "New value"; } } } String result = "ModifyFormFieldValue_out.pdf"; //Save the document pdf.SaveToFile(result); //Launch the Pdf file PDFDocumentViewer(result); }
public void deleteAllFieldsFromPdf() { PdfFormWidget formWidget = pdf.Form as PdfFormWidget; for (int i = formWidget.FieldsWidget.List.Count - 1; i >= 0; i--) { PdfField field = formWidget.FieldsWidget.List[i] as PdfField; formWidget.FieldsWidget.Remove(field); } }
// FelderOperationen public void getFieldsFromPdf() { PdfFormWidget formWidget = pdf.Form as PdfFormWidget; for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++) { PdfField field = formWidget.FieldsWidget.List[i] as PdfField; string fieldName = field.Name; Console.WriteLine(fieldName); } Console.ReadLine(); }
private void button1_Click(object sender, EventArgs e) { //Load a pdf document string input = @"..\..\..\..\..\..\Data\RadioButton.pdf"; PdfDocument pdf = new PdfDocument(); pdf.LoadFromFile(input); //Get pdf forms PdfFormWidget formWidget = pdf.Form as PdfFormWidget; //Find the radio button field and add capture for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++) { PdfField field = formWidget.FieldsWidget.List[i] as PdfField; if (field is PdfRadioButtonListFieldWidget) { PdfRadioButtonListFieldWidget radioButton = field as PdfRadioButtonListFieldWidget; if (radioButton.Name == "RadioButton") { //Get the page PdfPageBase page = radioButton.Page; //Set capture name string text = "Radio button caption"; //Set font, pen and brush PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 12f); PdfPen pen = new PdfPen(Color.Red, 0.02f); PdfSolidBrush brush = new PdfSolidBrush(Color.Red); //Set the capture location float x = radioButton.Location.X; float y = radioButton.Location.Y - font.MeasureString(text).Height - 10;; //Draw capture page.Canvas.DrawString(text, font, pen, brush, x, y); } } } String result = "AddRadioButtonCaption_out.pdf"; //Save the document pdf.SaveToFile(result); //Launch the Pdf file PDFDocumentViewer(result); }
private void btnGenerate_Click(object sender, RoutedEventArgs e) { PdfDocument doc = new PdfDocument("sample.pdf"); PdfField field = doc.Fields["PatientName"]; field.Value = string.IsNullOrEmpty(txtUserFullName.Text.Trim())?"(No name)":txtUserFullName.Text.Trim(); PdfField field2 = doc.Fields["Age"]; field2.Value = string.IsNullOrEmpty(txtAge.Text.Trim()) ? "--" : txtAge.Text.Trim();; var fileName = DateTime.Now.Ticks.ToString() + ".pdf"; doc.Save(fileName); System.Diagnostics.Process.Start(fileName); }
private void button1_Click(object sender, EventArgs e) { //Load a pdf document string input = @"..\..\..\..\..\..\Data\RecognizeRequiredField.pdf"; PdfDocument doc = new PdfDocument(); doc.LoadFromFile(input); //Get pdf forms PdfFormWidget formWidget = doc.Form as PdfFormWidget; for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++) { PdfField field = formWidget.FieldsWidget.List[i] as PdfField; //Judge if the field is required if (field.Required) { MessageBox.Show("The field named: " + field.Name + " is required"); } } }
private void button1_Click(object sender, EventArgs e) { //Create a pdf document PdfDocument pdf = new PdfDocument(); //Load a pdf document pdf.LoadFromFile(@"..\..\..\..\..\..\Data\ExtractJavaScript.pdf"); string js = null; PdfFormWidget form = pdf.Form as PdfFormWidget; for (int i = 0; i < form.FieldsWidget.List.Count; i++) { PdfField field = form.FieldsWidget.List[i] as PdfField; if (field is PdfTextBoxFieldWidget) { PdfTextBoxFieldWidget textbox = field as PdfTextBoxFieldWidget; //Find the textbox named total if (textbox.Name == "total") { //Get the action PdfJavaScriptAction jsa = textbox.Actions.Calculate; if (jsa != null) { //Get JavaScript js = jsa.Script; } } } } //Save and launch the result file File.WriteAllText("ExtractJavaScript.txt", js); System.Diagnostics.Process.Start("ExtractJavaScript.txt"); }
private void button1_Click(object sender, EventArgs e) { //pdf file string input = "..\\..\\..\\..\\..\\..\\..\\Data\\FormField.pdf"; //open pdf document PdfDocument doc = new PdfDocument(input); //get pdf form PdfFormWidget formWidget = doc.Form as PdfFormWidget; //find the particular form field and determine if it marks as required or not for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++) { PdfField field = formWidget.FieldsWidget.List[i] as PdfField; if (field is PdfTextBoxFieldWidget) { PdfTextBoxFieldWidget textbox = field as PdfTextBoxFieldWidget; if (textbox.Name == "username") { textbox.Required = true; } if (textbox.Name == "password2") { textbox.Required = false; } } } string output = "result.pdf"; //save pdf document doc.SaveToFile(output); //Launching the Pdf file PDFDocumentViewer(output); }
private void button1_Click(object sender, EventArgs e) { //Load a pdf document string input = @"..\..\..\..\..\..\Data\FillFormField.pdf"; PdfDocument doc = new PdfDocument(); doc.LoadFromFile(input); //Get pdf forms PdfFormWidget formWidget = doc.Form as PdfFormWidget; //Fill pdf form fields for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++) { PdfField field = formWidget.FieldsWidget.List[i] as PdfField; if (field is PdfTextBoxFieldWidget) { PdfTextBoxFieldWidget textBoxField = field as PdfTextBoxFieldWidget; switch (textBoxField.Name) { case "email": textBoxField.Text = "*****@*****.**"; break; case "username": textBoxField.Text = "E-iceblue"; break; case "password": textBoxField.Password = true; textBoxField.Text = "e-iceblue"; break; case "password2": textBoxField.Password = true; textBoxField.Text = "e-iceblue"; break; case "company_name ": textBoxField.Text = "E-iceblue"; break; case "first_name": textBoxField.Text = "James"; break; case "last_name": textBoxField.Text = "Chen"; break; case "middle_name": textBoxField.Text = "J"; break; case "address1": textBoxField.Text = "Chengdu"; break; case "address2": textBoxField.Text = "Beijing"; break; case "city": textBoxField.Text = "Shanghai"; break; case "postal_code": textBoxField.Text = "11111"; break; case "state": textBoxField.Text = "Shanghai"; break; case "phone": textBoxField.Text = "1234567901"; break; case "mobile_phone": textBoxField.Text = "123456789"; break; case "fax": textBoxField.Text = "12121212"; break; } } if (field is PdfListBoxWidgetFieldWidget) { PdfListBoxWidgetFieldWidget listBoxField = field as PdfListBoxWidgetFieldWidget; switch (listBoxField.Name) { case "email_format": int[] index = { 1 }; listBoxField.SelectedIndex = index; break; } } if (field is PdfComboBoxWidgetFieldWidget) { PdfComboBoxWidgetFieldWidget comBoxField = field as PdfComboBoxWidgetFieldWidget; switch (comBoxField.Name) { case "title": int[] items = { 0 }; comBoxField.SelectedIndex = items; break; } } if (field is PdfRadioButtonListFieldWidget) { PdfRadioButtonListFieldWidget radioBtnField = field as PdfRadioButtonListFieldWidget; switch (radioBtnField.Name) { case "country": radioBtnField.SelectedIndex = 1; break; } } if (field is PdfCheckBoxWidgetFieldWidget) { PdfCheckBoxWidgetFieldWidget checkBoxField = field as PdfCheckBoxWidgetFieldWidget; switch (checkBoxField.Name) { case "agreement_of_terms": checkBoxField.Checked = true; break; } } if (field is PdfButtonWidgetFieldWidget) { PdfButtonWidgetFieldWidget btnField = field as PdfButtonWidgetFieldWidget; switch (btnField.Name) { case "submit": btnField.Text = "Submit"; break; } } } string output = "FillFormField.pdf"; //Save pdf document doc.SaveToFile(output); //Launch the file PDFDocumentViewer(output); }
public void CreateQuoteIllustrationReport(int stlmtBrokerID, string annuitantName, string genderAndAgeLabel, string genderAndAge, DateTime quoteDate , DateTime purchaseDate, string rateVersion, DataGrid dgBenefits) { PdfDocument reportDoc; BusinessLogicLayer.Broker brk = new Broker(); brk.GetBroker(stlmtBrokerID); //string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //string tmpForm = System.IO.Path.Combine(path + @"\Reports", "QuoteTemplate.pdf"); //tmpForm = @"C:\Users\bbopp\Documents\Visual Studio 2013\Projects\StlmtQuote\StlmQuoteWPF\Reports\QuoteTemplate.pdf"; //tmpForm = @"C:\Program Files (x86)\Independent Insurance Group\Independent Quoting System\Reports\QuoteTemplate.pdf"; reportDoc = new PdfDocument(_templateIllustrationReport); // Page 1 ************************************************************************************* PdfField BrokerageName = reportDoc.Fields["BrokerageName"]; BrokerageName.Value = brk.EntityName; PdfField BrokerAddress1 = reportDoc.Fields["BrokerAddress1"]; BrokerAddress1.Value = brk.AddrLine1; PdfField BrokerAddress2 = reportDoc.Fields["BrokerAddress2"]; BrokerAddress2.Value = brk.City + ", " + brk.StateCode + ", " + brk.ZipCode5; PdfField PreparedBy = reportDoc.Fields["PreparedBy"]; PreparedBy.Value = brk.FirstName + " " + brk.LastName; PdfField PreparedFor = reportDoc.Fields["PreparedFor"]; PreparedFor.Value = annuitantName; PdfField GenderAgeLabel = reportDoc.Fields["GenderAgeLabel"]; GenderAgeLabel.Value = genderAndAgeLabel; PdfField GenderAge = reportDoc.Fields["GenderAge"]; GenderAge.Value = genderAndAge; PdfField QuoteDate = reportDoc.Fields["QuoteDate"]; QuoteDate.Value = quoteDate.ToShortDateString(); PdfField PurchaseDate = reportDoc.Fields["PurchaseDate"]; PurchaseDate.Value = purchaseDate.ToShortDateString(); PdfField RateVersion = reportDoc.Fields["RateVersion"]; RateVersion.Value = rateVersion; PdfField BenefitType1 = reportDoc.Fields["BenefitType1"]; PdfField BenefitPeriod1 = reportDoc.Fields["BenefitPeriod1"]; PdfField Amount1 = reportDoc.Fields["Amount1"]; PdfField Mode1 = reportDoc.Fields["Mode1"]; PdfField Premium1 = reportDoc.Fields["Premium1"]; PdfField BenefitType2 = reportDoc.Fields["BenefitType2"]; PdfField BenefitPeriod2 = reportDoc.Fields["BenefitPeriod2"]; PdfField Amount2 = reportDoc.Fields["Amount2"]; PdfField Mode2 = reportDoc.Fields["Mode2"]; PdfField Premium2 = reportDoc.Fields["Premium2"]; PdfField BenefitType3 = reportDoc.Fields["BenefitType3"]; PdfField BenefitPeriod3 = reportDoc.Fields["BenefitPeriod3"]; PdfField Amount3 = reportDoc.Fields["Amount3"]; PdfField Mode3 = reportDoc.Fields["Mode3"]; PdfField Premium3 = reportDoc.Fields["Premium3"]; PdfField BenefitType4 = reportDoc.Fields["BenefitType4"]; PdfField BenefitPeriod4 = reportDoc.Fields["BenefitPeriod4"]; PdfField Amount4 = reportDoc.Fields["Amount4"]; PdfField Mode4 = reportDoc.Fields["Mode4"]; PdfField Premium4 = reportDoc.Fields["Premium4"]; PdfField BenefitType5 = reportDoc.Fields["BenefitType5"]; PdfField BenefitPeriod5 = reportDoc.Fields["BenefitPeriod5"]; PdfField Amount5 = reportDoc.Fields["Amount5"]; PdfField Mode5 = reportDoc.Fields["Mode5"]; PdfField Premium5 = reportDoc.Fields["Premium5"]; PdfField Footer = reportDoc.Fields["Footer"]; string tmpFooter; tmpFooter = "Expected values are calculated using the annuitant’s actual age and life expectancy based on the 1983(a) IAM table.\n"; tmpFooter = tmpFooter + "This illustration will expire on " + DateTime.Now.AddDays(7).ToString("MM/dd/yyyy") + " or the last day of \n"; tmpFooter = tmpFooter + "This is an illustration only and is subject to approval by Independent Life, inclusive of the submission of all required documents and adherence to quoting restrictions as described in the IL Broker Manual & Underwriting Guidelines."; Footer.Value = tmpFooter; //Footer.Font = new EO.Pdf.Drawing.PdfFont("Adobe Arabic Italic", 10); Footer.Font.Italic = true; int benefitNum = 1; decimal totalPremium = 0.0m; string tmpBenefitPeriod = ""; DateTime endDate; foreach (System.Data.DataRowView dr in dgBenefits.ItemsSource) { switch (dr[3].ToString()) { case "Life": tmpBenefitPeriod = Convert.ToDateTime(dr[6].ToString()).ToString("MM/dd/yyyy") + " - for Life"; break; case "Period Certain": endDate = Convert.ToDateTime(dr[6].ToString()); endDate = endDate.AddYears(Convert.ToInt16(dr[7].ToString())); endDate = endDate.AddMonths(Convert.ToInt16(dr[8].ToString())); tmpBenefitPeriod = Convert.ToDateTime(dr[6].ToString()).ToString("MM/dd/yyyy") + " - " + endDate.ToShortDateString(); break; case "Temporary Life": endDate = Convert.ToDateTime(dr[6].ToString()); endDate = endDate.AddYears(Convert.ToInt16(dr[7].ToString())); endDate = endDate.AddMonths(Convert.ToInt16(dr[8].ToString())); tmpBenefitPeriod = Convert.ToDateTime(dr[6].ToString()).ToString("MM/dd/yyyy") + " - " + endDate.ToShortDateString(); break; case "Lump Sum": tmpBenefitPeriod = Convert.ToDateTime(dr[6].ToString()).ToString("MM/dd/yyyy"); break; default: break; } switch (benefitNum) { case 1: BenefitType1.Value = dr[3].ToString(); BenefitPeriod1.Value = tmpBenefitPeriod; Amount1.Value = String.Format("{0:C}", Convert.ToDecimal(dr[4].ToString())); Mode1.Value = dr[5].ToString(); Premium1.Value = String.Format("{0:C}", Convert.ToDecimal(dr[10].ToString())); break; case 2: BenefitType2.Value = dr[3].ToString(); BenefitPeriod2.Value = tmpBenefitPeriod; Amount2.Value = String.Format("{0:C}", Convert.ToDecimal(dr[4].ToString())); Mode2.Value = dr[5].ToString(); Premium2.Value = String.Format("{0:C}", Convert.ToDecimal(dr[10].ToString())); break; case 3: BenefitType3.Value = dr[3].ToString(); BenefitPeriod3.Value = tmpBenefitPeriod; Amount3.Value = String.Format("{0:C}", Convert.ToDecimal(dr[4].ToString())); Mode3.Value = dr[5].ToString(); Premium3.Value = String.Format("{0:C}", Convert.ToDecimal(dr[10].ToString())); break; case 4: BenefitType4.Value = dr[3].ToString(); BenefitPeriod4.Value = tmpBenefitPeriod; Amount4.Value = String.Format("{0:C}", Convert.ToDecimal(dr[4].ToString())); Mode4.Value = dr[5].ToString(); Premium4.Value = String.Format("{0:C}", Convert.ToDecimal(dr[10].ToString())); break; case 5: BenefitType5.Value = dr[3].ToString(); BenefitPeriod5.Value = tmpBenefitPeriod; Amount5.Value = String.Format("{0:C}", Convert.ToDecimal(dr[4].ToString())); Mode5.Value = dr[5].ToString(); Premium5.Value = String.Format("{0:C}", Convert.ToDecimal(dr[10].ToString())); break; default: break; } benefitNum++; totalPremium = totalPremium + Convert.ToDecimal(dr[10].ToString()); tmpBenefitPeriod = "Not Assigned"; } PdfField TotalPremium = reportDoc.Fields["TotalPremium"]; TotalPremium.Value = String.Format("{0:C}", totalPremium); PdfField AssignmentFee = reportDoc.Fields["AssignmentFee"]; AssignmentFee.Value = String.Format("{0:C}", 750.0); PdfField TotalCost = reportDoc.Fields["TotalCost"]; TotalCost.Value = String.Format("{0:C}", totalPremium + 750.0m); PdfDocument finalDoc = new PdfDocument(); finalDoc = reportDoc.Clone(); //finalDoc = proposalDoc; //finalDoc.Security.Permissions = PdfDocumentPermissions.Printing; //finalDoc.Security.Permissions = PdfDocumentPermissions.All | PdfDocumentPermissions.HighQualityPrinting; finalDoc.Security.Permissions = PdfDocumentPermissions.Printing | PdfDocumentPermissions.HighQualityPrinting; //finalDoc.Security.Permissions = PdfDocumentPermissions.CopyingContents| PdfDocumentPermissions.CopyingContentsForAccessibility; //string thisFileName; //thisFileName = "~/App_Data/SPDA_Proposal_" + thisProposal.DateCreated.ToString("dd-MM-yyyy_hh-mm-ss") + ".pdf"; //thisFileName = @"C:\Users\bbopp\Documents\Visual Studio 2013\Projects\StlmtQuote\StlmQuoteWPF\Reports\test_" + DateTime.Now.ToString("MM-dd-yyyy_hh-mm-ss") + ".pdf"; //thisFileName = @"C:\Program Files (x86)\Independent Insurance Group\Independent Quoting System\Reports\test_" + DateTime.Now.ToString("MM-dd-yyyy_hh-mm-ss") + ".pdf"; finalDoc.Save(IllustrationReportName); }
// public void CreateSettlementReport(int stlmtBrokerID, string annuitantName, string genderAndAge, DateTime quoteDate // , DateTime purchaseDate, string rateVersion, DataGrid dgBenefits) public void CreateSettlementReport(int stlmtBrokerID, string annuitantName, string genderAndAgeLabel, string genderAndAge, DateTime quoteDate , DateTime purchaseDate, string rateVersion, DataGrid dgBenefits, int quoteID) { decimal irr = 0.0m; decimal equivalentCash = 0.0m; decimal equivalentCashPct = 0.04m; DataAccessLayer.Report rpt = new DataAccessLayer.Report(); rpt.CreateSettlementReportData(quoteID, ref irr, ref equivalentCash); PdfDocument reportDoc; BusinessLogicLayer.Broker brk = new Broker(); brk.GetBroker(stlmtBrokerID); reportDoc = new PdfDocument(_templateSettlementReport); // Page 1 ************************************************************************************* PdfField BrokerageName = reportDoc.Fields["BrokerageName"]; BrokerageName.Value = brk.EntityName; PdfField BrokerAddress1 = reportDoc.Fields["BrokerAddress1"]; BrokerAddress1.Value = brk.AddrLine1; PdfField BrokerAddress2 = reportDoc.Fields["BrokerAddress2"]; BrokerAddress2.Value = brk.City + ", " + brk.StateCode + ", " + brk.ZipCode5; PdfField PreparedBy = reportDoc.Fields["PreparedBy"]; PreparedBy.Value = brk.FirstName + " " + brk.LastName; PdfField PreparedFor = reportDoc.Fields["PreparedFor"]; PreparedFor.Value = annuitantName; PdfField GenderAgeLabel = reportDoc.Fields["GenderAgeLabel"]; GenderAgeLabel.Value = genderAndAgeLabel; PdfField GenderAge = reportDoc.Fields["GenderAge"]; GenderAge.Value = genderAndAge; PdfField QuoteDate = reportDoc.Fields["QuoteDate"]; QuoteDate.Value = quoteDate.ToShortDateString(); PdfField PurchaseDate = reportDoc.Fields["PurchaseDate"]; PurchaseDate.Value = purchaseDate.ToShortDateString(); PdfField RateVersion = reportDoc.Fields["RateVersion"]; RateVersion.Value = rateVersion; PdfField BenefitDesc1 = reportDoc.Fields["BenefitDesc1"]; PdfField GuaranteedAmt1 = reportDoc.Fields["GuaranteedAmt1"]; PdfField ExpectedAmt1 = reportDoc.Fields["ExpectedAmt1"]; PdfField CostAmt1 = reportDoc.Fields["CostAmt1"]; PdfField BenefitDesc2 = reportDoc.Fields["BenefitDesc2"]; PdfField GuaranteedAmt2 = reportDoc.Fields["GuaranteedAmt2"]; PdfField ExpectedAmt2 = reportDoc.Fields["ExpectedAmt2"]; PdfField CostAmt2 = reportDoc.Fields["CostAmt2"]; PdfField BenefitDesc3 = reportDoc.Fields["BenefitDesc3"]; PdfField GuaranteedAmt3 = reportDoc.Fields["GuaranteedAmt3"]; PdfField ExpectedAmt3 = reportDoc.Fields["ExpectedAmt3"]; PdfField CostAmt3 = reportDoc.Fields["CostAmt3"]; PdfField BenefitDesc4 = reportDoc.Fields["BenefitDesc4"]; PdfField GuaranteedAmt4 = reportDoc.Fields["GuaranteedAmt4"]; PdfField ExpectedAmt4 = reportDoc.Fields["ExpectedAmt4"]; PdfField CostAmt4 = reportDoc.Fields["CostAmt4"]; PdfField BenefitDesc5 = reportDoc.Fields["BenefitDesc5"]; PdfField GuaranteedAmt5 = reportDoc.Fields["GuaranteedAmt5"]; PdfField ExpectedAmt5 = reportDoc.Fields["ExpectedAmt5"]; PdfField CostAmt5 = reportDoc.Fields["CostAmt5"]; int benefitNum = 1; decimal subTotalGuranteedAmt = 0.0m; decimal subTotalExpectedBenefitAmt = 0.0m; decimal subTotalCostAmt = 0.0m; string tmpBenefitDesc = ""; DateTime endDate; foreach (System.Data.DataRowView dr in dgBenefits.ItemsSource) { decimal benefitAmt = Convert.ToDecimal(dr[4].ToString()); string paymentMode = dr[5].ToString(); int certainYears = Convert.ToInt16(dr[7].ToString()); endDate = Convert.ToDateTime(dr[6].ToString()); //endDate = endDate.AddYears(Convert.ToInt16(dr[7].ToString())); //endDate = endDate.AddMonths(Convert.ToInt16(dr[8].ToString())); endDate = endDate.AddMonths((Convert.ToInt16(dr[7].ToString()) * 12) + (Convert.ToInt16(dr[8].ToString())) - 1); switch (dr[3].ToString()) { case "Life": tmpBenefitDesc = "Life with Certain Period Annuity - " + String.Format("{0:C}", benefitAmt) + " for life, payable " + paymentMode + ", " + " guaranteed for " + certainYears.ToString() + " year(s), " + "beginning on " + Convert.ToDateTime(dr[6].ToString()).ToShortDateString() + ", " + "with the last guaranteed payment on " + endDate.ToShortDateString(); break; case "Period Certain": tmpBenefitDesc = "Period Certain Annuity - " + String.Format("{0:C}", benefitAmt) + " payable " + paymentMode + ", " + " guaranteed for " + certainYears.ToString() + " year(s), " + "beginning on " + Convert.ToDateTime(dr[6].ToString()).ToShortDateString() + ", " + "with the last guaranteed payment on " + endDate.ToShortDateString(); break; case "Temporary Life": tmpBenefitDesc = "Temporary Life Annuity - " + String.Format("{0:C}", benefitAmt) + " paid if living, payable " + paymentMode + ", " + "beginning on " + Convert.ToDateTime(dr[6].ToString()).ToShortDateString() + " for a maximum of " + certainYears.ToString() + " year(s)."; break; case "Lump Sum": tmpBenefitDesc = "Guaranteed Lump Sum - " + String.Format("{0:C}", benefitAmt) + " paid on " + Convert.ToDateTime(dr[6].ToString()).ToShortDateString(); break; default: break; } decimal guaranteedAmt = Convert.ToDecimal(dr[13].ToString()) * benefitAmt; decimal expectedAmt = Convert.ToDecimal(dr[12].ToString()) * benefitAmt; decimal costAmt = Convert.ToDecimal(dr[10].ToString()); switch (benefitNum) { case 1: BenefitDesc1.Value = tmpBenefitDesc; GuaranteedAmt1.Value = String.Format("{0:C}", guaranteedAmt); ExpectedAmt1.Value = String.Format("{0:C}", expectedAmt); CostAmt1.Value = String.Format("{0:C}", costAmt); break; case 2: BenefitDesc2.Value = tmpBenefitDesc; GuaranteedAmt2.Value = String.Format("{0:C}", guaranteedAmt); ExpectedAmt2.Value = String.Format("{0:C}", expectedAmt); CostAmt2.Value = String.Format("{0:C}", costAmt); break; case 3: BenefitDesc3.Value = tmpBenefitDesc; GuaranteedAmt3.Value = String.Format("{0:C}", guaranteedAmt); ExpectedAmt3.Value = String.Format("{0:C}", expectedAmt); CostAmt3.Value = String.Format("{0:C}", costAmt); break; case 4: BenefitDesc4.Value = tmpBenefitDesc; GuaranteedAmt4.Value = String.Format("{0:C}", guaranteedAmt); ExpectedAmt4.Value = String.Format("{0:C}", expectedAmt); CostAmt4.Value = String.Format("{0:C}", costAmt); break; case 5: BenefitDesc5.Value = tmpBenefitDesc; GuaranteedAmt5.Value = String.Format("{0:C}", guaranteedAmt); ExpectedAmt5.Value = String.Format("{0:C}", expectedAmt); CostAmt5.Value = String.Format("{0:C}", costAmt); break; default: break; } benefitNum++; subTotalGuranteedAmt = subTotalGuranteedAmt + guaranteedAmt; subTotalExpectedBenefitAmt = subTotalExpectedBenefitAmt + expectedAmt; subTotalCostAmt = subTotalCostAmt + costAmt; tmpBenefitDesc = "Not Assigned"; } //PdfField SubTotalGuaranteedAmt = reportDoc.Fields["SubTotalGuaranteedAmt"]; //SubTotalGuaranteedAmt.Value = String.Format("{0:C}", subTotalGuranteedAmt); //PdfField SubTotalExpectedAmt = reportDoc.Fields["SubTotalExpectedAmt"]; //SubTotalExpectedAmt.Value = String.Format("{0:C}", subTotalExpectedBenefitAmt); //PdfField SubTotalCostAmt = reportDoc.Fields["SubTotalCostAmt"]; //SubTotalCostAmt.Value = String.Format("{0:C}", subTotalCostAmt); PdfField AnnuityCostAmt = reportDoc.Fields["AnnuityCostAmt"]; AnnuityCostAmt.Value = String.Format("{0:C}", subTotalCostAmt); PdfField AssignmentFeeAmt = reportDoc.Fields["AssignmentFeeAmt"]; AssignmentFeeAmt.Value = String.Format("{0:C}", 750.0m); PdfField TotalGuaranteedAmt = reportDoc.Fields["TotalGuaranteedAmt"]; TotalGuaranteedAmt.Value = String.Format("{0:C}", subTotalGuranteedAmt); PdfField TotalExpectedAmt = reportDoc.Fields["TotalExpectedAmt"]; TotalExpectedAmt.Value = String.Format("{0:C}", subTotalExpectedBenefitAmt); PdfField TotalCostAmt = reportDoc.Fields["TotalCostAmt"]; TotalCostAmt.Value = String.Format("{0:C}", subTotalCostAmt + 750.0m); PdfField EquivalentCashAmt = reportDoc.Fields["EquivalentCashAmt"]; EquivalentCashAmt.Value = String.Format("{0:C}", equivalentCash); PdfField EquivalentCashPct = reportDoc.Fields["EquivalentCashPct"]; EquivalentCashPct.Value = "@ " + equivalentCashPct.ToString("P"); PdfField IRR = reportDoc.Fields["IRR"]; IRR.Value = irr.ToString("P"); PdfField Footer1 = reportDoc.Fields["Footer1"]; PdfField Footer2 = reportDoc.Fields["Footer2"]; PdfField Footer3 = reportDoc.Fields["Footer3"]; Footer1.Value = "Expected values are calculated using the annuitant’s actual age and life expectancy based on the 1983(a) IAM table."; Footer2.Value = "This illustration will expire on " + DateTime.Now.AddDays(7).ToString("MM/dd/yyyy") + " Rate Series: " + rateVersion; Footer3.Value = "This is an illustration only and is subject to approval by Independent Life, inclusive of the submission of all required documents and adherence to quoting restrictions as described in the IL Broker Manual & Underwriting Guidelines."; //Footer1.Font = new EO.Pdf.Drawing.PdfFont("Adobe Arabic Italic", 10); Footer1.Font.Italic = true; Footer2.Font.Italic = true; Footer3.Font.Italic = true; PdfDocument finalDoc = new PdfDocument(); finalDoc = reportDoc.Clone(); finalDoc.Security.Permissions = PdfDocumentPermissions.Printing | PdfDocumentPermissions.HighQualityPrinting; finalDoc.Save(SettlementReportName); }
private void button1_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); //Load a pdf document string input = @"..\..\..\..\..\..\Data\AllFields.pdf"; PdfDocument doc = new PdfDocument(); doc.LoadFromFile(input); //Get pdf forms PdfFormWidget formWidget = doc.Form as PdfFormWidget; //Find pdf form fields for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++) { PdfField field = formWidget.FieldsWidget.List[i] as PdfField; if (field is PdfTextBoxFieldWidget) { PdfTextBoxFieldWidget textBoxField = field as PdfTextBoxFieldWidget; //Get text of textbox string text = textBoxField.Text; sb.Append("The text in textbox is " + text + "\r\n"); } if (field is PdfListBoxWidgetFieldWidget) { PdfListBoxWidgetFieldWidget listBoxField = field as PdfListBoxWidgetFieldWidget; sb.Append("Listbox items are \r\n"); //Get values of listbox PdfListWidgetItemCollection items = listBoxField.Values; foreach (PdfListWidgetItem item in items) { sb.Append(item.Value + "\r\n"); } //Get selected value string selectedValue = listBoxField.SelectedValue; sb.Append("The selected value in the listbox is " + selectedValue + "\r\n"); } if (field is PdfComboBoxWidgetFieldWidget) { PdfComboBoxWidgetFieldWidget comBoxField = field as PdfComboBoxWidgetFieldWidget; sb.Append("comBoxField items are \r\n"); //Get values of comboBox PdfListWidgetItemCollection items = comBoxField.Values; foreach (PdfListWidgetItem item in items) { sb.Append(item.Value + "\r\n"); } //Get selected value string selectedValue = comBoxField.SelectedValue; sb.Append("The selected value in the comBoxField is " + selectedValue + "\r\n"); } if (field is PdfRadioButtonListFieldWidget) { PdfRadioButtonListFieldWidget radioBtnField = field as PdfRadioButtonListFieldWidget; //Get value of radio button string value = radioBtnField.Value; sb.Append("The text in radioButtonField is " + value + "\r\n"); } if (field is PdfCheckBoxWidgetFieldWidget) { PdfCheckBoxWidgetFieldWidget checkBoxField = field as PdfCheckBoxWidgetFieldWidget; //Get the checked state of the checkbox bool state = checkBoxField.Checked; sb.Append("If the checkBox is checked: " + state + "\r\n"); } } string result = "GetAllValues.txt"; File.WriteAllText(result, sb.ToString()); //Launch file PDFDocumentViewer(result); }