I have created a web page that dynamically creates textboxes on a page. Basically the textbox id's and the number of textboxes created are determined from a database. I need help setting the Form Field Values in the PDF equal to the Web Page Textboxes.
Normally, I would use:
MyDocument.Form.Fields("topmostSubform[0].Page2[0].Group_1_Part_1_1[0]").Value = txtPF1a.Text
But, Since the textboxes are dynamically crated I'm not sure how to do this. If figured out how to get all the form field from the pdf but I don't know how to link them.
Private Sub CreateList(ByVal fieldList As ceTe.DynamicPDF.Merger.Forms.PdfFormFieldList)
For i As Integer = 0 To fieldList.Count - 1
fieldList(i).Name
If fieldList(i).HasChildFields = True Then
CreateList(fieldList(i).ChildFields)
End If
Next
End Sub
Dynamic TextBoxes = Form Fields
Re: Dynamic TextBoxes = Form Fields
Forum member · Jun 18, 2007I'm getting pretty close or I'm way off.
Any help???
Sub ReadPDF()
' PDF to read form fields from
Dim pdfDocument As New PdfDocument(MapPath("Images/Project2.pdf"))
CreateList(pdfDocument.Form.Fields)
End Sub
Private Sub CreateList(ByVal fieldList As ceTe.DynamicPDF.Merger.Forms.PdfFormFieldList)
For i As Integer = 0 To fieldList.Count - 1
Dim s As String
Dim nPosition As Integer
nPosition = fieldList(i).Name.IndexOf("[")
s = fieldList(i).Name.Substring(0, nPosition)
fieldList(i).Equals(CType(form1.Page.FindControl(s), RadNumericTextBox).Text)
If fieldList(i).HasChildFields = True Then
CreateList(fieldList(i).ChildFields)
End If
Next
End Sub
Re: Dynamic TextBoxes = Form Fields
Support · Jun 19, 2007Hello,
You can fill the form fields with the textbox values using the full name of the form field without any problem. You can use the textbox name which is in the database to get the text and assign this text to the PDF form field.
pdfDoc.Form.Field["FormFieldName"].Value = textBoxId.Text;
Are you trying to compare the PDF form field name with the textbox id before assigning the value? In that case you can access and get the full names of all the PDF form fields by using the FullName property of the form field. The CreateList method is usefull to loop through all the form fields. You can refer to the AcroFormFieldReader example which gives the full names of the form fields from your PDF document.
Thanks,
ceTe Software Support Team.
Re: Dynamic TextBoxes = Form Fields
Forum member · Jun 19, 2007Yes, I'm trying to retrieve all the pdf form fields and then setting the form field values = to the web form textboxes. I think I need to do something like the following:
Private Sub CreateList(ByVal fieldList As ceTe.DynamicPDF.Merger.Forms.PdfFormFieldList, ByVal MyDocument As MergerDocument)
For i As Integer = 0 To fieldList.Count - 1
Dim s As String
Dim nPosition As Integer
nPosition = fieldList(i).Name.IndexOf("[")
s = fieldList(i).Name.Substring(0, nPosition)
MyDocument.Form.Fields(fieldlist(i).FullName).value = CType(form1.Page.FindControl(s), RadNumericTextBox).Text)
If fieldList(i).HasChildFields = True Then
CreateList(fieldList(i).ChildFields)
End If
Next
End Sub
Any idea's or advice?
Re: Dynamic TextBoxes = Form Fields
Support · Jun 19, 2007Hello,
In order to retrieve the form field values you can use the following sample line of code.
string value = pdfDoc.Form.Fields["Name"].Value;
//assign this value to the TextBox on the webpage
textBoxId.Text = value;
You can refer to the Reading Form Field Values
topic on our help documentation to know about reading the form field values.
Thanks,
ceTe Software Support Team.