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
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'.
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
Acrobate du PDF, InDesigner et Photoshoptographe
Copy link to clipboard
Copied
Place this script as a "Validation script" in the "item" field:
event.value = "Label" + event.value;
Acrobate du PDF, InDesigner et Photoshoptographe
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
Copy link to clipboard
Copied
Can you share your file or a sample?
(https://helpx.adobe.com/acrobat/using/sharing-pdfs.html)
Acrobate du PDF, InDesigner et Photoshoptographe
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
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'.
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
Copy link to clipboard
Copied
Did you put script as document level script?
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
Acrobate du PDF, InDesigner et Photoshoptographe
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
Copy link to clipboard
Copied
Attached a screenshot from my Acrobat.
Thanks
Simone
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).
Acrobate du PDF, InDesigner et Photoshoptographe
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
Copy link to clipboard
Copied
Sorry, I didn't understand correctly, it's true that Acrobat's UI has changed since this tutorial:
😉
Acrobate du PDF, InDesigner et Photoshoptographe
Copy link to clipboard
Copied
That's my issue. In my Adobe Acrobat XI I cannot access that action.
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:
Acrobate du PDF, InDesigner et Photoshoptographe
Copy link to clipboard
Copied
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!

