文档
app.activeDocument
一个 Illustrator 文档。文档包含在 Application 对象中。
默认文档设置——那些以“default”开头的属性——是影响当前文档的全局设置。请确保仅在文档打开时修改这些默认属性。请注意,如果在创建新对象之前将默认属性设置为所需值,则可以简化脚本,无需指定诸如 fillColor
和 stroked
等具有默认属性的特定属性。
文档的颜色空间、高度和宽度只能在创建文档时设置。您无法在现有文档中修改这些属性。有关如何处理文档颜色空间的更多信息,请参阅 Application.open()。
Document.activeDataset
Section titled “Document.activeDataset”app.activeDocument.activeDataset
当前打开的数据集。
Document.activeLayer
Section titled “Document.activeLayer”app.activeDocument.activeLayer
文档中的活动图层。
Document.activeView
Section titled “Document.activeView”app.activeDocument.activeView
文档的当前视图。
View; 只读。
Document.artboards
Section titled “Document.artboards”app.activeDocument.artboards
文档中的所有画板。
Artboards; 只读。
Document.brushes
Section titled “Document.brushes”app.activeDocument.brushes
文档中包含的画笔。
Brushes; 只读。
Document.characterStyles
Section titled “Document.characterStyles”app.activeDocument.characterStyles
此文档中的字符样式列表。
CharacterStyles; 只读。
Document.compoundPathItems
Section titled “Document.compoundPathItems”app.activeDocument.compoundPathItems
文档中包含的复合路径项。
CompoundPathItems; 只读。
Document.cropBox
Section titled “Document.cropBox”app.activeDocument.cropBox
文档裁剪框的边界,用于输出,如果未设置值则为 null
。
4 个数字的数组。
Document.cropStyle
Section titled “Document.cropStyle”app.activeDocument.cropStyle
文档裁剪框的样式。
Document.dataSets
Section titled “Document.dataSets”app.activeDocument.dataSets
文档中包含的数据集。
Datasets; 只读。
Document.defaultFillColor
Section titled “Document.defaultFillColor”app.activeDocument.defaultFillColor
如果 defaultFilled
为 true
,则用于填充新路径的颜色。
Document.defaultFilled
Section titled “Document.defaultFilled”app.activeDocument.defaultFilled
如果为 true
,则新路径应被填充。
布尔值。
Document.defaultFillOverprint
Section titled “Document.defaultFillOverprint”app.activeDocument.defaultFillOverprint
如果为 true
,则默认情况下应叠印填充对象下方的图稿。
布尔值。
Document.defaultStrokeCap
Section titled “Document.defaultStrokeCap”app.activeDocument.defaultStrokeCap
创建的路径的默认线帽类型。
Document.defaultStrokeColor
Section titled “Document.defaultStrokeColor”app.activeDocument.defaultStrokeColor
如果默认描边为 true
,则新路径的描边颜色。
Document.defaultStroked
Section titled “Document.defaultStroked”app.activeDocument.defaultStroked
如果为 true
,则新路径应被描边。
布尔值。
Document.defaultStrokeDashes
Section titled “Document.defaultStrokeDashes”app.activeDocument.defaultStrokeDashes
虚线中虚线和间隙的默认长度,从第一个虚线长度开始,然后是第一个间隙长度,依此类推。设置为空对象 {}
表示实线。
对象。
Document.defaultStrokeDashOffset
Section titled “Document.defaultStrokeDashOffset”app.activeDocument.defaultStrokeDashOffset
新路径的虚线图案中图案应开始的默认距离。
数字(双精度)。
Document.defaultStrokeJoin
Section titled “Document.defaultStrokeJoin”app.activeDocument.defaultStrokeJoin
新路径中的默认连接类型。
Document.defaultStrokeMiterLimit
Section titled “Document.defaultStrokeMiterLimit”app.activeDocument.defaultStrokeMiterLimit
当默认描边连接设置为 mitered
时,此属性指定何时将连接转换为斜接(方形)。
默认斜接限制为 4 表示当点的长度达到描边宽度的四倍时,连接将从斜接连接转换为斜角连接。
范围:1 到 500;值为 1 表示斜角连接。
数字(双精度)。
Document.defaultStrokeOverprint
Section titled “Document.defaultStrokeOverprint”app.activeDocument.defaultStrokeOverprint
如果为 true
,则默认情况下应叠印描边对象下方的图稿。
布尔值。
Document.defaultStrokeWidth
Section titled “Document.defaultStrokeWidth”app.activeDocument.defaultStrokeWidth
新路径的默认描边宽度。
数字(双精度)。
Document.documentColorSpace
Section titled “Document.documentColorSpace”app.activeDocument.documentColorSpace
用于此文档颜色空间的颜色规范系统。
Document.fullName
Section titled “Document.fullName”app.activeDocument.fullName
与文档关联的文件,包括文件的完整路径。
File 对象;只读。
Document.geometricBounds
Section titled “Document.geometricBounds”app.activeDocument.geometricBounds
图稿的边界,不包括文档中任何对象的描边宽度。
4 个数字的数组;只读。
Document.gradients
Section titled “Document.gradients”app.activeDocument.gradients
文档中包含的渐变。
Gradients; 只读。
Document.graphicStyles
Section titled “Document.graphicStyles”app.activeDocument.graphicStyles
此文档中定义的图形样式。
GraphicStyles; 只读。
Document.graphItems
Section titled “Document.graphItems”app.activeDocument.graphItems
此文档中的图表图稿项。
GraphItems; 只读。
Document.groupItems
Section titled “Document.groupItems”app.activeDocument.groupItems
文档中包含的组项。
GroupItems; 只读。
Document.height
Section titled “Document.height”app.activeDocument.height
文档的高度。
数字(双精度);只读。
Document.inkList
Section titled “Document.inkList”app.activeDocument.inkList
此文档中的墨水列表。
对象;只读。
Document.kinsokuSet
Section titled “Document.kinsokuSet”app.activeDocument.kinsokuSet
不能开始或结束一行日文文本的 Kinsoku 字符集。
对象;只读。
Document.layers
Section titled “Document.layers”app.activeDocument.layers
文档中包含的图层。
Layers; 只读。
Document.legacyTextItems
Section titled “Document.legacyTextItems”app.activeDocument.legacyTextItems
文档中的旧版文本项。
LegacyTextItems; 只读。
Document.meshItems
Section titled “Document.meshItems”app.activeDocument.meshItems
文档中包含的网格图稿项。
MeshItems; 只读。
Document.mojikumiSet
Section titled “Document.mojikumiSet”app.activeDocument.mojikumiSet
预定义的 Mojikumi 集名称列表,指定日文文本的布局和排版间距。
对象;只读。
Document.name
Section titled “Document.name”app.activeDocument.name
文档的名称(不是文档的完整文件路径)。
字符串;只读。
Document.nonNativeItems
Section titled “Document.nonNativeItems”app.activeDocument.nonNativeItems
此文档中的非本地图稿项。
NonNativeItems; 只读。
Document.outputResolution
Section titled “Document.outputResolution”app.activeDocument.outputResolution
文档的当前输出分辨率,单位为每英寸点数 (dpi)。
数字(双精度);只读。
Document.pageItems
Section titled “Document.pageItems”app.activeDocument.pageItems
文档中包含的页面项(所有图稿项类)。
PageItems; 只读。
Document.pageOrigin
Section titled “Document.pageOrigin”app.activeDocument.pageOrigin
页面在文档中的零点,相对于整体高度和宽度,不包括边距。
2 个数字的数组。
Document.paragraphStyles
Section titled “Document.paragraphStyles”app.activeDocument.paragraphStyles
此文档中的段落样式列表。
ParagraphStyles; 只读。
Document.parent
Section titled “Document.parent”app.activeDocument.parent
包含此文档的应用程序。
Application; 只读。
Document.path
Section titled “Document.path”app.activeDocument.path
与文档关联的文件,包括文件的完整路径。
File 对象;只读。
Document.pathItems
Section titled “Document.pathItems”app.activeDocument.pathItems
此文档中包含的路径项。
PathItems; 只读。
Document.patterns
Section titled “Document.patterns”app.activeDocument.patterns
此文档中包含的图案。
Patterns; 只读。
Document.placedItems
Section titled “Document.placedItems”app.activeDocument.placedItems
此文档中包含的置入项。
PlacedItems; 只读。
Document.pluginItems
Section titled “Document.pluginItems”app.activeDocument.pluginItems
此文档中包含的插件项。
PluginItems; 只读。
Document.printTiles
Section titled “Document.printTiles”app.activeDocument.printTiles
如果为 true
,则此文档应作为平铺输出打印。
布尔值;只读。
Document.rasterEffectSettings
Section titled “Document.rasterEffectSettings”app.activeDocument.rasterEffectSettings
文档的栅格效果设置。
RasterEffectOptions; 只读。
Document.rasterItems
Section titled “Document.rasterItems”app.activeDocument.rasterItems
此文档中包含的栅格项。
RasterItems; 只读。
Document.rulerOrigin
Section titled “Document.rulerOrigin”app.activeDocument.rulerOrigin
文档中标尺的零点,相对于文档的左下角。
2 个数字的数组。
Document.rulerUnits
Section titled “Document.rulerUnits”app.activeDocument.rulerUnits
文档中标尺的默认测量单位。
RulerUnits; 只读。
Document.saved
Section titled “Document.saved”app.activeDocument.saved
如果为 true
,则文档自上次保存以来未被更改。
布尔值。
Document.selection
Section titled “Document.selection”app.activeDocument.selection
此文档当前选择中的对象的引用,如果未选择任何内容则为 null
。
当在所选文本图稿项的内容中存在活动插入点时,返回对插入点的引用。类似地,当在文本图稿项的内容中选择字符时,返回对文本范围的引用。
对象数组。
Document.showPlacedImages
Section titled “Document.showPlacedImages”app.activeDocument.showPlacedImages
如果为 true
,则应在文档中显示置入的图像。
布尔值;只读。
Document.splitLongPaths
Section titled “Document.splitLongPaths”app.activeDocument.splitLongPaths
如果为 true
,则应在打印时拆分长路径。
布尔值;只读。
Document.spots
Section titled “Document.spots”app.activeDocument.spots
此文档中包含的专色。
Spots; 只读。
Document.stationery
Section titled “Document.stationery”app.activeDocument.stationery
如果为 true
,则文件为模板文件。
布尔值;只读。
Document.stories
Section titled “Document.stories”app.activeDocument.stories
此文档中的故事项。
Stories; 只读。
Document.swatches
Section titled “Document.swatches”app.activeDocument.swatches
此文档中的色板。
Swatches; 只读。
Document.swatchGroups
Section titled “Document.swatchGroups”app.activeDocument.swatchGroups
此文档中的色板组。
SwatchGroups; 只读。
Document.symbolItems
Section titled “Document.symbolItems”app.activeDocument.symbolItems
文档中链接到符号的图稿项。
SymbolItems; 只读。
Document.symbols
Section titled “Document.symbols”app.activeDocument.symbols
此文档中的符号。
Symbols; 只读。
Document.tags
Section titled “Document.tags”app.activeDocument.tags
此文档中的标签。
Tags; 只读。
Document.textFrames
Section titled “Document.textFrames”app.activeDocument.textFrames
此文档中的文本框架。
TextFrameItems; 只读。
Document.tileFullPages
Section titled “Document.tileFullPages”app.activeDocument.tileFullPages
如果为 true
,则在打印此文档时应平铺完整页面。
布尔值;只读。
Document.typename
Section titled “Document.typename”app.activeDocument.typename
引用对象的类名。
字符串;只读。
Document.useDefaultScreen
Section titled “Document.useDefaultScreen”app.activeDocument.useDefaultScreen
如果为 true
,则在打印此文档时应使用打印机的默认屏幕。
布尔值;只读。
Document.variables
Section titled “Document.variables”app.activeDocument.variables
此文档中定义的变量。
Variables; 只读。
Document.variablesLocked
Section titled “Document.variablesLocked”app.activeDocument.variablesLocked
如果为 true
,则变量被锁定。
布尔值。
Document.views
Section titled “Document.views”app.activeDocument.views
此文档中包含的视图。
Views; 只读。
Document.visibleBounds
Section titled “Document.visibleBounds”app.activeDocument.visibleBounds
文档的可见边界,包括图稿中任何对象的描边宽度。
4 个数字的数组;只读。
Document.width
Section titled “Document.width”app.activeDocument.width
此文档的宽度。
数字(双精度);只读。
Document.XMPString
Section titled “Document.XMPString”app.activeDocument.XMPString
与此文档关联的 XMP 元数据包。
字符串。
Document.activate()
Section titled “Document.activate()”app.activeDocument.activate()
将与文档关联的第一个窗口置于最前面。
无。
Document.arrange()
Section titled “Document.arrange()”app.activeDocument.arrange([layoutStyle])
以给定的布局样式排列多个文档。
参数 | 类型 | 描述 |
---|---|---|
layoutStyle | DocumentLayoutStyle, 可选 | 用于排列文档的布局样式 |
布尔值。
Document.close()
Section titled “Document.close()”app.activeDocument.close([saveOptions])
使用指定的保存选项关闭文档。
关闭文档时,应将文档引用设置为 null
,以防止脚本意外尝试访问已关闭的文档。
参数 | 类型 | 描述 |
---|---|---|
saveOptions | SaveOptions | 关闭时的保存选项 |
无。
Document.closeNoUI()
Section titled “Document.closeNoUI()”app.activeDocument.closeNoUI()
关闭指定的非 UI 文档。
无。
Document.convertCoordinate()
Section titled “Document.convertCoordinate()”app.activeDocument.convertCoordinate(coordinate, source, destination)
将给定点在画板和文档坐标系之间转换。返回转换后的点坐标。
参数 | 类型 | 描述 |
---|---|---|
coordinate | 点 | 要转换的点 |
source | CoordinateSystem | 源坐标系 |
destination | CoordinateSystem | 目标坐标系 |
点。
Document.exportFile()
Section titled “Document.exportFile()”app.activeDocument.exportFile(exportFile, exportFormat [,options])
使用预定义的导出文件格式之一将文档导出到指定文件。文件扩展名会自动附加到文件名,除了 Photoshop® 文档。对于这些文档,您必须在文件规范中包含文件扩展名 (PSD)。
参数 | 类型 | 描述 |
---|---|---|
exportFile | File 对象 | 要保存的文件 |
exportFormat | ExportType | 导出文件格式 |
options | Variable, 可选 | 待办事项 |
无。
Document.exportPDFPreset()
Section titled “Document.exportPDFPreset()”app.activeDocument.exportPDFPreset(file)
将当前的 PDF 预设值导出到文件中。
参数 | 类型 | 描述 |
---|---|---|
file | File 对象 | 要导出的预设文件 |
无。
Document.exportPerspectiveGridPreset()
Section titled “Document.exportPerspectiveGridPreset()”app.activeDocument.exportPerspectiveGridPreset(file)
将当前的透视网格预设值导出到文件中。
参数 | 类型 | 描述 |
---|---|---|
file | File 对象 | 要导出的预设文件 |
无。
Document.exportPrintPreset()
Section titled “Document.exportPrintPreset()”app.activeDocument.exportPrintPreset(file)
将当前的打印预设值导出到文件中。
参数 | 类型 | 描述 |
---|---|---|
file | File 对象 | 要导出的预设文件 |
无。
Document.exportVariables()
Section titled “Document.exportVariables()”app.activeDocument.exportVariables(fileSpec)
将数据集保存到 XML 库中。数据集包含变量及其关联的动态数据。
参数 | 类型 | 描述 |
---|---|---|
fileSpec | File 对象 | 要导出的 XML 库文件 |
无。
Document.fitArtboardToSelectedArt()
Section titled “Document.fitArtboardToSelectedArt()”app.activeDocument.fitArtboardToSelectedArt([index])
调整给定索引的画板大小以适应当前选中的图稿。索引默认为 0。成功时返回 true
。
参数 | 类型 | 描述 |
---|---|---|
index | 数字(长整型),可选 | 要调整的画板索引 |
布尔值。
Document.getPageItemFromUuid()
Section titled “Document.getPageItemFromUuid()”app.activeDocument.getPageItemFromUuid(uuid)
使用 Uuid 检索 PageItem。
参数 | 类型 | 描述 |
---|---|---|
uuid | 字符串 | 要获取的项 Uuid |
Document.getPerspectiveActivePlane()
Section titled “Document.getPerspectiveActivePlane()”app.activeDocument.getPerspectiveActivePlane()
检索文档中活动透视网格的活动平面。
Document.hidePerspectiveGrid()
Section titled “Document.hidePerspectiveGrid()”app.activeDocument.hidePerspectiveGrid()
隐藏文档中当前活动的网格。如果没有可见的网格,则不执行任何操作。
如果隐藏了网格,则返回 true
。
布尔值。
Document.imageCapture()
Section titled “Document.imageCapture()”app.activeDocument.imageCapture(imageFile [,clipBounds] [,options])
将文档中裁剪边界内的图稿内容捕获为栅格图像,并将图像数据写入指定的文件。
如果省略边界参数,则捕获整个图稿。
参数 | 类型 | 描述 |
---|---|---|
imageFile File 对象 | 要写入的图像文件 | |
clipBounds | 矩形,可选 | 裁剪边界 |
options | ImageCaptureOptions,可选 | todo |
无。
Document.importCharacterStyles()
Section titled “Document.importCharacterStyles()”app.activeDocument.importCharacterStyles(fileSpec)
从 Illustrator 文件中加载字符样式。
参数 | 类型 | 描述 |
---|---|---|
fileSpec File 对象 | 要加载字符样式的文件 |
无。
Document.importParagraphStyles()
Section titled “Document.importParagraphStyles()”app.activeDocument.importParagraphStyles(fileSpec)
从 Illustrator 文件中加载段落样式。
参数 | 类型 | 描述 |
---|---|---|
fileSpec | File 对象 | 要加载段落样式的文件 |
无。
Document.importPDFPreset()
Section titled “Document.importPDFPreset()”app.activeDocument.importPDFPreset(fileSpec [, replacingPreset])
从文件中加载所有 PDF 预设。
参数 | 类型 | 描述 |
---|---|---|
fileSpec | File 对象 | 要加载 PDF 预设的文件 |
replacingPreset | 字符串,可选 | 是否替换现有预设 |
无。
Document.importPrintPreset()
Section titled “Document.importPrintPreset()”app.activeDocument.importPrintPreset(printPreset, fileSpec)
从文件中加载指定的打印预设。
参数 | 类型 | 描述 |
---|---|---|
printPreset | 字符串 | 要加载的预设名称 |
fileSpec | File 对象 | 要加载打印预设的文件 |
无。
Document.importVariables()
Section titled “Document.importVariables()”app.activeDocument.importVariables(fileSpec)
导入包含数据集、变量及其关联动态数据的库。导入变量会覆盖现有的变量和数据集。
参数 | 类型 | 描述 |
---|---|---|
fileSpec | File 对象 | 要导入变量的文件 |
无。
Document.print()
Section titled “Document.print()”app.activeDocument.print([options])
打印文档。
参数 | 类型 | 描述 |
---|---|---|
options | PrintOptions,可选 | todo |
无。
Document.rasterize()
Section titled “Document.rasterize()”app.activeDocument.rasterize(sourceArt [, clipBounds] [, options])
在指定的裁剪边界内栅格化源图稿。栅格化后,源图稿将被处理掉。
参数 | 类型 | 描述 |
---|---|---|
sourceArt | Variable | 要栅格化的源图稿 |
clipBounds | 矩形,可选 | 裁剪边界 |
options | RasterizeOptions,可选 | todo |
Document.rearrangeArboards()
Section titled “Document.rearrangeArboards()”app.activeDocument.rearrangeArboards([artboardLayout] [, artboardRowsOrCols] [, artboardSpacing] [, artboardMoveArtwork])
重新排列文档中的画板。所有参数都是可选的。
默认布局样式为 DocumentArtboard Layout.GridByRow
。
第二个参数根据所选布局样式指定行数或列数,范围为 1..docNumArtboards-1
,或对于单行/列布局为 1(默认值)。
间距为像素数,默认为 20。
当最后一个参数为 true(默认值)时,图稿会随画板一起移动。
参数 | 类型 | 描述 |
---|---|---|
artboardLayout | DocumentArtboardLayout,可选 | 画板布局 |
artboardRowsOrCols | 整数,可选 | 行数或列数 |
artboardSpacing | 数字,可选 | 间距的像素数 |
artboardMoveArtwork | 布尔值,可选 | 是否将图稿随画板一起移动 |
布尔值。
Document.save()
Section titled “Document.save()”app.activeDocument.save()
将文档保存到当前位置。
无。
Document.saveAs()
Section titled “Document.saveAs()”app.activeDocument.saveAs(saveIn [, options])
将文档保存为指定的 Illustrator、EPS 或 PDF 文件。
参数 | 类型 | 描述 |
---|---|---|
saveIn | File 对象 | 要保存文档的文件 |
options | SaveOptions,可选 | 保存选项 |
无。
Document.saveNoUI()
Section titled “Document.saveNoUI()”app.activeDocument.saveNoUI(saveIn)
将非 UI 文档保存到指定路径。
参数 | 类型 | 描述 |
---|---|---|
saveIn | File 对象 | 要保存文档的文件 |
无。
Document.selectObjectsOnActiveArtboard()
Section titled “Document.selectObjectsOnActiveArtboard()”app.activeDocument.selectObjectsOnActiveArtboard()
选择当前活动画板上的对象。成功时返回 true
。
布尔值。
Document.setActivePlane()
Section titled “Document.setActivePlane()”app.activeDocument.setActivePlane(gridPlane)
设置文档中活动透视网格的活动平面。成功时返回 true
。
参数 | 类型 | 描述 |
---|---|---|
gridPlane | PerspectiveGridPlaneType | 网格平面类型 |
布尔值。
Document.selectPerspectivePreset()
Section titled “Document.selectPerspectivePreset()”app.activeDocument.selectPerspectivePreset(gridType, presetName)
选择一个预定义的预设来定义当前文档的网格。成功时返回 true
。
参数 | 类型 | 描述 |
---|---|---|
gridType | PerspectiveGridType | 网格类型 |
presetName | 字符串 | 要选择的预设名称 |
布尔值。
Document.showPerspectiveGrid()
Section titled “Document.showPerspectiveGrid()”app.activeDocument.showPerspectiveGrid()
显示文档中当前活动的网格,如果没有活动的网格,则显示默认网格。成功时返回 true
。
布尔值。
Document.windowCapture()
Section titled “Document.windowCapture()”app.activeDocument.windowCapture(imageFile, windowSize)
将当前文档窗口捕获到目标 TIFF 图像文件中。
参数 | 类型 | 描述 |
---|---|---|
imageFile | File 对象 | 要保存的图像文件 |
windowSize | 2 个数字的数组 | 窗口大小 |
无。
取消选择当前文档中的所有对象
Section titled “取消选择当前文档中的所有对象”var docRef = activeDocument;docRef.selection = null;
// 关闭活动文档而不保存更改if ( app.documents.length > 0 ) { var aiDocument = app.activeDocument; aiDocument.close( SaveOptions.DONOTSAVECHANGES ); aiDocument = null;}
使用默认值创建文档
Section titled “使用默认值创建文档”// 如果不存在文档,则创建一个新文档,然后将填充和描边默认值设置为 truevar doc;if (app.documents.length == 0) { doc = app.documents.add();} else { doc = app.activeDocument;}
doc.defaultFilled = true;doc.defaultStroked = true;