跳转到内容

文档

app.activeDocument

一个 Illustrator 文档。文档包含在 Application 对象中。

默认文档设置——那些以“default”开头的属性——是影响当前文档的全局设置。请确保仅在文档打开时修改这些默认属性。请注意,如果在创建新对象之前将默认属性设置为所需值,则可以简化脚本,无需指定诸如 fillColorstroked 等具有默认属性的特定属性。

文档的颜色空间、高度和宽度只能在创建文档时设置。您无法在现有文档中修改这些属性。有关如何处理文档颜色空间的更多信息,请参阅 Application.open()


app.activeDocument.activeDataset

当前打开的数据集。

Dataset


app.activeDocument.activeLayer

文档中的活动图层。

Layer


app.activeDocument.activeView

文档的当前视图。

View; 只读。


app.activeDocument.artboards

文档中的所有画板。

Artboards; 只读。


app.activeDocument.brushes

文档中包含的画笔。

Brushes; 只读。


app.activeDocument.characterStyles

此文档中的字符样式列表。

CharacterStyles; 只读。


app.activeDocument.compoundPathItems

文档中包含的复合路径项。

CompoundPathItems; 只读。


app.activeDocument.cropBox

文档裁剪框的边界,用于输出,如果未设置值则为 null

4 个数字的数组。


app.activeDocument.cropStyle

文档裁剪框的样式。

CropOptions


app.activeDocument.dataSets

文档中包含的数据集。

Datasets; 只读。


app.activeDocument.defaultFillColor

如果 defaultFilledtrue,则用于填充新路径的颜色。

Color


app.activeDocument.defaultFilled

如果为 true,则新路径应被填充。

布尔值。


app.activeDocument.defaultFillOverprint

如果为 true,则默认情况下应叠印填充对象下方的图稿。

布尔值。


app.activeDocument.defaultStrokeCap

创建的路径的默认线帽类型。

StrokeCap


app.activeDocument.defaultStrokeColor

如果默认描边为 true,则新路径的描边颜色。

Color


app.activeDocument.defaultStroked

如果为 true,则新路径应被描边。

布尔值。


app.activeDocument.defaultStrokeDashes

虚线中虚线和间隙的默认长度,从第一个虚线长度开始,然后是第一个间隙长度,依此类推。设置为空对象 {} 表示实线。

对象。


app.activeDocument.defaultStrokeDashOffset

新路径的虚线图案中图案应开始的默认距离。

数字(双精度)。


app.activeDocument.defaultStrokeJoin

新路径中的默认连接类型。

StrokeJoin


app.activeDocument.defaultStrokeMiterLimit

当默认描边连接设置为 mitered 时,此属性指定何时将连接转换为斜接(方形)。

默认斜接限制为 4 表示当点的长度达到描边宽度的四倍时,连接将从斜接连接转换为斜角连接。

范围:1 到 500;值为 1 表示斜角连接。

数字(双精度)。


app.activeDocument.defaultStrokeOverprint

如果为 true,则默认情况下应叠印描边对象下方的图稿。

布尔值。


app.activeDocument.defaultStrokeWidth

新路径的默认描边宽度。

数字(双精度)。


app.activeDocument.documentColorSpace

用于此文档颜色空间的颜色规范系统。

DocumentColorSpace


app.activeDocument.fullName

与文档关联的文件,包括文件的完整路径。

File 对象;只读。


app.activeDocument.geometricBounds

图稿的边界,不包括文档中任何对象的描边宽度。

4 个数字的数组;只读。


app.activeDocument.gradients

文档中包含的渐变。

Gradients; 只读。


app.activeDocument.graphicStyles

此文档中定义的图形样式。

GraphicStyles; 只读。


app.activeDocument.graphItems

此文档中的图表图稿项。

GraphItems; 只读。


app.activeDocument.groupItems

文档中包含的组项。

GroupItems; 只读。


app.activeDocument.height

文档的高度。

数字(双精度);只读。


app.activeDocument.inkList

此文档中的墨水列表。

对象;只读。


app.activeDocument.kinsokuSet

不能开始或结束一行日文文本的 Kinsoku 字符集。

对象;只读。


app.activeDocument.layers

文档中包含的图层。

Layers; 只读。


app.activeDocument.legacyTextItems

文档中的旧版文本项。

LegacyTextItems; 只读。


app.activeDocument.meshItems

文档中包含的网格图稿项。

MeshItems; 只读。


app.activeDocument.mojikumiSet

预定义的 Mojikumi 集名称列表,指定日文文本的布局和排版间距。

对象;只读。


app.activeDocument.name

文档的名称(不是文档的完整文件路径)。

字符串;只读。


app.activeDocument.nonNativeItems

此文档中的非本地图稿项。

NonNativeItems; 只读。


app.activeDocument.outputResolution

文档的当前输出分辨率,单位为每英寸点数 (dpi)。

数字(双精度);只读。


app.activeDocument.pageItems

文档中包含的页面项(所有图稿项类)。

PageItems; 只读。


app.activeDocument.pageOrigin

页面在文档中的零点,相对于整体高度和宽度,不包括边距。

2 个数字的数组。


app.activeDocument.paragraphStyles

此文档中的段落样式列表。

ParagraphStyles; 只读。


app.activeDocument.parent

包含此文档的应用程序。

Application; 只读。


app.activeDocument.path

与文档关联的文件,包括文件的完整路径。

File 对象;只读。


app.activeDocument.pathItems

此文档中包含的路径项。

PathItems; 只读。


app.activeDocument.patterns

此文档中包含的图案。

Patterns; 只读。


app.activeDocument.placedItems

此文档中包含的置入项。

PlacedItems; 只读。


app.activeDocument.pluginItems

此文档中包含的插件项。

PluginItems; 只读。


app.activeDocument.printTiles

如果为 true,则此文档应作为平铺输出打印。

布尔值;只读。


app.activeDocument.rasterEffectSettings

文档的栅格效果设置。

RasterEffectOptions; 只读。


app.activeDocument.rasterItems

此文档中包含的栅格项。

RasterItems; 只读。


app.activeDocument.rulerOrigin

文档中标尺的零点,相对于文档的左下角。

2 个数字的数组。


app.activeDocument.rulerUnits

文档中标尺的默认测量单位。

RulerUnits; 只读。


app.activeDocument.saved

如果为 true,则文档自上次保存以来未被更改。

布尔值。


app.activeDocument.selection

此文档当前选择中的对象的引用,如果未选择任何内容则为 null

当在所选文本图稿项的内容中存在活动插入点时,返回对插入点的引用。类似地,当在文本图稿项的内容中选择字符时,返回对文本范围的引用。

对象数组。


app.activeDocument.showPlacedImages

如果为 true,则应在文档中显示置入的图像。

布尔值;只读。


app.activeDocument.splitLongPaths

如果为 true,则应在打印时拆分长路径。

布尔值;只读。


app.activeDocument.spots

此文档中包含的专色。

Spots; 只读。


app.activeDocument.stationery

如果为 true,则文件为模板文件。

布尔值;只读。


app.activeDocument.stories

此文档中的故事项。

Stories; 只读。


app.activeDocument.swatches

此文档中的色板。

Swatches; 只读。


app.activeDocument.swatchGroups

此文档中的色板组。

SwatchGroups; 只读。


app.activeDocument.symbolItems

文档中链接到符号的图稿项。

SymbolItems; 只读。


app.activeDocument.symbols

此文档中的符号。

Symbols; 只读。


app.activeDocument.tags

此文档中的标签。

Tags; 只读。


app.activeDocument.textFrames

此文档中的文本框架。

TextFrameItems; 只读。


app.activeDocument.tileFullPages

如果为 true,则在打印此文档时应平铺完整页面。

布尔值;只读。


app.activeDocument.typename

引用对象的类名。

字符串;只读。


app.activeDocument.useDefaultScreen

如果为 true,则在打印此文档时应使用打印机的默认屏幕。

布尔值;只读。


app.activeDocument.variables

此文档中定义的变量。

Variables; 只读。


app.activeDocument.variablesLocked

如果为 true,则变量被锁定。

布尔值。


app.activeDocument.views

此文档中包含的视图。

Views; 只读。


app.activeDocument.visibleBounds

文档的可见边界,包括图稿中任何对象的描边宽度。

4 个数字的数组;只读。


app.activeDocument.width

此文档的宽度。

数字(双精度);只读。


app.activeDocument.XMPString

与此文档关联的 XMP 元数据包。

字符串。


app.activeDocument.activate()

将与文档关联的第一个窗口置于最前面。

无。


app.activeDocument.arrange([layoutStyle])

以给定的布局样式排列多个文档。

参数类型描述
layoutStyleDocumentLayoutStyle, 可选用于排列文档的布局样式

布尔值。


app.activeDocument.close([saveOptions])

使用指定的保存选项关闭文档。

关闭文档时,应将文档引用设置为 null,以防止脚本意外尝试访问已关闭的文档。

参数类型描述
saveOptionsSaveOptions关闭时的保存选项

无。


app.activeDocument.closeNoUI()

关闭指定的非 UI 文档。

无。


app.activeDocument.convertCoordinate(coordinate, source, destination)

将给定点在画板和文档坐标系之间转换。返回转换后的点坐标。

参数类型描述
coordinate要转换的点
sourceCoordinateSystem源坐标系
destinationCoordinateSystem目标坐标系

点。


app.activeDocument.exportFile(exportFile, exportFormat [,options])

使用预定义的导出文件格式之一将文档导出到指定文件。文件扩展名会自动附加到文件名,除了 Photoshop® 文档。对于这些文档,您必须在文件规范中包含文件扩展名 (PSD)。

参数类型描述
exportFileFile 对象要保存的文件
exportFormatExportType导出文件格式
optionsVariable, 可选待办事项

无。


app.activeDocument.exportPDFPreset(file)

将当前的 PDF 预设值导出到文件中。

参数类型描述
fileFile 对象要导出的预设文件

无。


app.activeDocument.exportPerspectiveGridPreset(file)

将当前的透视网格预设值导出到文件中。

参数类型描述
fileFile 对象要导出的预设文件

无。


app.activeDocument.exportPrintPreset(file)

将当前的打印预设值导出到文件中。

参数类型描述
fileFile 对象要导出的预设文件

无。


app.activeDocument.exportVariables(fileSpec)

将数据集保存到 XML 库中。数据集包含变量及其关联的动态数据。

参数类型描述
fileSpecFile 对象要导出的 XML 库文件

无。


app.activeDocument.fitArtboardToSelectedArt([index])

调整给定索引的画板大小以适应当前选中的图稿。索引默认为 0。成功时返回 true

参数类型描述
index数字(长整型),可选要调整的画板索引

布尔值。


app.activeDocument.getPageItemFromUuid(uuid)

使用 Uuid 检索 PageItem

参数类型描述
uuid字符串要获取的项 Uuid

PageItem


app.activeDocument.getPerspectiveActivePlane()

检索文档中活动透视网格的活动平面。

PerspectiveGridPlaneType


app.activeDocument.hidePerspectiveGrid()

隐藏文档中当前活动的网格。如果没有可见的网格,则不执行任何操作。

如果隐藏了网格,则返回 true

布尔值。


app.activeDocument.imageCapture(imageFile [,clipBounds] [,options])

将文档中裁剪边界内的图稿内容捕获为栅格图像,并将图像数据写入指定的文件。

如果省略边界参数,则捕获整个图稿。

参数类型描述
imageFile File 对象要写入的图像文件
clipBounds矩形,可选裁剪边界
optionsImageCaptureOptions,可选todo

无。


app.activeDocument.importCharacterStyles(fileSpec)

从 Illustrator 文件中加载字符样式。

参数类型描述
fileSpec File 对象要加载字符样式的文件

无。


app.activeDocument.importParagraphStyles(fileSpec)

从 Illustrator 文件中加载段落样式。

参数类型描述
fileSpecFile 对象要加载段落样式的文件

无。


app.activeDocument.importPDFPreset(fileSpec [, replacingPreset])

从文件中加载所有 PDF 预设。

参数类型描述
fileSpecFile 对象要加载 PDF 预设的文件
replacingPreset字符串,可选是否替换现有预设

无。


app.activeDocument.importPrintPreset(printPreset, fileSpec)

从文件中加载指定的打印预设。

参数类型描述
printPreset字符串要加载的预设名称
fileSpecFile 对象要加载打印预设的文件

无。


app.activeDocument.importVariables(fileSpec)

导入包含数据集、变量及其关联动态数据的库。导入变量会覆盖现有的变量和数据集。

参数类型描述
fileSpecFile 对象要导入变量的文件

无。


app.activeDocument.print([options])

打印文档。

参数类型描述
optionsPrintOptions,可选todo

无。


app.activeDocument.rasterize(sourceArt [, clipBounds] [, options])

在指定的裁剪边界内栅格化源图稿。栅格化后,源图稿将被处理掉。

参数类型描述
sourceArtVariable要栅格化的源图稿
clipBounds矩形,可选裁剪边界
optionsRasterizeOptions,可选todo

RasterItem


app.activeDocument.rearrangeArboards([artboardLayout] [, artboardRowsOrCols] [, artboardSpacing] [, artboardMoveArtwork])

重新排列文档中的画板。所有参数都是可选的。

默认布局样式为 DocumentArtboard Layout.GridByRow

第二个参数根据所选布局样式指定行数或列数,范围为 1..docNumArtboards-1,或对于单行/列布局为 1(默认值)。

间距为像素数,默认为 20。

当最后一个参数为 true(默认值)时,图稿会随画板一起移动。

参数类型描述
artboardLayoutDocumentArtboardLayout,可选画板布局
artboardRowsOrCols整数,可选行数或列数
artboardSpacing数字,可选间距的像素数
artboardMoveArtwork布尔值,可选是否将图稿随画板一起移动

布尔值。


app.activeDocument.save()

将文档保存到当前位置。

无。


app.activeDocument.saveAs(saveIn [, options])

将文档保存为指定的 Illustrator、EPS 或 PDF 文件。

参数类型描述
saveInFile 对象要保存文档的文件
optionsSaveOptions,可选保存选项

无。


app.activeDocument.saveNoUI(saveIn)

将非 UI 文档保存到指定路径。

参数类型描述
saveInFile 对象要保存文档的文件

无。


app.activeDocument.selectObjectsOnActiveArtboard()

选择当前活动画板上的对象。成功时返回 true

布尔值。


app.activeDocument.setActivePlane(gridPlane)

设置文档中活动透视网格的活动平面。成功时返回 true

参数类型描述
gridPlanePerspectiveGridPlaneType网格平面类型

布尔值。


app.activeDocument.selectPerspectivePreset(gridType, presetName)

选择一个预定义的预设来定义当前文档的网格。成功时返回 true

参数类型描述
gridTypePerspectiveGridType网格类型
presetName字符串要选择的预设名称

布尔值。


app.activeDocument.showPerspectiveGrid()

显示文档中当前活动的网格,如果没有活动的网格,则显示默认网格。成功时返回 true

布尔值。


app.activeDocument.windowCapture(imageFile, windowSize)

将当前文档窗口捕获到目标 TIFF 图像文件中。

参数类型描述
imageFileFile 对象要保存的图像文件
windowSize2 个数字的数组窗口大小

无。


取消选择当前文档中的所有对象

Section titled “取消选择当前文档中的所有对象”
var docRef = activeDocument;
docRef.selection = null;

// 关闭活动文档而不保存更改
if ( app.documents.length > 0 ) {
var aiDocument = app.activeDocument;
aiDocument.close( SaveOptions.DONOTSAVECHANGES );
aiDocument = null;
}

// 如果不存在文档,则创建一个新文档,然后将填充和描边默认值设置为 true
var doc;
if (app.documents.length == 0) {
doc = app.documents.add();
} else {
doc = app.activeDocument;
}
doc.defaultFilled = true;
doc.defaultStroked = true;