|
Adobe Illustrator 2019 支持使用 JavaScript 进行自动化任务。你可以使用 ExtendScript(Adobe 的 JavaScript 实现)来编写脚本。
以下是一个示例脚本,它会在每个画板上生成页码,并将页码显示在画板的底部居中位置:
- #target illustrator
- function main() {
- var doc = app.activeDocument;
- var numArtboards = doc.artboards.length;
- for (var i = 0; i < numArtboards; i++) {
- var artboard = doc.artboards[i];
- addPageNumberToArtboard(doc, artboard, i + 1);
- }
- }
- function addPageNumberToArtboard(doc, artboard, pageNumber) {
- // Create a new text frame
- var textFrame = doc.textFrames.add();
-
- // Set the content of the text frame to the page number
- textFrame.contents = pageNumber.toString();
-
- // Get the bounds of the artboard
- var artboardBounds = artboard.artboardRect;
-
- // Calculate the position for the text frame to be centered at the bottom of the artboard
- var textFramePosition = [
- artboardBounds[0] + (artboardBounds[2] - artboardBounds[0]) / 2, // Center horizontally
- artboardBounds[1] + (artboardBounds[3] - artboardBounds[1]) * 0.95 // Bottom with some margin
- ];
-
- // Set the position of the text frame
- textFrame.top = textFramePosition[1];
- textFrame.left = textFramePosition[0];
-
- // Align the text frame to the center
- textFrame.justification = Justification.CENTER;
- }
- main();
复制代码
如何使用此脚本:
在桌面新建一个.js的文件,如“自动页码888.js”
然后在Adobe Illustrator,点击“文件-脚本-其他脚本”,找点桌的.js文件,即可。
|
|