Skip to main content
Participant
June 11, 2025
Question

FreeText Annotation not being added in New Adobe

  • June 11, 2025
  • 1 reply
  • 194 views

I have vb.net code that was adding a Text Box to my Adobe forms.  It worked prior to the new version of adobe.  I was using the following code:

Public Sub addAnnotation(commentText As String, PageNum As String, rect() As Object, editable As Boolean)
Dim annot As Object
Dim props As Object

annot = jso.addAnnot()
props = annot.getProps

props.type = "FreeText"
props.page = PageNum
props.contents = commentText
props.strokeColor = jso.Color.black
props.Rect = rect
props.name = commentText
props.readonly = editable
annot.setProps(props)
End Sub

 

After going to the newer version (I cannot go back to the older version of Adobe due to company policy) it does nothing when I run this.  I made a small change and have it assign the type of FreeText first which then gives me a rectangle on the Form, but the text doesn't display in it.

 

Public Sub addAnnotation(commentText As String, PageNum As String, rect() As Object, editable As Boolean)
Dim annot As Object
Dim props As Object

annot = jso.addAnnot()
props = annot.getProps

props.type = "FreeText"
annot.setProps(props)
props = annot.getProps
props.page = PageNum
props.contents = commentText
props.strokeColor = jso.Color.black
props.Rect = rect
props.name = commentText
props.readonly = editable
annot.setProps(props)
End Sub

 

What do I need ot chnage so I can add the type of text box threw the SDK to display the text on the form.

1 reply

Thom Parker
Community Expert
Community Expert
June 12, 2025

I would suggest two things. 

1)  Do not run a complex series of JS code directly from VB.  The VB and JS objects are different animals. The best strategy for running Acrobat JS from VB is to put as much of the JS functionality into a folder level JS function, then call that function from the VB.  This also give you the ability to test the JS before using it in a foriegn context. 

2) Do not call Add Annot with an empty argument list. Add all necessary arguments are presetnt at the time it is called. 

 

Did you check the Acrobat Console for errors?  It's likely that Acrobat is telling you the problem. 

Also, make sure the document being operated does not have security on it. 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often