• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Jul 29, 2022 Jul 29, 2022

Copy link to clipboard

Copied

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

 

Views

347

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 29, 2022 Jul 29, 2022

Copy link to clipboard

Copied

Try the forum for Acrobat SDK.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Aug 01, 2022 Aug 01, 2022

Copy link to clipboard

Copied

Isn't this the acrobat SDK forum?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 01, 2022 Aug 01, 2022

Copy link to clipboard

Copied

Someone has moved it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 02, 2022 Aug 02, 2022

Copy link to clipboard

Copied

LATEST

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines