How to get field's coordinates with the script rule?

Question

I need to export field's coordinates. How do I do it if the export format is not XML.

Answer

  • In Document Definition create a custom text field, i.e. Total Coordinates


  • ​In its properties > Rules create a script rule, i.e.
  • Add Total field into the rule as well, and make sure Total Coordinates is not read only as it will be modified:
  • ​​This is the sample script that will get the Total field surrounding rectangle coordinates and write them into the Total Coordinates field:
if (Context.Field("Total").IsMatched)
{
    Context.Field("Total Coordinates").Text = Context.Field("Total").Regions[0].SurroundingRect.Bottom.ToString() + ", " + Context.Field("Total").Regions[0].SurroundingRect.Left.ToString() +
    ", " + Context.Field("Total").Regions[0].SurroundingRect.Right.ToString() + ", " + Context.Field("Total").Regions[0].SurroundingRect.Top.ToString();
}

  • It will return something like that:
  • After that export that field into the data file together with other fields.​
  • It is possible to get coordinates of other fields as well the same way. However, for repeatable fields, iterate through every region as the field may have more than 1 instance.

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.