Referencing resources in arbitrary JavaScript controlled Fixups

Fixups may use resources, such as ICC profiles or - most importantly - Checks that are used as filters. In order to use such resources in the JavaScript structure of a Fixup they have to be listed in the second input field of the Fixup.

Desktop

If you are using the method 3. "Insert configured Fixup" described in Arbitrary JavaScript controlled Fixups all configured resources are automatically added. However, even then you may want to add more resources. That is when you want to change what resources are used during runtime. You may for instance want to change the destination ICC profile of a color conversion during runtime via JavaScript. You could then put all ICC profiles that may be used into the "icc_profiles" section of the list and can then reference any of them in the JavaScript.

Adding resources

In order to add any item to the list of resources you would again use the blue info button.

Using Checks for filters

A special case are Checks that can be used in an "Apply to" filter. We use an example to demonstrate how that can be done.

This Fixup places some text on the first page of a PDF file.

When you create a new Fixup based on "Arbitrary JavaScript controlled Fixups" and import this configured Fixup via the blue info button you see this structure:

Desktop

The Check for "Page 1" is automatically added to the Script resources and in the params section there is an entry "apply_to" that references that resource. If you would have more than one Check in the resources you could select the one you want to use in your JS code.

The "isCheck" parameter serves a very special use case: It should almost always be "true". Only if the filter of the Fixup has predefined values (e.g. "All" or "Images") it may be set to "false".

Explanation: If there is a string in "value" that means it is not a JavaScript structure (as explained here). It could then either be a Check in the resources of the JS based Fixup or it could be such a predefined value. In the latter case you would tell the engine by setting "isCheck" to "false" that the value should be treated as a value rather than a Check name.

But you can be even more dynamic, you could as well define the whole "Apply to" Check using JavaScript. Read Using JavaScript in an (apply to) filter in order to find out how.