static public void AddCheckBoxFormFields(Form1 Parent) { int index = 1; //delegate string CheckNamesFields(IPXC_Document Doc, string fieldName, ref int x); CheckNamesFields checkNamesFields = (IPXC_Document Doc, string fName, ref int inx) => { string sFieldName = ""; uint i = 0; do { sFieldName = fName + inx; IPXC_FormField ff = Doc.AcroForm.GetFieldByName(sFieldName); if (ff == null) { break; } inx++; i++; }while (i <= Doc.AcroForm.FieldsCount); inx++; return(sFieldName); }; if (Parent.m_CurDoc == null) { Document.CreateNewDoc(Parent); } PXC_Rect rc = new PXC_Rect(); rc.top = 800; rc.right = 600; //Adding uncheked checkbox IPXC_UndoRedoData urD = null; IPXC_Pages pages = Parent.m_CurDoc.Pages; IPXC_Page Page = pages.InsertPage(0, rc, out urD); PXC_Rect rcPB = new PXC_Rect(); rcPB.left = 3.2 * 72.0; rcPB.right = rcPB.left + 0.5 * 72.0; rcPB.top = rc.top - 0.2 * 72.0; rcPB.bottom = rcPB.top - 0.5 * 72.0; //top is greater then bottom (PDF Coordinate System) IPXC_FormField checkBoxUnch = Parent.m_CurDoc.AcroForm.CreateField(checkNamesFields(Parent.m_CurDoc, "CheckBox", ref index), PXC_FormFieldType.FFT_CheckBox, 0, ref rcPB); Marshal.ReleaseComObject(checkBoxUnch); //Adding cheked checkbox rcPB.right = rc.right - 3.2 * 72.0; rcPB.left = rcPB.right - 0.5 * 72.0; IPXC_FormField checkBoxCh = Parent.m_CurDoc.AcroForm.CreateField(checkNamesFields(Parent.m_CurDoc, "CheckBox", ref index), PXC_FormFieldType.FFT_CheckBox, 0, ref rcPB); IPXC_Annotation annot = checkBoxCh.Widget[0]; IPXC_AnnotData_Widget widget = (IPXC_AnnotData_Widget)annot.Data; checkBoxCh.CheckWidget((uint)checkBoxCh.GetWidgetIndex(annot), true); Marshal.ReleaseComObject(checkBoxCh); Marshal.ReleaseComObject(Page); Marshal.ReleaseComObject(pages); }
static public void AddRadioButtonsFormFields(Form1 Parent) { if (Parent.m_CurDoc == null) { Document.CreateNewDoc(Parent); } PXC_Rect rc = new PXC_Rect(); rc.top = 800; rc.right = 600; //Adding group with RadioButtons IPXS_Inst pxsInst = (IPXS_Inst)Parent.m_pxcInst.GetExtension("PXS"); IPXC_UndoRedoData urD = null; IPXC_Pages pages = Parent.m_CurDoc.Pages; IPXC_Page Page = pages.InsertPage(0, rc, out urD); PXC_Rect rcPB = new PXC_Rect(); rcPB.top = rc.top - 0.35 * 72.0; rcPB.bottom = rcPB.top - 0.5 * 72.0; //top is greater then bottom (PDF Coordinate System) rcPB.left = 1.7 * 72.0; rcPB.right = rcPB.left + 0.5 * 72.0; IPXC_FormField firstGroup = Parent.m_CurDoc.AcroForm.CreateField("RadioButton", PXC_FormFieldType.FFT_RadioButton, 0, ref rcPB); rcPB.left = 2.3 * 72.0; rcPB.right = rcPB.left + 0.5 * 72.0; Parent.m_CurDoc.AcroForm.CreateField("RadioButton", PXC_FormFieldType.FFT_RadioButton, 0, ref rcPB); rcPB.left = 2.9 * 72.0; rcPB.right = rcPB.left + 0.5 * 72.0; Parent.m_CurDoc.AcroForm.CreateField("RadioButton", PXC_FormFieldType.FFT_RadioButton, 0, ref rcPB); rcPB.right = rc.right - 1.5 * 72.0; rcPB.left = rcPB.right - 0.5 * 72.0; IPXC_FormField secondGroup = Parent.m_CurDoc.AcroForm.CreateField("RadioButton1", PXC_FormFieldType.FFT_RadioButton, 0, ref rcPB); rcPB.top = rcPB.top - 0.6 * 72.0; rcPB.bottom = rcPB.top - 0.5 * 72.0; Parent.m_CurDoc.AcroForm.CreateField("RadioButton1", PXC_FormFieldType.FFT_RadioButton, 0, ref rcPB); firstGroup.CheckWidget(1, true); secondGroup.CheckWidget(1, true); Marshal.ReleaseComObject(firstGroup); Marshal.ReleaseComObject(secondGroup); Marshal.ReleaseComObject(Page); Marshal.ReleaseComObject(pages); }