Can I add a spot colour to a PDF in Acrobat using JavaScript?

50 Views Asked by At

I'm attempting to write a script that will add a box to the trim area of every page of a PDF using JavaScript. The box needs to be a spot colour with a specific name. I've got it working as a process colour, but can't seem to set it as a spot colour.

This is what I have that sets a 100% cyan box as a process colour:

function addCutContourBoxOnEveryPage() {
    try {
        var numPages = this.numPages;

        for (var i = 0; i < numPages; i++) {
            var trimBox = this.getPageBox("Trim", i);

            var x = trimBox[0];
            var y = trimBox[1];
            var width = trimBox[2] - trimBox[0];
            var height = trimBox[3] - trimBox[1];

            var rect = this.addAnnot({
                type: "Square",
                page: i,
                rect: [x, y, x + width, y + height],
                strokeColor: ["CMYK", 100, 0, 0, 0],
                lineWidth: 0.1,
                fillColor: ["T", [0, 0, 0, 0]],
                author: "Spot_Colour_Name"
            });
        }

        this.dirty = true;
    } catch (e) {
        console.println("Error adding cut contour box: " + e);
    }
}

addCutContourBoxOnEveryPage();

1

There are 1 best solutions below

2
iPDFdev On

Per PDF specification the stroke/fill colors can be only RGB, CMYK or Gray.

What you can do is to create a square annotation with a custom appearance. In the custom appearance you draw the square using any colors you want, including spot colors. But I do no know if you can do this using Acrobat JavaScript.