Copy link to clipboard
Copied
the below script breaks every time at the this.getfield command. Rank and Abbreviated rank are list boxes. I am trying to run this InDesign and willing to push it to acrobat but dont know if that would work either.
// Get references to the required fields
var rankField = this.getField("Rank");
var firstField = this.getField("First");
var lastField = this.getField("Last");
var dutyTitleField = this.getField("Duty Title");
var unitField = this.getField("Unit");
var inputField = this.getField("input");
var decField = this.getField("dec");
var abbreviatedRankField = this.getField("Abbreviated Rank");
// Check the values of the checkboxes
var longCheckbox = this.getField("long").value;
var shortCheckbox = this.getField("short").value;
// Get the values from the input fields
var rank = rankField.valueAsString;
var first = firstField.value;
var last = lastField.value;
var dutyTitle = dutyTitleField.value;
var unit = unitField.value;
var input = inputField.value;
var abbreviatedRank = abbreviatedRankField.valueAsString;
// Build the output based on the checkbox values
var output = "";
if (longCheckbox === "Yes") {
output = rank + " " + first + " " + last + " distinguished " + (firstField.value === "female" ? "herself" : "himself") + " by meritorious service as " + dutyTitle + ", " + unit + ".";
} else if (shortCheckbox === "Yes") {
output = rank + " " + first + " " + last + " distinguished " + (firstField.value === "female" ? "herself" : "himself") + " by meritorious service while assigned to " + unit + ".";
}
// Set the value of the 'dec' field
decField.value = output;
// Build and set the closing phrase
var closingPhrase = "The distinctive accomplishments of " + abbreviatedRank + " " + last + " reflects credit upon " + (firstField.value === "female" ? "herself" : "himself") + " and the United States Air Force.";
this.getField("closingPhrase").value = closingPhrase;
Copy link to clipboard
Copied
Where is the definition of the getField method you are using? What is the value of the this object? This seems to be an incomplete set of code. Please share the complete one, only then will we be able to troubleshoot it.
-Manan
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi @Daniel308633812s5g , Your code looks like it’s using the Acrobat API—there is no getField() method in the InDesign API.
Copy link to clipboard
Copied
An InDesign document has a formFields property, which would be a collection of all formFields in a document.
This would get the active document’s form fields:
var ff = app.activeDocument.formFields.everyItem().getElements();
for (var i = 0; i < ff.length; i++){
$.writeln(ff[i].name)
//returns the name of every form field in the active document
};
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#FormField.html#d1e127934
Copy link to clipboard
Copied
Thank you!
Copy link to clipboard
Copied
You can't use the API from one app in a different app. Each one does different things, in different ways. This is for the Acrobat API only. But you can't justify text in a fillable PDF field, not by any trick; whether you made it in InDesign doesn't give more power to the PDF fields. However, it's normal to design the form in InDesign then export to PDF.
Copy link to clipboard
Copied
Thank you! sounds like I have to leave instructions for people to select the text frame, ctrl+E and select justified to get the result they need to view.. not what i wanted but seems to be the only option I have with limited experience and wanting this to be able to be a mass distrobution.
Copy link to clipboard
Copied
If you attempt a mass distribution you may have many other issues. Can you FORCE people to use suitable software - that is, Acrobat Reader on Mac or Windows? When they already have an app that can read PDF? And will you tell people on iOS and Android that they are out of luck? I think you're reaching beyond what is feasible. If you want to give people a precisely formatted PDF, you need to generate them on a server and deliver them - a very different kind of programming.
Copy link to clipboard
Copied
every one of our computers are equiped with acroboat pro 2020. im testing it on myself in that domain before pushing it up. trying to eliminate the annoying part of writing decorations/medals and it has to generate a pdf for download to preview if you have reached appropriate guidelines
Find more inspiration, events, and resources on the new Adobe Community
Explore Now