InDesign 脚本编写 - 初学者
我是一名经验丰富的 JavaScript 程序员,目前正在从事一个需要大量工作的项目,我希望该过程可以使用 InDesign 脚本实现自动化。
本质上,这就是我想做的。我有一个 5 位(有时但很少是 4 位)数字的字符串。然后,我在文本框架下方有三个矩形,我想根据数字的最后数字对其应用样本。数字 0-9 被分配了特定的颜色(和样本),目前我正在手动浏览每个矩形,并根据最后两位数字选择它,并将样本应用于所有选定的颜色。
我确信使用 InDesign 用户脚本自动化该过程一定是可能的,但我对此没有很好的理解。以下是如何将颜色分配给特殊条形码的示例:
0 = 红色 1 = 蓝色 2 = 绿色 ....
因此,对于以下代码:12312,我希望下面的条具有以下颜色:
蓝色 红色的 蓝色
(即顶行和底行 = 倒数第二位数字;中间行 = 最后一位数字)。
谁能告诉我如何编写一个脚本,该脚本循环遍历文档中的页面,查找代码,提取最后两位数字,然后根据数字将样本应用到矩形对象......
我有信心我可以使用常规 JavaScript 和 HTML 编写类似的内容,但话虽如此,我熟悉 HTML 中的 DOM...
任何帮助或指示将不胜感激!
I am a seasoned JavaScript programmer, and am currently working on a project which requires a lot of work, and I'm hoping that the process can be automated using scripts for InDesign.
Essentially, here's what I want to do. I have a 5 (sometimes, but rarely, 4)-digit string. I then have three rectangles underneath the text frame which I would like to apply a swatch to, depending on the final digits of the number. Numbers 0-9 are assigned a specific colour (and swatch), and at the moment I am manually going through each rectangle, and selecting it according to the last two digits, and applying the swatch to all those selected.
I am convinced that it must be possible to automate the process using InDesign User Scripts, but I don't have a good understanding of this. Here's an example of how the colours are assigned to the special bar codes:
0 = red
1 = blue
2 = green
....
So for the following code: 12312, I would like the bars underneath to have the following colours:
blue
red
blue
(i.e. top and bottom row = penultimate digit; middle row = last digit).
Could anyone indicate to me how I might write a script which loops through the pages in my document, finds the codes, extracts the last two digits and then applies a swatch to the rectangle object, depending on the number...
I am confident that I could write something like this using regular JavaScript and HTML, but that having been said, I am familiar with the DOM in HTML...
Any help or pointers would be gratefully received!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我刚刚快速输入的一个脚本示例,应该可以帮助您入门。您可能需要对其进行调整,但我认为它满足您的要求。
我希望这有帮助!以下是一些直接来自 Adobe 的脚本参考,应该会有所帮助。如果您对上述示例有任何疑问,请告诉我。
Here is a script example I just typed up quick that should get you started. You may have to tweak it, but I think it covers what you're requesting.
I hope this helps! Here are some scripting references straight from Adobe that should help. Let me know if you have any questions about the example above.