I am trying to fill a form from Xojo Code. The xojo code helps fill the form from a database depending on what the user choses.
The form started life as a Word Doc that was converted to PDF and then converted to a fillable form using Acrobat Pro. All it has are text fields and Radiobutton fields. The values of the radiobuttions are set (in Acrobat) to display as Checkmarks if that matters.
I have no trouble assigning values to text fields but I can’t seem to set the value for a radio button. Based on your example code, this is how I am trying to set it:
FIdx = pdf.FindField("ReqType")
Field = pdf.GetFieldEx(FIdx)
ub = Field.KidCount-1
Static ReqTypes() As String = Array("New", "Change","Biennial")
StrVal = ReqTypes(ReqTypePM.ListIndex)
For i as Integer = 0 to ub
Child = Field.Kids(ReqTypePM.ListIndex)
If Child.ExpValue = StrVal Then
call pdf.SetCheckBoxState(Child.Handle, true)
using the Debugger I know pdf.SetCheckBoxState is called as I set a break point there. I tried a few other things but nothing seems to work.No option is checked on the output PDF.
What could be the issue?
BTW Does DynaPDF docs come for any other coding language besides C?
For ChartDirector I used their ColdFusion Docs as that language was closer to Xojo and so easier for me to read.
I tried that before and did not work but thought maybe i was misunderstanding the expected parameters.
Using your suggestion gives me an error that the index does not exist. It looks like that function wants the handle of the parent group and the child’s index in the group. (which is what I tried earlier)
Executes without error (as did my original code that searched to find the right child) but the produced PDF does not have the control selected (same results as my original code).
Any other ideas?
Might I be doing something else wrong,
or is this a bug in DynaPDF or the way you implemented the Call in Xojo,
or maybe DynaPDF can’t radio buttons that as not created with DynaPDF itself (or all the config options for them in Acrobat Pro)?
The issue I was seeing was when I loaded the PDF in from a file, and could not set checkbox (or rather it just not show up), was only when I read the PDF Form from a file on disk…
When I pull the PDFdata from a DB directly into an in memory DynaPDF and set the checkboxes then save to disk, the checkmarks show up just !!!
Next i tried to read that PDF file back in and pull the filed data in the form fields out of it… But it’s not working … Not sure If I am messing the reading back in, or if there is an issue that is related to the checkmarks not showing up before…
Public Sub Load(PDFFIle as Folderitem)
Dim Stream as BinaryStream = BinaryStream.Open(PDFFile)
Dim theData As String = Stream.Read(Stream.Length)
Dim PDF as New DynaPDFMBS
Dim Msg As String
If Not CheckFileFormat(PDFData) Then
Msg = "Not a PDF"
ElseIf not pdf.CreateNewPDF(nil) then // create pdf in memory
Msg = "Could Not Create PDF In memory"
ElseIf pdf.OpenImportBuffer(PDFData) <> 0 Then // load from memory
Msg = "Could Not Load PDF Into memory"
If pdf.ImportPDFFile(1,1.0,1.0) < 0 Then Msg = "Could Not Create PDF In memory"
Dim FIdx as Integer, StrVal, EmptyStr As String
If Msg.LenB = 0 then
call pdf.EditPage(1) ' needed for reading the fields?
Fidx = pdf.FindField("DCRID")
If Fidx < 0 then Msg= "Not A fillable DCR PDF Form"
If Msg.LenB > 0 then
Dim err as UnsupportedOperationException
Err.Message = Msg
FiledIdx is -1 and that field has to exist … I previously assigned a value to it before I wrote the file out!
So am I doing something wrong or is this rated to the issue mentioned above?