DynaPDF RadioButtons Issue


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)
  End if

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.

  • Karen

DynaPDF documentation comes primary in C, although I copy more and more of it into my own documentation over time.

SetFieldExpValueEx is the function to use as far as I know.

call pdf.SetFieldExpValueEx(child.handle, 2, true, false)

so you set one of the children to be selected.

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)

Replacing my code with:

FIdx = pdf.FindField("ReqType")
Field =  pdf.GetFieldEx(FIdx)
Call pdf.SetFieldExpValueEx(Field.handle, ReqTypePM.ListIndex, true, false)

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)?


I’ll ask Jens how it should be.

By the way, FIdx and Field.handle should be the same, so no need to query Field.handle.

If you like, you could send me the PDF to try myself here.

Jens told me to use SetCheckBoxState for this.

If you can’t get it to work, please send me copy of PDF, so I can look into.

There is a lot that can be weird about how people build PDFs, so it is easy to grab the wrong handle.

I was unsure of which Email address to use…


Moderator edit: email address removed.

I emailed you back since you sent it to the mailing list.
Please send again to me.

Oops… I hope that did not go out to everyone!

Sent to you just now.


Thanks for the PDF.
It’s a bit special and has empty values, so when we set it, you see nothing.

The next version of DynaPDF in a few days will fix that automatically and put in a checkbox, just like other apps do it. So thanks for reporting this kind of issue.

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"
  call pdf.SetImportFlags(pdf.kifImportAsPage) 
  If  pdf.ImportPDFFile(1,1.0,1.0) < 0 Then Msg =  "Could Not Create PDF In memory"
End if
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"
End if

If Msg.LenB > 0 then
  Dim err as UnsupportedOperationException
  Err.Message = Msg
  Raise err
End if

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?


First thing I see is that you miss flags to SetImportFlags.

// set flags to import all
Dim flags As Integer = Bitwise.BitOr(pdf.kifImportAsPage, pdf.kifImportAll)
Call pdf.SetImportFlags(flags)

If you don’t pass either all or add the flag for form fields, the fields are skipped.

Thanks, that works!


1 Like