Can't rasterize object with hole inside
Copy link to clipboard
Copied
Hello everyone.
I've used thisone part of script for rastering objects.
var docPathItems = app.activeDocument.pathItems;
var myDoc = app.activeDocument;
// If a docuement is open
if ( app.documents.length > 0 )
{
for ( var i=0; i < docPathItems.length ; i++ )
{
if (docPathItems.filled == true)
{
var rasterizeOptions = new RasterizeOptions;
rasterizeOptions.antiAliasingMethod = AntiAliasingMethod.ARTOPTIMIZED;
rasterizeOptions.backgroundBlack = false;
rasterizeOptions.clippingMask = true;
//rasterizeOptions.colorModel = RasterizationColorModel.GRAYSCALE;
rasterizeOptions.convertSpotColors = false;
rasterizeOptions.convertTextToOutlines = false;
rasterizeOptions.includeLayers = false;
rasterizeOptions.padding = 0;
rasterizeOptions.resolution = 300;
rasterizeOptions.transparency = true;
myDoc.rasterize(docPathItems, docPathItems.controlBounds,rasterizeOptions);
}
}
}
If object dont have hole inside (for example picture). It work ok.
BUT if its hole inside (for example picture) - I have error.
So.. error
Who know what does it mean???
Explore related tutorials & articles
Copy link to clipboard
Copied
Is that because it's a Compound Path and doing just one part of it will give an error? If so, you'd need to do rasterize for the compoundPathItems of the doc 1st, then repeat with the pathItems second.
Copy link to clipboard
Copied
Thank u for answer,
So, How can i find only compundPathItems in cycle?
Copy link to clipboard
Copied
Thank u one more time.
I've found how to find only compoundPath objects.
If someone have the same problem, there is code of my decision
var docPathItems = app.activeDocument.pathItems;
var docCompPathItems = app.activeDocument.compoundPathItems;
var myDoc = app.activeDocument;
// If a docuement is open
if ( app.documents.length > 0 )
{
for ( var i=0; i < docCompPathItems.length ; i++ )
{
var rasterizeOptions = new RasterizeOptions;
rasterizeOptions.padding = 0;
rasterizeOptions.resolution = 300;
rasterizeOptions.transparency = true;
myDoc.rasterize(docCompPathItems, docCompPathItems.controlBounds,rasterizeOptions);
}
}

