Copy link to clipboard
Copied
I want to populate a richtext form field with a formatted string compiled by a vb.net app.
Dim pdDoc As New Acrobat.AcroPDDoc
pdDoc.Open("my.PDF")
Dim jso = pdDoc.GetJSObject
Dim myFld = jso.getField("MyFld")
Dim mySpans = myFld.richValue
Assuming that myField.value is "This is MY field", with "MY" in bold,
I get back 5 spans: "This is"," ","MY"," ","field", the fontWeight on all is 400 except for "MY" which is 700
I change mySpans(2).text from "MY" to "YOUR", and write the spans back:
myFld.richVale = mySpans
expecting to see "This is YOUR field", but I don't
Am I missing something here, or can I just not do it this way?
Had lots of experience setting value, font and sizes on fields - which I managed to decipher from "JavaScript for Acrobat API Reference", but not this...
The examples I've found all refer to Java - nothing for VB (or even C#, which might have helped).
Any help much appreciated.
Thanks
Dave
Copy link to clipboard
Copied
Is richVale a typo only in the post?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Besides the typo Try pointed out. Spans are a type of JavaScript Object. JS objects and VB objects are different things and don't translate well. This is one of the more restrictive issues with the JSO. The best solution is to only transfer scalar, string, and simple array values between JS and VB.
The solution to dealing with this issue is to develop a set of folder level functions that preform the heavy lifting on the JS side. Then call these functions from VB. This is also more efficient, because all the JS stuff is being done in the JS world
Another major advantage of this approach is that you can test your methodology for modifying rich text on Acrobat without the added complication of VB.
Copy link to clipboard
Copied
Suppose I need to get my head round Java then.
Thanks.
Copy link to clipboard
Copied
Info: Acrobat uses JavaScript, not Java.
Copy link to clipboard
Copied
As far as programming languages go, JavaScript is much better than VB. Do all your initial development in Acrobat Using JavaScript. When you have the functionality you want worked out, then go back to VB.