Indesign脚本:在具有特定段落样式的文本后面设置背景图像

发布于 2025-01-17 22:50:01 字数 585 浏览 3 评论 0原文

我正在 Indesign 中寻找一种解决方案,以在具有特定段落样式的文本后面设置背景图像。不幸的是我还没有找到。 所以我想也许你可以帮助我编写一个脚本,其中你可以:

  • 指定段落样式(比方说“chapter_head”)

  • 在整个文档中搜索其遇到情况。

  • 剪切找到的项目的文本并将其以相同的样式(或样式的副本)粘贴到新的文本框架中

  • 在文本框架后面加载图片(“small-frame.ai”)

  • 组后面加载一张图片,并将其粘贴到我们剪切文本的位置

  • 对所有找到的元素重复

提前致谢! 编辑: 这里根据要求提供了我的目标的图片

在此处输入图像描述

I was searching for a solution in Indesign to set a background image behind a text with a certain paragraph style. Unfortunately I did not find any yet.
So I thought maybe you can help me out with a script where you:

  • assign a paragraph style (let's say "chapter_head")

  • search for its encounter in the whole document.

  • cut text of the found item and paste it with the same style(or a copy of the style) into a new textframe

  • load a picture behind the textframe ("small-frame.ai")

  • group, and paste it to the position where we cut the text out

  • repeat with all found elements

Thanks in advance!
Edit:
here as requested a picture of what I am aiming at

enter image description here

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

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

发布评论

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

评论(1

悲念泪 2025-01-24 22:50:01

干得好。

// find all headers with style 'header'
app.findGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences.findWhat = '^.+

该脚本查找所有样式为“header”的段落,使用剪贴板的内容更改它们(一组:图像+文本“#placeholder#”),然后查找并更改所有文本“#placeholder#”与标题的内容。

之前:

在此处输入图像描述

之后:

在此处输入图像描述

; app.findGrepPreferences.appliedParagraphStyle = 'header'; var headers = app.activeDocument.findGrep(); // store contents of the headers in the array 'contents' var contents = []; while (headers.length) contents.push(headers.shift().contents); // replace all the headers with placeholder from clipboard app.changeGrepPreferences.changeTo = '~C'; app.activeDocument.changeGrep(); // change all '#placeholder#' with contents of the headers app.findGrepPreferences = NothingEnum.nothing; app.findGrepPreferences.findWhat = '#placeholder#'; var placeholders = app.activeDocument.findGrep(); while (contents.length) placeholders.pop().contents = contents.pop();

该脚本查找所有样式为“header”的段落,使用剪贴板的内容更改它们(一组:图像+文本“#placeholder#”),然后查找并更改所有文本“#placeholder#”与标题的内容。

之前:

在此处输入图像描述

之后:

在此处输入图像描述

Here you go.

// find all headers with style 'header'
app.findGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences.findWhat = '^.+

The script finds all the paragraphs with style 'header', changes them with contents of clipboard (a group: image + text '#placeholder#'), then finds and changes all the texts '#placeholder#' with contents of the headers.

Before:

enter image description here

After:

enter image description here

; app.findGrepPreferences.appliedParagraphStyle = 'header'; var headers = app.activeDocument.findGrep(); // store contents of the headers in the array 'contents' var contents = []; while (headers.length) contents.push(headers.shift().contents); // replace all the headers with placeholder from clipboard app.changeGrepPreferences.changeTo = '~C'; app.activeDocument.changeGrep(); // change all '#placeholder#' with contents of the headers app.findGrepPreferences = NothingEnum.nothing; app.findGrepPreferences.findWhat = '#placeholder#'; var placeholders = app.activeDocument.findGrep(); while (contents.length) placeholders.pop().contents = contents.pop();

The script finds all the paragraphs with style 'header', changes them with contents of clipboard (a group: image + text '#placeholder#'), then finds and changes all the texts '#placeholder#' with contents of the headers.

Before:

enter image description here

After:

enter image description here

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