Is it possible to get bounding box of a field as an AcroRect object ?
CAcroApp acroApp = new AcroAppClass();
CAcroAVDoc avDoc = new AcroAVDocClass();
CAcroRect acroRect = new AcroRectClass();
CAcroPDDoc pDDoc = new AcroPDDocClass();
if (!avDoc.Open(sample_pdf, ""))
return;
else
pDDoc = (CAcroPDDoc)avDoc.GetPDDoc();
IAFormApp formApp = new AFormAppClass();
IFields myFields = (IFields)formApp.Fields;
IEnumerator myEnumerator = myFields.GetEnumerator();
while (myEnumerator.MoveNext())
{
IField myField = (IField)myEnumerator.Current;
string fieldName = myField.Name;
string fieldType = myField.Type;
}
I need to replace myField of type checkbox to a text field of same size at same location. I can remove checkbox by
while (myEnumerator.MoveNext())
{
IField myField = (IField)myEnumerator.Current;
string fieldName = myField.Name;
string fieldType = myField.Type;
//Remove Checkbox field type
if(fieldType=="checkbox")
myFields.Remove(fieldName);
}
How can I add a text type field in the same position of checkbox ?
if(fieldType=="checkbox")
{
//Remove Checkbox field type
myFields.Remove(fieldName);
//Add text field type
myFields.Add(fieldName, "text", 0, acroRect.Left, acroRect.Top, acroRect.right, acroRect.bottom); // how to get acroRect object of a field ??
}
Copy link to clipboard
Copied
Try the forum for Acrobat SDK.
Isn't this the acrobat SDK forum?
Copy link to clipboard
Copied
Someone has moved it.
Copy link to clipboard
Copied
The APIs you are using were frozen some 20 years ago, and you need to be looking at the JavaScript methods. The Field object in JavaScript does have a "rect" property. Caution: a field may appear in multiple positions with the same name, and you need to code to at least take that into account. The discussion of the Field object shows how to distinguish.