将 "Object Style" 应用于特定 XML 结构标签的 Indesign 脚本
Indesign Script to Apply "Object Style" to Specific XML Structure Tags
有没有办法在 InDesign 中提出 javascript 在通过 XML 将图像导入 InDesign 后,我可以 运行 一个脚本来映射特定的对象样式到一个特定的标签?就像标签允许的段落样式和字符样式一样。不知道为什么 Adobe 不允许对象样式以相同的方式工作。
我在 Adobe 论坛上发现了一些相同的问题..
以下是它的 link..
https://forums.adobe.com/thread/740264
希望对您有所帮助..
我找到的答案如下...
/**
IMAGE OBJECT STYLE SCRIPT
*/
var actions = [
/*
-------------------------
| ACTION:Default Action |
-------------------------
*/
function DefaultAction(){
/** command array */
var commands = [
/** ACTION FUNCTIONS BEGIN HERE: **/
/* Assign a property from the objectStyles collection */
function assign_appliedObjectStyle(obj){
obj.appliedObjectStyle = document.objectStyles.itemByName("Image");
}
];
/** START ACTION EXECUTION CODE: **/
var applyToSelection = [true,true,true,true];
var repeats = 1;
while(repeats--){
for(var idx=0; idx < commands.length; idx++){
try{var i = void 0; (!applyToSelection[idx])?commands[idx]():(function(command){
while((i = (i||0)+1) <= app.selection.length){
try{ command(app.selection[i-1]); }catch(err){
//Selection command error handling code here.
}
}})(commands[idx]);}catch(err){
//Insert Error Handling Code Here.
}}}
/** END ACTION EXECUTION CODE: **/
}
];
for(var idx = 0; idx < actions.length; idx++){
actions[idx]()
}
有没有办法在 InDesign 中提出 javascript 在通过 XML 将图像导入 InDesign 后,我可以 运行 一个脚本来映射特定的对象样式到一个特定的标签?就像标签允许的段落样式和字符样式一样。不知道为什么 Adobe 不允许对象样式以相同的方式工作。
我在 Adobe 论坛上发现了一些相同的问题.. 以下是它的 link..
https://forums.adobe.com/thread/740264
希望对您有所帮助..
我找到的答案如下...
/**
IMAGE OBJECT STYLE SCRIPT
*/
var actions = [
/*
-------------------------
| ACTION:Default Action |
-------------------------
*/
function DefaultAction(){
/** command array */
var commands = [
/** ACTION FUNCTIONS BEGIN HERE: **/
/* Assign a property from the objectStyles collection */
function assign_appliedObjectStyle(obj){
obj.appliedObjectStyle = document.objectStyles.itemByName("Image");
}
];
/** START ACTION EXECUTION CODE: **/
var applyToSelection = [true,true,true,true];
var repeats = 1;
while(repeats--){
for(var idx=0; idx < commands.length; idx++){
try{var i = void 0; (!applyToSelection[idx])?commands[idx]():(function(command){
while((i = (i||0)+1) <= app.selection.length){
try{ command(app.selection[i-1]); }catch(err){
//Selection command error handling code here.
}
}})(commands[idx]);}catch(err){
//Insert Error Handling Code Here.
}}}
/** END ACTION EXECUTION CODE: **/
}
];
for(var idx = 0; idx < actions.length; idx++){
actions[idx]()
}