Skip to main content
Participant
Jul 29, 2022 9:41 AM UTC
Question

IAC : C# : Is it possible to get bounding box of a field as an AcroRect object ?

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

 

This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

Legend
Aug 2, 2022 9:27 AM UTC

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. 

Translate
Bernd Alheit
Community Expert
Community Expert
Jul 29, 2022 9:51 AM UTC

Try the forum for Acrobat SDK.

Translate
Participant
Aug 1, 2022 2:13 PM UTC

Isn't this the acrobat SDK forum?

Translate
Bernd Alheit
Community Expert
Community Expert
Aug 1, 2022 2:34 PM UTC

Someone has moved it.

Translate