Rasterize to clipping boundary
Hi,
I have an issue that I can not find an explanation to, and if I did... Than I could understand a solution for my problem.
I have a file that has 9 seperate artboards, all identical, with 9 layers (1per artboard). Each AB has 1 clipping mask, with a pattern behind it.
(Yes it's a vector,
No, I am not going to trim it in pathfinder)
I can manually select each design, on any artboard, and manually (object-rasterise) my design, and the output will clip all of the design to the clipping mask boundary.
Perfect... What I want.
Here in lies the issue, when I run a script (pasted below), it all works, much in the same way, and all 9 artboards a separlety rasterised, however in the output, each one is now rasterised to the internal artwork boundary within the clipping mask, leaving a large transparent box.
Now... Why can I do them one by one manually, but not through my script below?
I seem to have all the details needed as shown in the dialogue box for 2022.
var Rasterizer = function (resolution) {
this.doc = app.activeDocument;
this.selection = this.doc.selection;
this.options = new RasterizeOptions();
this.options.resolution = resolution || 72;
this.options.transparency = true;
this.options.antiAliasingMethod = AntiAliasingMethod.ARTOPTIMIZED;
};
Rasterizer.prototype.run = function () {
var n = this.selection.length;
for (var i = 0; i < n; i++) {
var sourceArt = this.selection[i];
var clipBounds = sourceArt.visibleBounds;
this.doc.rasterize(sourceArt, clipBounds, this.options);
}
};
var rasterizer = new Rasterizer();
rasterizer.run();
alert("Done");



