我正在制作的剧本应该这样做 PDF-to psd(ok) 所有文件保持打开(好) 用户做出选择,为Photoshop中的每个打开文档定义裁剪(不好) 关闭并保存在其他文件夹中(确定)
我们的想法是,我们有以某种方式创作的PDF格式。但下次我们将有其他pdf必须以不同的方式裁剪。这就是我到目前为止所得到的,但它会像参数中的一组一样裁剪文档。
感谢
//PDFOpenOptions.jsx
var OpenAIFile = new PDFOpenOptions;
OpenAIFile.antiAlias = false;
OpenAIFile.mode = OpenDocumentMode.CMYK;
OpenAIFile.resolution = 150;
var myFolder = Folder.selectDialog("select folder");
if(myFolder != null)
{
var fileList = myFolder.getFiles(/\.(pdf)$/i);
for(var i = 0 ;i < fileList.length; i++)
{
if(fileList[i] instanceof File)
{
var doc= open(fileList[i],OpenAIFile);
}
}
};
var outputFolder = Folder.selectDialog("Dossier de destination:");
//alert(outputFolder);
if (app.documents.length > 0) {
//flatten the active document
app.activeDocument.flatten();
//jpeg options
var myJPEGOptions = new JPEGSaveOptions();
myJPEGOptions.embedColorProfile = true;
myJPEGOptions.formatOptions = FormatOptions.STANDARDBASELINE;
myJPEGOptions.matte = MatteType.WHITE;
myJPEGOptions.quality = 12;
myJPEGOptions.scans = 3;
// get documents;
var docs = app.documents;
for (var m = 0; m < app.documents.length; m++) {
app.activeDocument = docs[m];
try {
//crop 1Lsquaire-got from script lisner
var idCrop = charIDToTypeID( "Crop" );
var desc4 = new ActionDescriptor();
var idT = charIDToTypeID( "T " );
var desc5 = new ActionDescriptor();
var idTop = charIDToTypeID( "Top " );
var idPxl = charIDToTypeID( "#Pxl" );
desc5.putUnitDouble( idTop, idPxl, 601.000000 );
var idLeft = charIDToTypeID( "Left" );
var idPxl = charIDToTypeID( "#Pxl" );
desc5.putUnitDouble( idLeft, idPxl, 2068.000000 );
var idBtom = charIDToTypeID( "Btom" );
var idPxl = charIDToTypeID( "#Pxl" );
desc5.putUnitDouble( idBtom, idPxl, 2948.000000 );
var idRght = charIDToTypeID( "Rght" );
var idPxl = charIDToTypeID( "#Pxl" );
desc5.putUnitDouble( idRght, idPxl, 2918.000000 );
var idRctn = charIDToTypeID( "Rctn" );
desc4.putObject( idT, idRctn, desc5 );
var idAngl = charIDToTypeID( "Angl" );
var idAng = charIDToTypeID( "#Ang" );
desc4.putUnitDouble( idAngl, idAng, 0.000000 );
var idDlt = charIDToTypeID( "Dlt " );
desc4.putBoolean( idDlt, false );
var idcropAspectRatioModeKey = stringIDToTypeID( "cropAspectRatioModeKey" );
var idcropAspectRatioModeClass = stringIDToTypeID( "cropAspectRatioModeClass" );
var idtargetSize = stringIDToTypeID( "targetSize" );
desc4.putEnumerated( idcropAspectRatioModeKey, idcropAspectRatioModeClass, idtargetSize );
executeAction( idCrop, desc4, DialogModes.ALL );
//crop 1Lsquaire
//save file to folder
var myFile = new File((outputFolder ) + "/" + activeDocument.name);
app.activeDocument.saveAs(myFile, myJPEGOptions, true);
}
catch (e) {
alert ("Error the script did not execute");
}
}
while(documents.length>0){
documents[documents.length-1].close(SaveOptions.DONOTSAVECHANGES);
}
};
答案 0 :(得分:0)
如果我理解正确,您可以找出作物坐标所需的位置,然后按照您认为合适的方式应用它们。如果将脚本侦听器裁剪代码更改为函数,则可以传递这些坐标。只需为第二组作物添加另一行,或者另存为新脚本,或者只是将它们注释掉
// usage:
selectRectangle(601, 2068, 2948, 2918);
cropToSelection();
// function SELECT RECTANGLE(top, left, bottom, right)
//
// Note: co-ordinates are same as script listener
// and not so human-friendly as t,l,r,b.
// --------------------------------------------------------
function selectRectangle(top, left, bottom, right)
{
// deselect EVERYTHING first
app.activeDocument.selection.deselect();
// =======================================================
var id1 = charIDToTypeID( "setd" );
var desc1 = new ActionDescriptor();
var id2 = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var id3 = charIDToTypeID( "Chnl" );
var id4 = charIDToTypeID( "fsel" );
ref1.putProperty( id3, id4 );
desc1.putReference( id2, ref1 );
var id5 = charIDToTypeID( "T " );
var desc2 = new ActionDescriptor();
var id6 = charIDToTypeID( "Top " );
var id7 = charIDToTypeID( "#Pxl" );
desc2.putUnitDouble( id6, id7, top );
var id8 = charIDToTypeID( "Left" );
var id9 = charIDToTypeID( "#Pxl" );
desc2.putUnitDouble( id8, id9, left );
var id10 = charIDToTypeID( "Btom" );
var id11 = charIDToTypeID( "#Pxl" );
desc2.putUnitDouble( id10, id11, bottom );
var id12 = charIDToTypeID( "Rght" );
var id13 = charIDToTypeID( "#Pxl" );
desc2.putUnitDouble( id12, id13, right );
var id16 = charIDToTypeID( "Rctn" );
desc1.putObject( id5, id16, desc2 );
executeAction( id1, desc1, DialogModes.NO );
}
function cropToSelection()
{
executeAction( charIDToTypeID( "Crop" ), new ActionDescriptor(), DialogModes.NO );
}