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

Document level Javascript - Change colour based on new value entered?

New Here ,
Dec 14, 2018 Dec 14, 2018

Copy link to clipboard

Copied

I am working on project were we will be generating a fillable PDF questionnaire that will be populated with data from our servers, the remaining missing information will need to be completed by the end user; however, we would like to be able to track what fields the end user is changing or inputting new information. Is there a way to allow us to track any changes that are made after the PDF is generated with the partially completed data?

We are flexible with regards to how we display the changes. Open to suggestions.

I was thinking of having a document level Javascript that we can turn on once the PDF is generated, via a button, that would change the text colour to red or green while keeping the existing text black, unless it is overridden.

TOPICS
PDF forms

Views

717

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

correct answers 1 Correct answer

Community Expert , Dec 14, 2018 Dec 14, 2018

One easy way is to have your server app also populate the "Default" value of each field. That way a script simply compares the current value to the default to determine a difference. And that script could also highlight the changed fields with a color change.

var strFieldName = ...

var oFld  = this.getField(strFieldName);

if(oFld.value != oFld.defaultValue)

    oFld.fillColor = color.red;

Votes

Translate

Translate
Community Expert ,
Dec 14, 2018 Dec 14, 2018

Copy link to clipboard

Copied

One easy way is to have your server app also populate the "Default" value of each field. That way a script simply compares the current value to the default to determine a difference. And that script could also highlight the changed fields with a color change.

var strFieldName = ...

var oFld  = this.getField(strFieldName);

if(oFld.value != oFld.defaultValue)

    oFld.fillColor = color.red;

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
New Here ,
Dec 18, 2018 Dec 18, 2018

Copy link to clipboard

Copied

Was speaking with my developers and they don't seem to be able to populate the value as "default". Any chance that you can provide some insight on how we can set the value as default in the PDF generator. We are using Poppler to fill the PDF and PDFtk to stitch the document together.

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
New Here ,
Feb 08, 2019 Feb 08, 2019

Copy link to clipboard

Copied

LATEST

The code works perfectly, however, i need to highlight the field to get the color to change to red. Would there be an option to run this script on a document level rather than a field level and have the color change reflect permanently?

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