javascript - 用于查找与边距重叠的文本框的 Indesign 脚本
问题描述
该答案带来了一个脚本来查找重叠的文本框。现在我尝试调整脚本以查找跨页边距的文本框,但脚本无法正常工作,并且它会提醒双页右侧页面上的所有文本框作为通过页面的文本框边距,我无法弄清楚原因以及如何正确定义它的代码。
也许问题在于我如何设置pageMargins
包含我的边距位置的数组?
以下是我的代码:
// find all out of margins textFrames
app.activeDocument.viewPreferences.rulerOrigin= RulerOrigin.SPREAD_ORIGIN;
//If you are going to work with pages, not spreads, change the line above to PAGE_ORIGIN;
for (a = 0; a < app.activeDocument.spreads.length; a ++) {
var pg = app.activeDocument.spreads [a];
for (e = 0 ; e < pg.pages.length; e ++) {
var singlePage = pg.pages[e];
for (b = 0 ; b < singlePage.textFrames.length; b ++) {
var r1 = pg.textFrames [b];
var gb1 = r1.geometricBounds;
var pageMargins = [singlePage.bounds [0] + singlePage.marginPreferences.top,
singlePage.bounds [1] + singlePage.marginPreferences.left,
singlePage.bounds [2] - singlePage.marginPreferences.bottom,
singlePage.bounds [3] - singlePage.marginPreferences.right
];
// check if it's overlapping page margins
if(!(gb1 [0] > pageMargins [0] && gb1 [1] > pageMargins [1] && gb1 [2] < pageMargins [2] && gb1 [3] < pageMargins [3]))
{
r1.select ();
alert("frame geometric bounds: " + gb1 + "\npage Margins: " + pageMargins + "\nnumber in spread: " + e + "\nsingle page bounds: " + singlePage.bounds + "\n")
var cnf = confirm ("Text frames overlap. Continue searching?", true, "Overlapping text frames");
if (!cnf)
exit ();
}
}
}
}
解决方案
推荐阅读
- r - 如何对分类栅格进行 ssplot 或 ggplot
- android - 保存到内部存储的数据是否会在 Android Studio 中连续运行时持续存在?
- scala - 什么时候进行类型检查以进行理解?
- java - 使用 gremlin 驱动程序实现负载平衡
- xml - 如何在 MarkLogic App Builder 中配置构面?
- python - Python 相同的导入适用于某些类而不适用于其他类 - 同一目录中的导入器
- java - 如何使这个平均位置?
- python - 带有 Tensorflow 后端的 Keras - 在 CPU 上运行预测但适合 GPU
- laravel - 使用 attach() 添加 Model 和 Pivot Model 之间的关系
- gatsby - GatsbyJs 教程一个链接在构建后不起作用