返单编号更新

	var doc = activeDocument;
	var pt = 72/25.4;

	
for (k=0; k<doc.artboards.length; k++) {
		
	var abBounds = doc.artboards[k].artboardRect;
	var 宽=abBounds[2]-abBounds[0];
	var 高=abBounds[1]-abBounds[3];
	
	var wh = getTextWidth();
	var x=abBounds[2]-3.34*pt;
	var y=abBounds[1]-20*pt;
	var nameF = activeDocument.name.substring(0,activeDocument.name.length-4);

	//右边
	addTextAndRect(x,y,270,2.8*pt,wh.width,nameF);
	//左边
	var x=abBounds[0]+0.7369*pt;
	var y=abBounds[1]-20*pt;
	addTextAndRect(x,y,270,2.8*pt,wh.width,nameF);
	//底部
	var x=abBounds[0]+10*pt;
	var y=abBounds[3]+wh.height-0.25*pt+0.6946*pt;
	addTextAndRect(x,y,0,wh.width,2.8*pt,nameF);

	//底部
	var x=abBounds[0]+宽/2+30*pt;
	var y=abBounds[3]+wh.height-0.25*pt+0.6946*pt;
	addTextAndRect(x,y,0,wh.width,2.8*pt,nameF);
}

function addTextAndRect(x,y,r,rw,rh,content){
	var newShape = activeDocument.pathItems.rectangle(y,x,rw,rh); 
	newShape.fillColor = getCMYKColor(0,0,0,0);
	newShape.strokeColor= NoColor;
	var text = doc.textFrames.add();
	text.contents = content;
	text.textRange.characterAttributes.size=6; //字体大小
	text.textRange.characterAttributes.textFont = textFonts.getByName("MicrosoftYaHei");
	text.textRange.characterAttributes.fillColor = getSpotColor();//填充颜色
	text.rotate(r);
	text.left=x;//距离左边的距离
	text.top =y;//距离顶边的距离
	text.createOutline();
}

function getTextWidth(){
	var text2 = doc.textFrames.add();
	text2.contents = activeDocument.name.substring(0,activeDocument.name.length-4);
	text2.textRange.characterAttributes.size=6; //字体大小
	text2.textRange.characterAttributes.textFont = textFonts.getByName("MicrosoftYaHei");
	var h = {
		width:text2.width,
		height:text2.height
	}
	text2.remove();
	return h;
	
}
function getSpotColor(){
	for (i=0;i<activeDocument.spots.length;i++){
		var  newSpot1 = activeDocument.spots[i]; //获得套版色
		var s = newSpot1.toString();
		aa= s.indexOf('套');
		bb= s.indexOf('Registration');
		if ( bb !=-1){
			var newSpot = activeDocument.spots[i]; //获得套版色
			i=activeDocument.spots.length
		}
		if (aa !=-1 ){
			var newSpot = activeDocument.spots[i]; //获得套版色
			i=activeDocument.spots.length
		}
    }
	regColor = new SpotColor();
	regColor.spot = newSpot;
	return regColor;
}
function getCMYKColor(c,m,y,k){
	var color = new CMYKColor();
	color.cyan= c;
	color.magenta = m;
	color.yellow = y;
	color.black = k;
	return color;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值