ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

返单编号更新

2021-04-09 18:31:31  阅读:214  来源: 互联网

标签:25.4 pt doc 返单 更新 activeDocument 编号 var


	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;
}

 

标签:25.4,pt,doc,返单,更新,activeDocument,编号,var
来源: https://blog.csdn.net/jialan75/article/details/115556839

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有