Skip to main content
Simone Ceccolini
Known Participant
April 23, 2021
Answered

Display label instead of code

  • April 23, 2021
  • 6 replies
  • 2690 views

Hi all,

 

I have an application that generates PDF from a pre-defined template. I'd like to configure these templates in a way that, for some fields, the PDF displays the field label instead of its code, considering I can configure all the possible value/codes in the template.

 

As an example, the 'item' field can assume values '000' or '001'. Instead of displaying '000' or '001' in the PDF, I'd like to display the corresponding labels 'Label000' or 'Label001'. Is there a way to configure the 'item' field with this mapping in order to always display the label even though I assign the code?

 

Thank you

Simone

This topic has been closed for replies.
Correct answer JR Boulay

So you just have to add this script as a Document Level script:

this.calculateNow();

 

The OK document is here: https://documentcloud.adobe.com/link/track?uri=urn:aaid:scds:US:0b64c907-cce9-4a4a-b3dd-17248c25aaf4

6 replies

JR Boulay
Community Expert
Community Expert
April 27, 2021

It should be here in Acrobat Pro, so I guess you're using Acrobat Standard.

As workarounds you can:

- use this free tool: http://khkonsulting.com/2014/10/document-level-scripts-acrobat-standard/

- place the script as a "Page Open" action:

 

Acrobate du PDF, InDesigner et Photoshopographe
Simone Ceccolini
Known Participant
April 28, 2021

Thanks @JR Boulay @Nesa Nurani , I've modified the fields definition and, thanks to JR, added the calculcateNow() function. Now it's working, thanks again!

JR Boulay
Community Expert
Community Expert
April 27, 2021

Sorry, I didn't understand correctly, it's true that Acrobat's UI has changed since this tutorial:

😉

 

Acrobate du PDF, InDesigner et Photoshopographe
Simone Ceccolini
Known Participant
April 27, 2021

That's my issue. In my Adobe Acrobat XI I cannot access that action.

JR Boulay
Community Expert
Community Expert
April 27, 2021

"So you just have to add this script as a Document Level script:"

 

You should click this link that lands to a tuto who answers your questions (copy-paste the URL in Google Translate if you can't read English).

Acrobate du PDF, InDesigner et Photoshopographe
Simone Ceccolini
Known Participant
April 27, 2021

@JR Boulay my question comes from the tutorial, where it's specified the document-level script can be modified from the Javascript tool. However, if you see my screenshot and my commands above, I cannot access it. I see document-level script when clicking on 'Edit all', but I cannot save any modification.

 

Thanks

Simone

JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
April 27, 2021

So you just have to add this script as a Document Level script:

this.calculateNow();

 

The OK document is here: https://documentcloud.adobe.com/link/track?uri=urn:aaid:scds:US:0b64c907-cce9-4a4a-b3dd-17248c25aaf4

Acrobate du PDF, InDesigner et Photoshopographe
Simone Ceccolini
Known Participant
April 27, 2021

Hi all,

 

@JR Boulay  from the uploaded example I can see you put the calculateNow() function at document level. I can see that function only if I go to 'Javascript -> Set Document Actions -> Edit all'. In my document, if I click on the above button I can access the entire Javascript document, but saving that Javascript by adding the following portion is not saved on the document.

 

//<Document-Level>
//<ACRO_source>init</ACRO_source>
//<ACRO_script>
/*********** belongs to: Document-Level:init ***********/
this.calculateNow();
//</ACRO_script>
//</Document-Level>

 

Is there another way to add this function?

 

Thanks again

Simone

 

 

Simone Ceccolini
Known Participant
April 27, 2021

Attached a screenshot from my Acrobat.

 

Thanks

Simone

JR Boulay
Community Expert
Community Expert
April 26, 2021

Can you share your file or a sample?

(https://helpx.adobe.com/acrobat/using/sharing-pdfs.html)

Acrobate du PDF, InDesigner et Photoshopographe
Simone Ceccolini
Known Participant
April 27, 2021

@JR Boulay , attached you can find a portion of the document.

 

From my application, I am creating documents where the 'Discipline' field is populated with codes. Based on the assigned code, I'd like that the PDF displays its label.

 

I tried to configure that field with the following calculation:

if (event.target.value.indexOf('AUT') != -1) 
{event.value = 'AUT - Автоматизация';};

if (event.target.value.indexOf('BLD') != -1) 
{event.value = 'BLD - Здания';};

but above calculation is not performed if the value is already assigned on the generated PDF.

 

Thank you

Simone

Nesa Nurani
Community Expert
Community Expert
April 27, 2021

If you want it to be changed when open file use script at document level, in that case change 'event.target' to correct field name 'this.getField("spm_discipline").value'.

JR Boulay
Community Expert
Community Expert
April 23, 2021

Place this script as a "Validation script" in the "item" field:

 

event.value = "Label" + event.value;

Acrobate du PDF, InDesigner et Photoshopographe
Simone Ceccolini
Known Participant
April 26, 2021

Hi @JR Boulay thanks for the reply. In my case, I can have multiple codes in the same field, meaning 'Label' cannot be static but I have to put as many labels as the supported codes. How can I do that?

 

Thanks

Simone