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

Display label instead of code

Explorer ,
Apr 23, 2021 Apr 23, 2021

Copy link to clipboard

Copied

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

TOPICS
Create PDFs , PDF forms

Views

1.4K

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 2 Correct answers

Community Expert , Apr 27, 2021 Apr 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'.

Votes

Translate

Translate
Community Expert , Apr 27, 2021 Apr 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

Votes

Translate

Translate
Community Expert ,
Apr 23, 2021 Apr 23, 2021

Copy link to clipboard

Copied

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

 

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

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
Explorer ,
Apr 26, 2021 Apr 26, 2021

Copy link to clipboard

Copied

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

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
Community Expert ,
Apr 26, 2021 Apr 26, 2021

Copy link to clipboard

Copied

Can you share your file or a sample?

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

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
Explorer ,
Apr 26, 2021 Apr 26, 2021

Copy link to clipboard

Copied

@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

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
Community Expert ,
Apr 27, 2021 Apr 27, 2021

Copy link to clipboard

Copied

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'.

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
Explorer ,
Apr 27, 2021 Apr 27, 2021

Copy link to clipboard

Copied

@Nesa Nurani , even with this.getField("spm_discipline").value, it's not working. Please consider the PDF is generated with that code as read-only field, but opening the PDF isn't changing the value according to the custom calculation script.

 

If I edit the generated PDF and simulate a modification of the calculation script on that field, the value is updated.

 

Thanks for your patience

Simone

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
Community Expert ,
Apr 27, 2021 Apr 27, 2021

Copy link to clipboard

Copied

Did you put script as document level script?

 

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
Community Expert ,
Apr 27, 2021 Apr 27, 2021

Copy link to clipboard

Copied

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

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
Explorer ,
Apr 27, 2021 Apr 27, 2021

Copy link to clipboard

Copied

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

 

 

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
Explorer ,
Apr 27, 2021 Apr 27, 2021

Copy link to clipboard

Copied

Attached a screenshot from my Acrobat.

 

Thanks

Simone

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
Community Expert ,
Apr 27, 2021 Apr 27, 2021

Copy link to clipboard

Copied

"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).

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
Explorer ,
Apr 27, 2021 Apr 27, 2021

Copy link to clipboard

Copied

@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

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
Community Expert ,
Apr 27, 2021 Apr 27, 2021

Copy link to clipboard

Copied

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

😉

 

Capture_366.png

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
Explorer ,
Apr 27, 2021 Apr 27, 2021

Copy link to clipboard

Copied

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

javascript.png

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
Community Expert ,
Apr 27, 2021 Apr 27, 2021

Copy link to clipboard

Copied

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:

 

Capture_370.png

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
Explorer ,
Apr 28, 2021 Apr 28, 2021

Copy link to clipboard

Copied

LATEST

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!

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