使用InDesign JS基于页面大小创建一个GraphicLine,不带几何边界

时间:2017-04-06 13:33:40

标签: javascript adobe-indesign

我的总体目标是创建具有特定规格的裁剪标记。我已经尝试过操作InDesign附带的提供的示例脚本。我现在正在尝试创建自己的裁剪标记,并努力完全理解使用graphicLine功能的几何方面。

以下是我到目前为止:

var myCropMarkLength = 15.12;
var myCropMarkOffset = 20.88;
var myCropMarkWidth = .25;
var myX1 = ([myDocument.documentPreferences.pageHeight - myDocument.documentPreferences.pageHeight]);
var myY1 = ([myDocument.documentPreferences.pageWidth - myDocument.documentPreferences.pageWidth]);
var myX2 = ([myDocument.documentPreferences.pageHeight]);
var myY2 = ([myDocument.documentPreferences.pageWidth]);
myOutsideGuide_Left = app.activeDocument.pages[0].graphicLines.add ();
myOutsideGuide_Left.geometricBounds = [myX1, myY1, myX2, myY2 ];
myOutsideGuide_Left.strokeWeight = myCropMarkWidth;

如果有人能帮助我填写myX1,myY1,myX2,myY2就会很精彩。我确信我遗漏了一些东西,但我应该能够在坐标中引用页面大小,因为这是确定坐标的方式。

最好,约翰

1 个答案:

答案 0 :(得分:0)

我不想使用CropMarks.JSX脚本,因为每次我处理文档时都需要我创建一个矩形。我也在尝试构建一个脚本,可以定期应用于我的所有艺术文件,并在内部与我的团队共享。这将允许所有作品的一致性,从裁剪标记长度,偏移量和笔画粗细。我还希望裁剪标记基于页面高度和宽度。

我已经能够使用以下脚本开发裁剪标记。

myDocument = app.activeDocument;

//Change Unit of Meausre to Points
myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
var myCropMarkLength = 15.12;
var myCropMarkOffset = 20.88;
var myCropMarkWidth = .25;
var myPH = myDocument.documentPreferences.pageHeight;
var myPW = myDocument.documentPreferences.pageWidth;

//Upper Left Crop Mark Pair
myOutsideGuide_Left = app.activeDocument.pages[0].graphicLines.add ();
myOutsideGuide_Left.geometricBounds = [myPH - myPH, (myPW - myPW) - myCropMarkOffset, myPH - myPH, (myPW - myPW) - (myCropMarkOffset + myCropMarkLength) ];
myOutsideGuide_Left.strokeWeight = myCropMarkWidth;

myOutsideGuide_Left = app.activeDocument.pages[0].graphicLines.add ();
myOutsideGuide_Left.geometricBounds = [(myPH - myPH) - myCropMarkOffset, myPW - myPW, (myPH - myPH)  - (myCropMarkOffset + myCropMarkLength), myPW - myPW];
myOutsideGuide_Left.strokeWeight = myCropMarkWidth;

//Lower Left Crop Mark Pair
myOutsideGuide_Left = app.activeDocument.pages[0].graphicLines.add ();
myOutsideGuide_Left.geometricBounds = [myPH, (myPW - myPW) - myCropMarkOffset, myPH, (myPW - myPW) - (myCropMarkOffset + myCropMarkLength) ];
myOutsideGuide_Left.strokeWeight = myCropMarkWidth;

myOutsideGuide_Left = app.activeDocument.pages[0].graphicLines.add ();
myOutsideGuide_Left.geometricBounds = [myPH + myCropMarkOffset, myPW - myPW, myPH + (myCropMarkOffset + myCropMarkLength), myPW - myPW];
myOutsideGuide_Left.strokeWeight = myCropMarkWidth;

//Upper Right Crop Mark Pair
myOutsideGuide_Left = app.activeDocument.pages[0].graphicLines.add ();
myOutsideGuide_Left.geometricBounds = [myPH - myPH, myPW + myCropMarkOffset, myPH - myPH, myPW + (myCropMarkOffset + myCropMarkLength) ];
myOutsideGuide_Left.strokeWeight = myCropMarkWidth;

myOutsideGuide_Left = app.activeDocument.pages[0].graphicLines.add ();
myOutsideGuide_Left.geometricBounds = [(myPH - myPH ) - myCropMarkOffset, myPW, (myPH - myPH) - (myCropMarkOffset + myCropMarkLength), myPW];
myOutsideGuide_Left.strokeWeight = myCropMarkWidth;

//Lower Right Crop Mark Pair
myOutsideGuide_Left = app.activeDocument.pages[0].graphicLines.add ();
myOutsideGuide_Left.geometricBounds = [myPH, myPW + myCropMarkOffset, myPH, myPW + (myCropMarkOffset + myCropMarkLength) ];
myOutsideGuide_Left.strokeWeight = myCropMarkWidth;

myOutsideGuide_Left = app.activeDocument.pages[0].graphicLines.add ();
myOutsideGuide_Left.geometricBounds = [myPH + myCropMarkOffset, myPW, myPH + (myCropMarkOffset + myCropMarkLength), myPW];
myOutsideGuide_Left.strokeWeight = myCropMarkWidth;

//Change Unit of Measure Back to Inches
myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;
myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;

创建这个脚本时我最大的问题之一就是确定边界是[Y1,X1,Y2,X2]这是我认为它们本来会倒退的。

希望此代码可以帮助其他人根据页面大小创建裁剪标记,但不能使用基于正在使用的工作流程的InDesign裁剪标记方法。