我使用以下脚本将所有项目/每页从indesign文档导出到jpg。此脚本还会将所有项目裁剪为由indesign中的容器指定的大小。
我想限制此脚本只导出所有"放置的图像",因为我只需要图像。此刻我还得到了所有矩形物体,如文本框等。
#target InDesign
//set properties for export to your needs
with(app.jpegExportPreferences){
antiAlias = true;
embedColorProfile = false;
exportResolution = 300;
jpegColorSpace = JpegColorSpaceEnum.RGB; //JpegColorSpaceEnum.CMYK, JpegColorSpaceEnum.GRAY r/w One of RGB, CMYK or Gray
jpegQuality = JPEGOptionsQuality.HIGH; //JPEGOptionsQuality.LOW, JPEGOptionsQuality.MEDIUM, JPEGOptionsQuality.HIGH, JPEGOptionsQuality.MAXIMUM r/w The compression quality.
jpegRenderingStyle = JPEGOptionsFormat.BASELINE_ENCODING; // JPEGOptionsFormat.PROGRESSIVE_ENCODING r/w The rendering style.
simulateOverprint = true;
}
//doc has to be saved once
var theDoc = app.activeDocument;
var docName = theDoc.name;
var docShortName = docName.replace(/.indd/, '')
var docPath = '' + theDoc.fullName;
var docContainerPath = docPath.replace(docName, '')
var destPath = docContainerPath + '/' + docShortName + '_jpgExport/'
if(Folder(destPath).create() != true){alert('Could not create targetfolder.'); exit();}
var pageItems = theDoc.pageItems.everyItem().getElements();
l = pageItems.length;
counter = 0;
for(var i = 0; i < l; i++){
counter = counter + 1;
var singlePageItem = pageItems[i];
currParentPage = singlePageItem.parentPage;
if(currParentPage == null){parentPageNumber = 'pasteboard'}else{parentPageNumber = singlePageItem.parentPage.name; }
newFile =new File(destPath + 'page_' + parentPageNumber + '_' + 'item_' + counter + '.jpg');
if(singlePageItem.exportFile(ExportFormat.JPG, newFile) === false){alert(newFile + ' could not write jpg-File.')}
}
答案 0 :(得分:1)
如果我理解正确,请代替:
var pageItems = theDoc.pageItems.everyItem().getElements();
你可以使用:
var pageItems = theDoc.allGraphics;
会抓取所有graphic
元素,而不是每个pageItem
。这是你在想什么?
编辑:您可能需要获取每个parent
元素的graphic
元素才能将其导出。