snapToPixel (Illustrator script)
/*
snapToPixel.jsx
Adobe Illustrator script.
Moves any selected objects to the nearest pixel.
*/
if ( documents.length > 0 ) {
var sourceDoc = activeDocument;
var items = selection;
var i = 0 ;
if ( items.length == 0 ) {
alert( "Select at least one item before running this script.");
} else {
// move items to nearest pixel
for ( i = 0 ; i < items.length; i++ ) {
items[i].left = Math.round( items[i].left );
items[i].top = Math.round( items[i].top );
}
redraw();
}
} else {
alert( "No document provided." );
}