InDesign-如何将组导出为jpg

时间:2019-10-16 08:51:06

标签: export jpeg adobe-indesign

我需要将InDesign中的组导出为jpg。

我的论坛将包含图片,徽标和一些txt,并且 我的文档中的每个组都需要有一张图片。最好加上图片名称。

我尝试使用this script, 但是它只显示图像,而不显示组。

我想让脚本使用组而不是图像。

exportSelectedImages();

function exportSelectedImages() {
    // configure export settings
    app.jpegExportPreferences.exportResolution = 72;
    app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.HIGH;

    // collect selected objects
    var selected = app.activeDocument.selection;
    $.writeln("Got " + selected.length + " selected objects...");

    // process selected objects
    for (var i = 0; i < selected.length; i++) {
        var cursor = selected[i];
        var img = cursor.images;

        $.writeln("Processing #" + (i+1) + "/" + selected.length);
        $.writeln("\t Type: " + cursor.constructor.name);

        // verify if object contains an image or not
        if (cursor.images.length > 0) {     
            var img = cursor.images[0];
            $.writeln("\t Contains image of type " + img.imageTypeName);
            var imageFileName = cursor.images[0].itemLink.name;
            $.writeln("\t File Name: " + imageFileName);
        } else {
            $.writeln("\t Not an image");
        }

        // save the object to a jpeg in path specified below
        var myFile = new File('~/Desktop/jowjow/' + "crop_" + imageFileName + '.jpg');
        cursor.exportFile(ExportFormat.JPG, myFile);

     }

    $.writeln("Done.");
}

1 个答案:

答案 0 :(得分:0)

选择组后,请尝试以下代码:

app.jpegExportPreferences.exportResolution = 72;

app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.HIGH;

var selected = app.activeDocument.selection;

for (var i = 0; i < selected.length; i++) {

    if(cursor.constructor.name == "Group"){

        var cursor = selected[i];

        if(cursor.rectangles.length == 1){

            if (cursor.rectangles[0].graphics.length > 0) {

                var img = cursor.rectangles[0].graphics[0];
                var imageFileName = cursor.rectangles[0].graphics[0].itemLink.name;
                var myFile = new File('~/Desktop/' + "Group_" + imageFileName + '.jpg');
                cursor.exportFile(ExportFormat.JPG, myFile);
                }
            }
        }
    }
alert("Process Completed!!!");

Sunil