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

Display label instead of code

Explorer ,
Apr 23, 2021 Apr 23, 2021

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
2.3K
Translate
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
2 ACCEPTED SOLUTIONS
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'.

View solution in original post

Translate
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

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 Photoshoptographe

View solution in original post

Translate
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 23, 2021 Apr 23, 2021

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

 

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


Acrobate du PDF, InDesigner et Photoshoptographe
Translate
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

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

Translate
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

Can you share your file or a sample?

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


Acrobate du PDF, InDesigner et Photoshoptographe
Translate
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

@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

Translate
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

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

Translate
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

@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

Translate
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

Did you put script as document level script?

 

Translate
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

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 Photoshoptographe
Translate
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

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

 

 

Translate
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

Attached a screenshot from my Acrobat.

 

Thanks

Simone

Translate
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

"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 Photoshoptographe
Translate
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

@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

Translate
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

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

😉

 

Capture_366.pngexpand image


Acrobate du PDF, InDesigner et Photoshoptographe
Translate
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

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

javascript.pngexpand image

Translate
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

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.pngexpand image


Acrobate du PDF, InDesigner et Photoshoptographe
Translate
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
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!

Translate
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