private static Field smethod_7(string A_0, Document A_1) { int num = 12; Field field = null; string str = A_0.Trim(); FieldType type = Class819.smethod_2(str); FieldType type2 = type; if (type2 <= FieldType.FieldMergeField) { if (type2 != FieldType.FieldIf) { if (type2 != FieldType.FieldMergeField) { goto Label_005C; } field = new MergeField(A_1); } else { field = new IfField(A_1); } goto Label_0113; } switch (type2) { case FieldType.FieldFormTextInput: case FieldType.FieldFormCheckBox: case FieldType.FieldFormDropDown: { string str2 = str.ToUpper(); if (str2 != null) { if ((str2 == BookmarkStart.b("昱焳渵氷猹爻渽ᔿᙁ", num)) || (str2 == BookmarkStart.b("琱笳搵男渹礻昽ᐿ", num))) { field = new TextFormField(A_1); } else if ((str2 == BookmarkStart.b("瘱瀳稵焷椹栻", num)) || (str2 == BookmarkStart.b("琱笳搵男縹渻焽ဿفୃᅅه", num))) { field = new DropDownFormField(A_1); } else if ((str2 == BookmarkStart.b("焱簳猵笷焹縻焽ᠿ", num)) || (str2 == BookmarkStart.b("琱笳搵男礹琻笽̿ुكॅ၇", num))) { field = new CheckBoxFormField(A_1); } } (field as FormField).HasFFData = false; goto Label_0113; } } Label_005C: field = new Field(A_1); Label_0113: field.Code = field.Code + A_0; if (!(field is FormField)) { field.Type = type; } return(field); }
private static Field smethod_1(string A_0, Document A_1) { int num = 9; Field field = null; string str = A_0.Trim(); FieldType type = Class819.smethod_2(str); FieldType type2 = type; if (type2 <= FieldType.FieldMergeField) { if (type2 != FieldType.FieldIf) { if (type2 != FieldType.FieldMergeField) { goto Label_005C; } field = new MergeField(A_1); } else { field = new IfField(A_1); } goto Label_0113; } switch (type2) { case FieldType.FieldFormTextInput: case FieldType.FieldFormCheckBox: case FieldType.FieldFormDropDown: { string str2 = str.ToUpper(); if (str2 != null) { if ((str2 == BookmarkStart.b("笮琰欲愴縶眸欺格款", num)) || (str2 == BookmarkStart.b("椮縰愲破挶簸挺椼", num))) { field = new TextFormField(A_1); } else if ((str2 == BookmarkStart.b("欮田缲簴搶洸", num)) || (str2 == BookmarkStart.b("椮縰愲破猶欸琺洼笾เᑂୄ", num))) { field = new DropDownFormField(A_1); } else if ((str2 == BookmarkStart.b("氮礰瘲瘴簶笸琺攼", num)) || (str2 == BookmarkStart.b("椮縰愲破琶焸縺縼琾̀ూᵄ", num))) { field = new CheckBoxFormField(A_1); } } (field as FormField).HasFFData = false; goto Label_0113; } } Label_005C: field = new Field(A_1); Label_0113: field.Code = field.Code + A_0; if (!(field is FormField)) { field.Type = type; } return(field); }
private void imethod_15(CharacterFormat A_0, FieldType A_1) { Field field; FieldType type = A_1; if (type <= FieldType.FieldMergeField) { if (type != FieldType.FieldIf) { if (type != FieldType.FieldMergeField) { goto Label_0044; } field = new MergeField(this.document_0); } else { field = new IfField(this.document_0); } goto Label_007A; } switch (type) { case FieldType.FieldFormTextInput: field = new TextFormField(this.document_0); goto Label_007A; case FieldType.FieldFormCheckBox: field = new CheckBoxFormField(this.document_0); goto Label_007A; case FieldType.FieldFormDropDown: field = new DropDownFormField(this.document_0); goto Label_007A; } Label_0044: field = new Field(this.document_0); Label_007A: this.fieldCharType_0 = FieldCharType.Begin; field.Type = A_1; field.CharacterFormat = (CharacterFormat)A_0.Clone(); this.documentObject_0.method_13(field); if (A_1 == FieldType.FieldTOC) { (this.documentObject_0 as Paragraph).IsTOCPara = true; } this.stack_0.Push(field); }
private int method_17(int A_0, DocumentObject A_1) { int num = 0x13; switch ((A_1 as FormField).FormFieldType) { case FormFieldType.TextInput: { TextFormField field = A_1 as TextFormField; if ((field.Name == null) || (field.Name == string.Empty)) { field.Name = (BookmarkStart.b("洸帺䔼䬾Ṁ", num) + Guid.NewGuid().ToString().Replace(BookmarkStart.b("ᐸ", num), BookmarkStart.b("昸", num))).Substring(0, 20); } if ((field.DefaultText == null) || (field.DefaultText == string.Empty)) { field.DefaultText = BookmarkStart.b("㬘㤚㼜㴞䍠", num); } break; } case FormFieldType.CheckBox: { CheckBoxFormField field3 = A_1 as CheckBoxFormField; if ((field3.Name == null) || (field3.Name == string.Empty)) { field3.Name = (BookmarkStart.b("稸区堼尾⩀᱂", num) + Guid.NewGuid().ToString().Replace(BookmarkStart.b("ᐸ", num), BookmarkStart.b("昸", num))).Substring(0, 20); } break; } case FormFieldType.DropDown: { DropDownFormField field2 = A_1 as DropDownFormField; if ((field2.Name == null) || (field2.Name == string.Empty)) { field2.Name = (BookmarkStart.b("紸䤺刼伾Ṁ", num) + Guid.NewGuid().ToString().Replace(BookmarkStart.b("ᐸ", num), BookmarkStart.b("昸", num))).Substring(0, 20); } break; } } (this.Owner as Paragraph).method_78((A_1 as FormField).Name); (this.Owner as Paragraph).Items.Insert(A_0, new BookmarkStart(base.Document, (A_1 as FormField).Name)); A_0++; return(A_0); }
void MailMerge_MergeField(object sender, MergeFieldEventArgs args) { if (args.FieldValue == "Yes") { //Create a checkbox name string checkBoxName = args.FieldName; Paragraph para = args.CurrentMergeField.OwnerParagraph; int index = para.ChildObjects.IndexOf(args.CurrentMergeField); // Insert a check box. CheckBoxFormField field = para.AppendField(checkBoxName, FieldType.FieldFormCheckBox) as CheckBoxFormField; para.ChildObjects.Insert(index, field); para.ChildObjects.Remove(args.CurrentMergeField); field.Checked = true; } if (args.FieldValue == "No") { //Create a checkbox name string checkBoxName = args.FieldName; Paragraph para = args.CurrentMergeField.OwnerParagraph; int index = para.ChildObjects.IndexOf(args.CurrentMergeField); // Insert a check box. CheckBoxFormField field = para.AppendField(checkBoxName, FieldType.FieldFormCheckBox) as CheckBoxFormField; para.ChildObjects.Insert(index, field); para.ChildObjects.Remove(args.CurrentMergeField); field.Checked = false; } // Insert html during mail merge. if (args.FieldName == "Body") { Paragraph para = args.CurrentMergeField.OwnerParagraph; para.AppendHTML(args.FieldValue.ToString()); para.ChildObjects.Remove(args.CurrentMergeField); } // Insert text input form field. if (args.FieldName == "Date") { string textInputName = args.FieldName; Paragraph para = args.CurrentMergeField.OwnerParagraph; TextFormField field = para.AppendField(textInputName, FieldType.FieldFormTextInput) as TextFormField; para.ChildObjects.Remove(args.CurrentMergeField); field.Text = args.FieldValue.ToString(); } }
private void imethod_14(Class42 A_0, CharacterFormat A_1) { switch (A_0.method_87()) { case FormFieldType.TextInput: { TextFormField field3 = this.stack_0.Peek() as TextFormField; field3.Name = A_0.method_46(); field3.ApplyCharacterFormat(A_1); field3.DefaultText = A_0.method_68(); field3.MaximumLength = A_0.method_64(); field3.StringFormat = A_0.method_70(); field3.TextFieldType = A_0.method_66(); return; } case FormFieldType.CheckBox: { CheckBoxFormField field = this.stack_0.Peek() as CheckBoxFormField; field.Name = A_0.method_46(); field.ApplyCharacterFormat(A_1); field.CalculateOnExit = A_0.method_50(); field.CheckBoxSize = (int)(((float)A_0.method_74()) / 2f); field.SizeType = A_0.method_72() ? CheckBoxSizeType.Auto : CheckBoxSizeType.Exactly; field.Checked = A_0.method_78(); field.DefaultCheckBoxValue = A_0.method_76(); return; } case FormFieldType.DropDown: { DropDownFormField field2 = this.stack_0.Peek() as DropDownFormField; field2.Name = A_0.method_46(); field2.ApplyCharacterFormat(A_1); field2.DefaultDropDownValue = A_0.method_81(); A_0.method_86().method_6(field2.DropDownItems); field2.DropDownSelectedIndex = A_0.method_83(); return; } } }
private void AddForm(Section section) { ParagraphStyle descriptionStyle = new ParagraphStyle(section.Document); descriptionStyle.Name = "description"; descriptionStyle.CharacterFormat.FontSize = 12; descriptionStyle.CharacterFormat.FontName = "Arial"; descriptionStyle.CharacterFormat.TextColor = Color.FromArgb(0x00, 0x45, 0x8e); section.Document.Styles.Add(descriptionStyle); Paragraph p1 = section.AddParagraph(); String text1 = "So that we can verify your identity and find your information, " + "please provide us with the following information. " + "This information will be used to create your online account. " + "Your information is not public, shared in anyway, or displayed on this site"; p1.AppendText(text1); p1.ApplyStyle(descriptionStyle.Name); Paragraph p2 = section.AddParagraph(); String text2 = "You must provide a real email address to which we will send your password."; p2.AppendText(text2); p2.ApplyStyle(descriptionStyle.Name); p2.Format.AfterSpacing = 8; //field group label style ParagraphStyle formFieldGroupLabelStyle = new ParagraphStyle(section.Document); formFieldGroupLabelStyle.Name = "formFieldGroupLabel"; formFieldGroupLabelStyle.ApplyBaseStyle("description"); formFieldGroupLabelStyle.CharacterFormat.Bold = true; formFieldGroupLabelStyle.CharacterFormat.TextColor = Color.White; section.Document.Styles.Add(formFieldGroupLabelStyle); //field label style ParagraphStyle formFieldLabelStyle = new ParagraphStyle(section.Document); formFieldLabelStyle.Name = "formFieldLabel"; formFieldLabelStyle.ApplyBaseStyle("description"); formFieldLabelStyle.ParagraphFormat.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Right; section.Document.Styles.Add(formFieldLabelStyle); //add table Table table = section.AddTable(); //2 columns of per row table.DefaultColumnsNumber = 2; //default height of row is 20point table.DefaultRowHeight = 20; //load form config data using (Stream stream = File.OpenRead(@"..\..\..\..\..\..\Data\Form.xml")) { XPathDocument xpathDoc = new XPathDocument(stream); XPathNodeIterator sectionNodes = xpathDoc.CreateNavigator().Select("/form/section"); foreach (XPathNavigator node in sectionNodes) { //create a row for field group label, does not copy format TableRow row = table.AddRow(false); row.Cells[0].CellFormat.BackColor = Color.FromArgb(0x00, 0x71, 0xb6); row.Cells[0].CellFormat.VerticalAlignment = VerticalAlignment.Middle; //label of field group Paragraph cellParagraph = row.Cells[0].AddParagraph(); cellParagraph.AppendText(node.GetAttribute("name", "")); cellParagraph.ApplyStyle(formFieldGroupLabelStyle.Name); XPathNodeIterator fieldNodes = node.Select("field"); foreach (XPathNavigator fieldNode in fieldNodes) { //create a row for field, does not copy format TableRow fieldRow = table.AddRow(false); //field label fieldRow.Cells[0].CellFormat.VerticalAlignment = VerticalAlignment.Middle; Paragraph labelParagraph = fieldRow.Cells[0].AddParagraph(); labelParagraph.AppendText(fieldNode.GetAttribute("label", "")); labelParagraph.ApplyStyle(formFieldLabelStyle.Name); fieldRow.Cells[1].CellFormat.VerticalAlignment = VerticalAlignment.Middle; Paragraph fieldParagraph = fieldRow.Cells[1].AddParagraph(); String fieldId = fieldNode.GetAttribute("id", ""); switch (fieldNode.GetAttribute("type", "")) { case "text": //add text input field TextFormField field = fieldParagraph.AppendField(fieldId, FieldType.FieldFormTextInput) as TextFormField; //set default text field.DefaultText = ""; field.Text = ""; break; case "list": //add dropdown field DropDownFormField list = fieldParagraph.AppendField(fieldId, FieldType.FieldFormDropDown) as DropDownFormField; //add items into dropdown. XPathNodeIterator itemNodes = fieldNode.Select("item"); foreach (XPathNavigator itemNode in itemNodes) { list.DropDownItems.Add(itemNode.SelectSingleNode("text()").Value); } break; case "checkbox": //add checkbox field fieldParagraph.AppendField(fieldId, FieldType.FieldFormCheckBox); break; } } //merge field group row. 2 columns to 1 column table.ApplyHorizontalMerge(row.GetRowIndex(), 0, 1); } } }
private void button1_Click(object sender, EventArgs e) { //Create the source document Document sourceDocument = new Document(); //Load the source document from disk. sourceDocument.LoadFromFile(@"..\..\..\..\..\..\Data\TextInputField.docx"); //Traverse FormFields foreach (FormField field in sourceDocument.Sections[0].Body.FormFields) { //Find FieldFormTextInput type field if (field.Type == FieldType.FieldFormTextInput) { //Get the paragraph Paragraph paragraph = field.OwnerParagraph; //Define variables int startIndex = 0; int endIndex = 0; //Create a new TextRange TextRange textRange = new TextRange(sourceDocument); //Set text for textRange textRange.Text = paragraph.Text; //Traverse DocumentObjectS of field paragraph foreach (DocumentObject obj in paragraph.ChildObjects) { //If its DocumentObjectType is BookmarkStart if (obj.DocumentObjectType == DocumentObjectType.BookmarkStart) { //Get the index startIndex = paragraph.ChildObjects.IndexOf(obj); } //If its DocumentObjectType is BookmarkEnd if (obj.DocumentObjectType == DocumentObjectType.BookmarkEnd) { //Get the index endIndex = paragraph.ChildObjects.IndexOf(obj); } } //Remove ChildObjects for (int i = endIndex; i > startIndex; i--) { //If it is TextFormField if (paragraph.ChildObjects[i] is TextFormField) { TextFormField textFormField = paragraph.ChildObjects[i] as TextFormField; //Remove the field object paragraph.ChildObjects.Remove(textFormField); } else { paragraph.ChildObjects.RemoveAt(i); } } //Insert the new TextRange paragraph.ChildObjects.Insert(startIndex, textRange); break; } } //Save the document. sourceDocument.SaveToFile("Output.docx", FileFormat.Docx); //Launch the Word file. WordDocViewer("Output.docx"); }
private void UpdateField() { //One or more of the fields properties changed so we need to update the field data //which is stored in the annotation objects UserData FormField currentField = _ocrField; string fieldType = (currentField is TextFormField) ? "Text" : "Omr"; switch (fieldType) { case "Text": if (!(currentField is TextFormField)) { currentField = new TextFormField(); } //set text field options (currentField as TextFormField).EnableIcr = _chkEnableIcr.Checked; (currentField as TextFormField).EnableOcr = _chkEnableOcr.Checked; (currentField as TextFormField).Type = _rbTextTypeChar.Checked ? TextFieldType.Character : TextFieldType.Numerical; break; case "Omr": if (!(currentField is OmrFormField)) { currentField = new OmrFormField(); } //set omr field options if (_rbOMRWithFrame.Checked) { (currentField as OmrFormField).FrameMethod = OcrOmrFrameDetectionMethod.WithFrame; } else if (_rbOMRWithoutFrame.Checked) { (currentField as OmrFormField).FrameMethod = OcrOmrFrameDetectionMethod.WithoutFrame; } else if (_rbOMRAutoFrame.Checked) { (currentField as OmrFormField).FrameMethod = OcrOmrFrameDetectionMethod.Auto; } if (_rbOMRSensitivityLowest.Checked) { (currentField as OmrFormField).Sensitivity = OcrOmrSensitivity.Lowest; } else if (_rbOMRSensitivityLow.Checked) { (currentField as OmrFormField).Sensitivity = OcrOmrSensitivity.Low; } else if (_rbOMRSensitivityHigh.Checked) { (currentField as OmrFormField).Sensitivity = OcrOmrSensitivity.High; } else if (_rbOMRSensitivityHighest.Checked) { (currentField as OmrFormField).Sensitivity = OcrOmrSensitivity.Highest; } break; } currentField.Bounds = new LeadRect(Convert.ToInt32(_nudLeft.Value), Convert.ToInt32(_nudTop.Value), Convert.ToInt32(_nudWidth.Value), Convert.ToInt32(_nudHeight.Value)); currentField.Name = _txt_ColumnOptionsFieldName.Text; _chkDropoutWords.Checked = (currentField.Dropout & DropoutFlag.WordsDropout) == DropoutFlag.WordsDropout; _chkDropoutCells.Checked = (currentField.Dropout & DropoutFlag.CellsDropout) == DropoutFlag.CellsDropout; }
private bool AddField(DiskMasterForm currentform, List <XmlModel> model) { try { DiskMasterForm currentMasterForm = currentform; FormRecognitionAttributes attributes = currentMasterForm.ReadAttributes(); FormPages formPages = currentMasterForm.ReadFields(); RasterImage formImage = currentMasterForm.ReadForm(); foreach (XmlModel xmlModel in model) { int i = formPages[xmlModel.PageNumber - 1].Count; formPages[xmlModel.PageNumber - 1].RemoveRange(0, i); foreach (XmlDetail xmlDetail in xmlModel.Detail) { FormField newField = null; if (xmlDetail.FieldInfo.ObjectId == -51) // For textfield => -51 //for OmrField => -50 { newField = new TextFormField(); (newField as TextFormField).EnableIcr = xmlDetail.FieldInfo.OcrFieldInfo.EnableICR; (newField as TextFormField).EnableOcr = xmlDetail.FieldInfo.OcrFieldInfo.EnableOCR; (newField as TextFormField).Type = (xmlDetail.FieldInfo.OcrFieldInfo.Character == true ? TextFieldType.Character : (xmlDetail.FieldInfo.OcrFieldInfo.Numeric == true ? TextFieldType.Numerical : TextFieldType.Data)); if (xmlDetail.FieldInfo.OcrFieldInfo.CellBoarders) { newField.Dropout |= DropoutFlag.CellsDropout; } else { newField.Dropout &= ~DropoutFlag.CellsDropout; } if (xmlDetail.FieldInfo.OcrFieldInfo.Words) { newField.Dropout |= DropoutFlag.WordsDropout; } else { newField.Dropout &= ~DropoutFlag.WordsDropout; } } else { newField = new OmrFormField(); if (xmlDetail.FieldInfo.OmrFieldInfo.WithFrame) { (newField as OmrFormField).FrameMethod = OcrOmrFrameDetectionMethod.WithFrame; } else if (xmlDetail.FieldInfo.OmrFieldInfo.WithoutFrame) { (newField as OmrFormField).FrameMethod = OcrOmrFrameDetectionMethod.WithoutFrame; } else if (xmlDetail.FieldInfo.OmrFieldInfo.Auto) { (newField as OmrFormField).FrameMethod = OcrOmrFrameDetectionMethod.Auto; } if (xmlDetail.FieldInfo.OmrFieldInfo.Lowest) { (newField as OmrFormField).Sensitivity = OcrOmrSensitivity.Lowest; } else if (xmlDetail.FieldInfo.OmrFieldInfo.Low) { (newField as OmrFormField).Sensitivity = OcrOmrSensitivity.Low; } else if (xmlDetail.FieldInfo.OmrFieldInfo.High) { (newField as OmrFormField).Sensitivity = OcrOmrSensitivity.High; } else if (xmlDetail.FieldInfo.OmrFieldInfo.Highest) { (newField as OmrFormField).Sensitivity = OcrOmrSensitivity.Highest; } } newField.Name = xmlDetail.FieldInfo.Name; newField.Bounds = new LeadRect(Convert.ToInt32(Annotations.Engine.AnnUnitConverter.ConvertToPixels(xmlDetail.Cordinates.X, Leadtools.Annotations.Engine.AnnUnit.Unit, 96)), Convert.ToInt32(Annotations.Engine.AnnUnitConverter.ConvertToPixels(xmlDetail.Cordinates.Y, Annotations.Engine.AnnUnit.Unit, 96)), Convert.ToInt32(Annotations.Engine.AnnUnitConverter.ConvertToPixels(xmlDetail.Cordinates.Width, Annotations.Engine.AnnUnit.Unit, 96)), Convert.ToInt32(Annotations.Engine.AnnUnitConverter.ConvertToPixels(xmlDetail.Cordinates.Height, Annotations.Engine.AnnUnit.Unit, 96))); // newField.Bounds= new LogicalRectangle(AnnUnitConverter.ConvertToPixels(xmlDetail.Cordinates.X, AnnUnit.Unit, 96), AnnUnitConverter.ConvertToPixels(xmlDetail.Cordinates.Y, AnnUnit.Unit, 96), AnnUnitConverter.ConvertToPixels(xmlDetail.Cordinates.Width, AnnUnit.Unit, 96), AnnUnitConverter.ConvertToPixels(xmlDetail.Cordinates.Height, AnnUnit.Unit, 96), LogicalUnit.Pixel); Annotations.Engine.AnnHiliteObject newObject = new Annotations.Engine.AnnHiliteObject(); newObject.Tag = newField; FormField currentField = newObject.Tag as FormField; formPages[xmlModel.PageNumber - 1].Add(currentField); } } currentMasterForm.WriteForm(formImage); currentMasterForm.WriteAttributes(attributes); currentMasterForm.WriteFields(formPages); return(true); } catch (Exception ex) { return(false); throw; } }