Map (spot and process) colors using script variables

Introduction

When you want to configure the Fixups "Map colors" and "Map spot and process colors" via JavaScript you face some problems, mainly that you can't add additional settings via JavaScript (in the UI you would use the [+] button) and that you have to predefine variable for all dynamic fields.

pdfToolbox 11 introduces two new Fixups: "Map colors using script variables" and "Map spot and process colors using script variables" that are configured with a single JSON object.

Usually you will assign a variable to it (via the orange triangle as usual) and create the value of the variable as a JSON structure according to the example in the UI.

Possible values in the JSON structure

Map spot and process colors using script variables

Name Possible values Corresponds to
("Map spot and process colors")
source

operator 1
2
3
4
matches with RegEx
does not match with RegEx
equal to
unequal to
name
<any proper string>
ignorecase true
false

keepalternatecolor true
false

destination

operation ConvertToCMYK
MapOrRename
KeepName
ConvertToDestination
Convert to CMYK
Map or rename
Change alternate color
Convert to destination
model Automatic
CMYKPercent
CMYKZeroToOne
GrayPercent
GrayZeroToOne
Lab
RGBPercent
RGBZeroTo255
RGBZeroToOne
Use source color
CMYK (%)
CMYK (0.0...1.0)
Gray (%)
Gray (0.0...1.0) 0.0 is black
Lab (0...100,-128...127,-128...127)
RGB (%)
RGB (0...255)
RGB (0.0...1.0)
name <any proper string>

value array of numbers, length according to color space

overprint On
Off
Unchanged

applyto None
Images
VectorAndText
None
All images
All vector and text objects

Map colors using script variables

Name Possible values Corresponds to
("Map colors")
source

model CMYKPercent
CMYKZeroToOne
GrayPercent
GrayZeroToOne
RGBPercent
RGBZeroTo255
RGBZeroToOne
CMYK (%)
CMYK (0.0...1.0)
Gray (%)
Gray (0.0...1.0) 0.0 is black
RGB (%)
RGB (0...255)
RGB (0.0...1.0)
value array of numbers, length according to color space
tolerance number
intermediate true
false

destination

model Automatic
CMYKPercent
CMYKZeroToOne
GrayPercent
GrayZeroToOne
RGBPercent
RGBZeroTo255
RGBZeroToOne
Use source color
CMYK (%)
CMYK (0.0...1.0)
Gray (%)
Gray (0.0...1.0) 0.0 is black
RGB (%)
RGB (0...255)
RGB (0.0...1.0)
value array of numbers, length according to color space

applyto None
Images
VectorAndText
None
All images
All vector and text objects
spotcolor

create
true
false

name <any proper string>
tintvalue number

overprint On
Off
Unchanged

keepalternatecolor true
false

Example: Convert colors using wildcards

To give an example we have created a Fixup to convert colors which allows for using a "wildcard" in one colorant. That means you could convert e.g. all colors using C50 M50 and K50 to something else, keeping all Y values as they are.

This PDF has a number of color patches, all using C75, M50, K0 and varying values for Y.

If you apply the Fixup and enter C75, M50, K0 for the input values of the respective colorants and a "?" (wildcard) for Y you can convert C,M and K to whatever values you enter (the output value for Y does not matter, the original values will be kept).

In this example we have used C0, M95, K10 for output.

One more thing:

You may as well use more than one wildcard ("?"). The problem is that it will then process much longer, in one test that we made it took roughly 30 minutes. So you should only do so if you have time...