Copy link to clipboard
Copied
I have a little over a 1,000 PDFs, with each specific PDF representing a Pantone C spot color. In these PDFs there are boxes that are filled with a custom spot color that needs to be replaced with a corresponding Pantone C swatch color...
I've done a lot of searching on the subject but haven't been able to find a good answer. I know no matter what it is going to require a lot of legwork but as of now typing out the 1,000 some spot color names into a script would be incredibly faster than the alternative.
Does anyone know of a script that could get me started on it?
Assure all you PDF file's structure are the same as the sample, open one PDF file and run this code.
...(function () {
var doc = activeDocument,
s = doc.swatches[2];
s.name = activeDocument.name.replace(/\.pdf$/, '');
s.color.spot.color = LABColorByValue ();
function LABColorByValue () {
var t = doc.textFrames,
l = t.length,
i = l - 1,
c = new LabColor(),
m;
for (; i >= 0; i--) {
m = t.contents.match(/Target: L = (\d*) a\* = (-?\d*) b\* = (-?\d*)/);
if
Copy link to clipboard
Copied
More infos please, a sample document is even better. The script is just somewhere, like waters in the deep dark sea.
Copy link to clipboard
Copied
Heres a link to a sample document: https://www.dropbox.com/s/e26fzp5jzpedf2h/PANTONE%207436%20C.pdf?dl=0
The green boxes below is where the swatch replacement would occur.
Copy link to clipboard
Copied
Is the corresponding PANTONE color the one mentioned in the text box? You'll need to create a document with all of the PANTONE colors inside it so that you could reference the swatches, or store them in a text file- which is legally sketchy territory when considering the PANTONE corporation's usage agreement.
So if that pantone's name is correct and if you have a document source for the pantone spot swatches or spreadsheet data with all the correct Lab values, you can do what you need.
Copy link to clipboard
Copied
Assure all you PDF file's structure are the same as the sample, open one PDF file and run this code.
(function () {
var doc = activeDocument,
s = doc.swatches[2];
s.name = activeDocument.name.replace(/\.pdf$/, '');
s.color.spot.color = LABColorByValue ();
function LABColorByValue () {
var t = doc.textFrames,
l = t.length,
i = l - 1,
c = new LabColor(),
m;
for (; i >= 0; i--) {
m = t.contents.match(/Target: L = (\d*) a\* = (-?\d*) b\* = (-?\d*)/);
if (m) {
c.l = m[1], c.a = m[2], c.b = m[3];
return c
}
}
}
})()
You can record an action, which insert this script as menu item, to process you files.
Copy link to clipboard
Copied
Wow, that worked perfectly! I was honestly expecting a lot more I would have to do but didn't think it would be able to match it to the file name, an elegant solution. Thank you!
Although when I run it as a batch script I get Error 8701: the name was not found. Line: 4. -> s.name = activeDocument.name.replace(/\.pdf$/, ");
Copy link to clipboard
Copied
Oh that Target Lab was the color's Lab values? I missed that detail! Hehh heh heh.