|Language:||English, Spanish, Portuguese|
|Distribution:||Free* [*Registration needed]|
There may be typos, please use the "Edit on Github" link in left sidebar in an article, at the bottom to propose fixes.
Conditional operators: Logical operators. The "switch" statement.
Advanced working with functions. Rest parameters and spread operator. Function object, NFE. The "new Function" syntax. Currying and partials. Arrow functions revisited. Object properties configuration.
Property flags and descriptors. Property getters and setters. Prototypes, inheritance. Prototypal inheritance. Native prototypes. Getting all properties. Class inheritance. Static properties and methods. Private and protected properties and methods. Extending build-in classes. Class checking: Error handling. Error handling, "try.. Custom errors, extending Error. Promises chaining. Error handling with promises. Microtasks and event loop.
Assuming the current document has a field with the correct name on it, the following code displays the raw color value in the Console Window: this. Remember, Acrobat attempts to convert all results into text. Arrays are converted to text by converting each individual array element into a text string, so the result would look something like the following line when it is displayed in the Console Window. We've just found out something that would have taken us just a little more effort to find out using the Acrobat property dialogs, and the information is in a very usable format.
We can easily copy and paste this information to accomplish some other purpose, for example applying the color to another field with this line of code: this. Suppose a document needs to be checked for branding purposes, i. It has to be done all at once. Notice that in the loop there is a function called console. It's in the fourth line. This function writes text to the Console Window and it will be discussed in the next section.
Here's an example of a function that does not have an easy equivalent on the regular Acrobat menus and toolbars. Enter the following line into the Console Window and run it: app.
This is perfect for trying out new ideas before applying them to a working document. The results of this operation are shown in Figure 7 below. Note that yet again, the result is something different. The Console Window has to convert the result of code execution to text before it can be displayed. Not everything has an obviously meaningful text representation. In this case, the output of the function is a Document Object. Objects are converted to text by simply converting their type information to a string.
The result shown in Figure 7 tells us the type of object created. This result is only useful in letting us know the function worked. If app. Both of these situations would have been displayed in the Console Window.
Enter and run the following line of code: this. It's the folder path of the current document. Since the current document was just created with app. The advantage to using the Console Window is to make this information available to copy to the system clipboard for use with another script in Acrobat or for something else.
Enter and run the following line of code in the Console Window: app. Acrobat responds by generating an error, which is displayed by the Console Window, shown in Figure 8. This message is critical to understanding why the code failed, especially if the function call is buried in several lines of code inside another script.
Always check the Console Window first when something goes wrong. Note that the second message on the line indicates a security error. For our purposes, this is an erroneous and unhelpful message.
This object provides a few functions for manipulating and accessing the Console Window, but for our purposes here the console. This function displays a single line of text on the next available line in the Console Window. The following line of code displays the words "Hello Acrobat. Just place a few console. It is up to the developer to decide what information to display. This information should be relevant to the state of the script.