[Tool] Display Area/Perimeter/Length Measurements, and/or Export to Form Fields  SOLVED

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

Mathew
User
Posts: 734
Joined: Thu Jun 19, 2014 7:30 pm

[Tool] Display Area/Perimeter/Length Measurements, and/or Export to Form Fields  SOLVED

Post by Mathew »

This tool can add a text 'tag' that displays the value for measurement annotations; it will also output the value to a form field. It works on Distance, Perimeter and Area measurement markups.

Installation
Download and extract the zip file, and copy to %APPDATA%\Tracker Software\PDFXEditor\3.0\Javascripts
Detailed instructions in post viewtopic.php?p=196006#p196006
measurementText v1.1.zip

Usage
The tool adds a button to the Add-Ons toolbar:
image.png
Select all the measurements to add a text tag to, then run the tool. It will add a text 'tag' (label) with the measurement at the center of the area:
image(1).png
The tag can be moved/formatted as needed. If you change the measurement markup, you can select the measurement and run the tool again and it will update the tag:
image(2).png
Form Output
The tool can also output the area to form fields. Once a form field is linked to an area, the tool will not add new ltags, so if you want area tags also, first run the tool on the measurements to add the tags, then link to form fields.

To link a form field, copy the Name of the area,
image(3).png
and paste it as the Field Name for a Text Field. If you want, add a more descriptive name to the Tooltip:
image(4).png
Then select all the areas and run the tool. It will copy the areas to the linked form fields. I've added a calculated form field at the bottom that sums all the areas (PDF XChange is smart enough to recognize the numbers, so isn't thrown off by the units):
image(5).png
The form fields do not have to be on the same page as the measurements, but watch out: If measurement markup names are duplicated on other pages (ie by copy-paste of the markup), they will also update the same field.

Compatibility
[edit] I just realized that .inReplyTo property has been supported all the way back to PXCE 9.5, so if you CTRL-drag to copy an area, it will duplicate the tag with it. So, if you've made a special formatting for one tag, you can CTRL-drag to copy that measurement and it will copy the formatted tag along with it. Feels very "built-in".
measure tag duplicate.gif

Limitations
  • The tool is adding a text box annotation, and setting the inReplyTo attribute to link it to the measurement. If you delete the measurement, it will also delete the text box.
  • The text box can be edited just like any other markup. The script uses a regular expression to try to just change the dimension when updating, but may get confused if you add a number followed by text.
  • If there's a label on the measurement, it will get copied to the text box, and will always be on a separate line, because the tool is copying the contents of the measurement:
    image(6).png
You do not have the required permissions to view the files attached to this post.
Last edited by Mathew on Fri Dec 05, 2025 12:47 am, edited 7 times in total.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12216
Joined: Wed Jan 03, 2018 6:52 pm

Re: [Tool] Display Area/Perimeter/Length Measurements, and/or Export to Form Fields

Post by Daniel - PDF-XChange »

Hello, Mathew

Thank you for the script, this looks very handy!

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
ShapePresidentReliable
User
Posts: 6
Joined: Fri Oct 04, 2024 3:46 am

Re: [Tool] Display Area/Perimeter/Length Measurements, and/or Export to Form Fields

Post by ShapePresidentReliable »

This is awesome! Thanks heaps.
Mathew
User
Posts: 734
Joined: Thu Jun 19, 2014 7:30 pm

Re: [Tool] Display Area/Perimeter/Length Measurements, and/or Export to Form Fields

Post by Mathew »

:) ... and I found a bug: If a measurement had a label, that would also get inserted into the field and prevented it being recognized as a number. Fixed in v1.1 below and in the original post.

Changes v1.1
  • only export measurement to form field (skip label)
measurementText v1.1.zip
You do not have the required permissions to view the files attached to this post.
User avatar
Sean - PDF-XChange
Site Admin
Posts: 629
Joined: Wed Sep 14, 2016 5:42 pm

Re: [Tool] Display Area/Perimeter/Length Measurements, and/or Export to Form Fields

Post by Sean - PDF-XChange »

:)
Sean Godley
Technical Writer
PDF-XChange Co LTD
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623
PDFan
User
Posts: 17
Joined: Tue Jan 07, 2025 1:54 pm

Re: [Tool] Display Area/Perimeter/Length Measurements, and/or Export to Form Fields

Post by PDFan »

Hello Mathew,

this tool is exactly that what I have wished. Great Job! Thank you!
Mathew
User
Posts: 734
Joined: Thu Jun 19, 2014 7:30 pm

Re: [Tool] Display Area/Perimeter/Length Measurements, and/or Export to Form Fields

Post by Mathew »

PDFan wrote: Wed Dec 03, 2025 6:35 pm Hello Mathew,

this tool is exactly that what I have wished. Great Job! Thank you!
:D
User avatar
Sean - PDF-XChange
Site Admin
Posts: 629
Joined: Wed Sep 14, 2016 5:42 pm

Re: [Tool] Display Area/Perimeter/Length Measurements, and/or Export to Form Fields

Post by Sean - PDF-XChange »

:)
Sean Godley
Technical Writer
PDF-XChange Co LTD
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623