How to subtract in a calculation in Acrobat Pro 9

Community Beginner ,
Sep 08, 2008 Sep 08, 2008

Copy link to clipboard

Copied

I'm building a pdf with some calculations. I can do a 'sum, product,average,minimum,maximum'. But how do i subtract 2 fields?

Views

38.7K

Likes

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 ,
Sep 08, 2008 Sep 08, 2008

Copy link to clipboard

Copied

You will need to use JavaScript in a field's custom calculation script. For example:

// Get first field value
var v1 = getField("Text1").value;

// Get second field value
var v2 = getField("Text2").value;

// Set this field value equal to the difference
event.value = v1 - v2;

You would replace "Text1" and "Text2" with the names of the fields you've set up.

George

Likes

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
New Here ,
Nov 06, 2020 Nov 06, 2020

Copy link to clipboard

Copied

I guess I'm missing something. I can't get this to work. Here is the script that I am using.

v1 = getField("Subtotal").value;
v2 = getField("TotalDiscount").value;
TotalDue.value = v1 - v2;

 

Any help would be appreciated.

 

Jack

 

Likes

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 ,
Nov 06, 2020 Nov 06, 2020

Copy link to clipboard

Copied

Use this:

event.value = v1 - v2;

Likes

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 ,
Sep 08, 2008 Sep 08, 2008

Copy link to clipboard

Copied

I should not have said you *need* to use JavaScript, because you can also use the "simplified field notation" option, but as you come to do more than the simplest of calculations, JavaScript is what you'll need.

If you want to use the simplified field notation option, you'd enter:

Text1 - Text2


but you'd replace Text1 and Text2 above with the names of your fields.

George

Likes

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
New Here ,
Sep 15, 2022 Sep 15, 2022

Copy link to clipboard

Copied

LATEST

I was unable to subtract using the guidance you provided. Do I need to add an equal sign or something?

Likes

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 Beginner ,
Sep 08, 2008 Sep 08, 2008

Copy link to clipboard

Copied

your the best, gonna try it out!

Likes

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 Beginner ,
Sep 08, 2008 Sep 08, 2008

Copy link to clipboard

Copied

works!

Likes

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
New Here ,
Mar 18, 2009 Mar 18, 2009

Copy link to clipboard

Copied

George - thank you so much! I didn't ask the question, but I certainly benefited from your assistance. Thanks so much! -dave

Likes

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
New Here ,
Mar 20, 2009 Mar 20, 2009

Copy link to clipboard

Copied

How would you write this if you were wanting to subtract dates? I'm using Acrobat 9 as well. Thank you!

Likes

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

Make content for your business needs with Adobe Express.

Get started easily with free templates: