Adobe indesign 数据超出Indesign脚本的范围,因为页面太小
我正在使用Indesign jsx脚本获取超出范围的Adobe indesign 数据超出Indesign脚本的范围,因为页面太小,adobe-indesign,Adobe Indesign,我正在使用Indesign jsx脚本获取超出范围的数据。 我的脚本停在:第102行源代码:pageWidth=width 我想这是因为页边比纸张大。我尝试处理最小纸张大小的场景:A11,使用if-else语句 我试图删除母版页,用应用母版页删除并弹出,但我不知道怎么做 我怎样才能给所有纸张尺寸留“5mm”的边距,“A11”留“0mm”的边距?我在Windows7上使用Indesign CS6 这是我的JSON数据: var papersizes = [ { "name"
数据。
我的脚本停在:第102行源代码:pageWidth=width代码>
我想这是因为页边比纸张大。我尝试处理最小纸张大小的场景:A11
,使用if-else语句
我试图删除母版页,用应用母版页删除并弹出
,但我不知道怎么做
我怎样才能给所有纸张尺寸留“5mm”的边距,“A11”留“0mm”的边距?我在Windows7上使用Indesign CS6
这是我的JSON数据:
var papersizes = [
{
"name": "4A0",
"length": 2378,
"width": 1682
},
{
"name": "2A0",
"length": 1682,
"width": 1189
},
{
"name": "A0",
"length": 1189,
"width": 841
},
{
"name": "A1",
"length": 841,
"width": 594
},
{
"name": "A2",
"length": 594,
"width": 420
},
{
"name": "A3",
"length": 420,
"width": 297
},
{
"name": "A4",
"length": 297,
"width": 210
},
{
"name": "A5",
"length": 210,
"width": 148
},
{
"name": "A6",
"length": 148,
"width": 105
},
{
"name": "A7",
"length": 105,
"width": 74
},
{
"name": "A8",
"length": 74,
"width": 52
},
{
"name": "A9",
"length": 52,
"width": 37
},
{
"name": "A10",
"length": 37,
"width": 26
},
{
"name": "A11",
"length": 26,
"width": 18
}
];
var bleed = "4mm";
var margin = "10mm";
for (index = 0; index < papersizes.length; ++index) {
papersize = papersizes[index];
name = papersize["name"];
length = papersize["length"];
width = papersize["width"];
var doc = app.documents.add();
with(doc.viewPreferences) {
horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;
}
with(doc.documentPreferences) {
pageHeight = length;
//Here does my script stops
pageWidth = width;
pageOrientation = PageOrientation.PORTRAIT;
pagesPerDocument = 1;
documentBleedBottomOffset = bleed;
documentBleedTopOffset = bleed;
documentBleedInsideOrLeftOffset = bleed;
documentBleedOutsideOrRightOffset = bleed;
}
//Here I try to handle the paper size
if(name != "A11") {
with (doc.pages.item(0).marginPreferences){
bottom = margin;
//When document.documentPreferences.facingPages == true,
//"left" means inside; "right" means outside.
left = margin;
right = margin;
top = margin;
}
} else {
with (doc.pages.item(0).marginPreferences){
bottom = 0;
//When document.documentPreferences.facingPages == true,
//"left" means inside; "right" means outside.
left = 0;
right = 0;
top = 0;
}
}
//If the active document has not been saved (ever), save it.
if(app.activeDocument.saved == false){
//If you do not provide a file name, InDesign will display the Save dialog box.
app.activeDocument.save(new File("C:/IndesignOutput/DIN_"+name+"_"+length+"mm_"+width+"mm.indd"));
app.activeDocument.close();
}
}
这是我的代码:
var papersizes = [
{
"name": "4A0",
"length": 2378,
"width": 1682
},
{
"name": "2A0",
"length": 1682,
"width": 1189
},
{
"name": "A0",
"length": 1189,
"width": 841
},
{
"name": "A1",
"length": 841,
"width": 594
},
{
"name": "A2",
"length": 594,
"width": 420
},
{
"name": "A3",
"length": 420,
"width": 297
},
{
"name": "A4",
"length": 297,
"width": 210
},
{
"name": "A5",
"length": 210,
"width": 148
},
{
"name": "A6",
"length": 148,
"width": 105
},
{
"name": "A7",
"length": 105,
"width": 74
},
{
"name": "A8",
"length": 74,
"width": 52
},
{
"name": "A9",
"length": 52,
"width": 37
},
{
"name": "A10",
"length": 37,
"width": 26
},
{
"name": "A11",
"length": 26,
"width": 18
}
];
var bleed = "4mm";
var margin = "10mm";
for (index = 0; index < papersizes.length; ++index) {
papersize = papersizes[index];
name = papersize["name"];
length = papersize["length"];
width = papersize["width"];
var doc = app.documents.add();
with(doc.viewPreferences) {
horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;
}
with(doc.documentPreferences) {
pageHeight = length;
//Here does my script stops
pageWidth = width;
pageOrientation = PageOrientation.PORTRAIT;
pagesPerDocument = 1;
documentBleedBottomOffset = bleed;
documentBleedTopOffset = bleed;
documentBleedInsideOrLeftOffset = bleed;
documentBleedOutsideOrRightOffset = bleed;
}
//Here I try to handle the paper size
if(name != "A11") {
with (doc.pages.item(0).marginPreferences){
bottom = margin;
//When document.documentPreferences.facingPages == true,
//"left" means inside; "right" means outside.
left = margin;
right = margin;
top = margin;
}
} else {
with (doc.pages.item(0).marginPreferences){
bottom = 0;
//When document.documentPreferences.facingPages == true,
//"left" means inside; "right" means outside.
left = 0;
right = 0;
top = 0;
}
}
//If the active document has not been saved (ever), save it.
if(app.activeDocument.saved == false){
//If you do not provide a file name, InDesign will display the Save dialog box.
app.activeDocument.save(new File("C:/IndesignOutput/DIN_"+name+"_"+length+"mm_"+width+"mm.indd"));
app.activeDocument.close();
}
}
var-bleed=“4mm”;
var margin=“10mm”;
对于(索引=0;索引
如果您是正确的,您无法更改文档大小,因为默认的边距。所以,是的:改变它们应该会让它起作用。但是,您必须在尝试设置此小尺寸之前更改它们,而不是之后
但是,唉,这不是唯一的事情。看起来,仅仅更改当前页面是不够的——调整文档的大小也会调整其主排列的大小,因此您还需要更改这些
我通常的技巧是设置多个项目以使用相同的属性:
// doc.masterSpreads.item(0).pages.everyItem().marginPreferences.properties = { ... };
。。。但是,令人惊讶的是,everyItem
在这里什么都不做!因此,您必须在masterSpreads
中手动循环页面。幸运的是,您不必更改文档的第一页,因为默认情况下,它应用了第一个主排列
它仍然不起作用,经过一些尝试和错误之后,我发现还有另一组边距需要重置:文档本身的默认值。(不知道为什么。也许你删除了所有主价差,或者类似的奇怪的东西,而保证金值仍然需要在某个地方“存在”。)
这对我很有用:
length = 26;
width = 18;
bleed = "4mm";
margin = "10mm";
var doc = app.documents.add();
with(doc.viewPreferences) {
horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;
}
doc.marginPreferences.properties = { top:0, bottom:0, left:0, right: 0 };
for (i=0; i<doc.masterSpreads.item(0).pages.length; i++)
doc.masterSpreads.item(0).pages.item(i).marginPreferences.properties = {
bottom:0,
//When document.documentPreferences.facingPages == true,
//"left" means inside; "right" means outside.
left:0,
right:0,
top:0
};
with(doc.documentPreferences) {
pageOrientation = PageOrientation.PORTRAIT;
pagesPerDocument = 1;
documentBleedBottomOffset = bleed;
documentBleedTopOffset = bleed;
documentBleedInsideOrLeftOffset = bleed;
documentBleedOutsideOrRightOffset = bleed;
pageHeight = length;
pageWidth = width;
}
length=26;
宽度=18;
出血=“4mm”;
边距=“10mm”;
var doc=app.documents.add();
使用(文档视图首选项){
水平测量单位=测量单位。毫米;
垂直测量单位=测量单位(毫米);
}
doc.marginPreferences.properties={top:0,bottom:0,left:0,right:0};
对于(i=0;当您手动执行此操作时,它可以工作吗?当我从GUI创建一篇空白为0的A11论文时,它是可能的。那么为什么它不能与脚本一起工作呢?