[英]indesign script to add a polygon (irregular shape textframe) and add text to it
我需要一個 Indesign 腳本來向頁面添加不規則文本框(多邊形)並向其中添加文本內容。 到目前為止,我有這段代碼。 但它是一個普通的文本框。
var doc = app.documents.add();
var textFrame = doc.textFrames.add();
textFrame.properties =
{
geometricBounds : [ 0,0,100,100 ],
strokeWidth : 0,
fillColor : "None",
contents : "Hello World!"
}
我還可以添加此多邊形,但無法向其添加文本。
var doc = app.documents.add();
var polygon = doc.polygons.add();
var points = [
[100,100],
[150,100],
[200,200],
[120,150],
[100,100],
]
polygon.paths.item(0) = points;
感謝您的幫助!
不確定這是否是您工作流程的最佳方式,但可以通過這種笨拙的方式完成:
var doc = app.documents.add();
var polygon = doc.polygons.add();
var points = [
[100,100],
[150,100],
[200,200],
[120,150],
// [100,100], // this point doesn't need, since a polygon is a closed path
];
polygon.paths[0].entirePath = points;
polygon.contentType = ContentType.TEXT_TYPE; // convert the polygon into a text frame
var poly_textFrame = doc.textFrames.lastItem(); // get the last text frame
poly_textFrame.contents = 'Hello World!'; // change contents of the frame
這種方法的問題是我不確定新文本框架是否始終是文本框架集合中的最后一項。 它需要在體內進行測試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.