Adobe InDesign CS5 Server JavaScript:通过 XML 标记获取矩形

发布于 2024-11-10 08:07:12 字数 630 浏览 4 评论 0原文

当前设置:

通过 PHP SOAP 通过 ExtendScript 编写 Adob​​e InDesign Server CS5 脚本

问题:

我当前正在将图像文件放入矩形中使用以下代码:

 frame     =   doc.rectangles[0];
 imgList   =   frame.place(new File(img));

这工作正常; img 文件按预期放置到矩形中。但是,这仅指文档中的第一个矩形:如果文档中有两个矩形,则图像将放置到最后创建的矩形中。

我理想地希望能够通过其 XML 标签来引用矩形 - 例如:

frame     =   doc.getRectangleByTag('Pic'); // <Pic> being the name of the XML tag
imgList   =   frame.place(new File(img));

有人对如何实现这一点有任何建议吗?我意识到这是一个基本的问题,但经过几个小时的搜索后我没有找到任何乐趣。

非常感谢

Current set-up:

Adobe InDesign Server CS5 scripted through ExtendScript via PHP SOAP

The problem:

I'm currently placing an image file into a rectangle using the following code:

 frame     =   doc.rectangles[0];
 imgList   =   frame.place(new File(img));

This works fine; the img file is placed into the rectangle as expected. However, this only refers to the first rectangle in the document: if I have two rectangles in the document, the image is placed into the last created rectangle.

What I'd ideally like to be able to refer to the rectangle by its XML tag - something like:

frame     =   doc.getRectangleByTag('Pic'); // <Pic> being the name of the XML tag
imgList   =   frame.place(new File(img));

Does anyone have any advice as to how this can be achieved? I realise this is rudimentary question, but am finding no joy after several hours of searching.

Many thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦里°也失望 2024-11-17 08:07:12

据我所知,没有“getRectangleByTag”方法。但是,如果您知道要查找的矩形的“id”或“name”属性,则可以循环遍历文档中的矩形并像这样查找它这:

var rectangles = doc.rectangles;
var rectID; //the ID you're looking for
var myRectangle;

for(var i = 0; i < rectangles.length; i++){
   if(rectangles[i].id == rectID){
      myRectangle = rectangles[i];
   }
}

myRectangle.place(new File(img));

希望这有帮助!

There isn't a 'getRectangleByTag' method that I know of. However, if you know the 'id' or 'name' property of the rectangle which you are looking for, you can loop through the rectangles in the document and finding it like this:

var rectangles = doc.rectangles;
var rectID; //the ID you're looking for
var myRectangle;

for(var i = 0; i < rectangles.length; i++){
   if(rectangles[i].id == rectID){
      myRectangle = rectangles[i];
   }
}

myRectangle.place(new File(img));

Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文