在运行时从 inDesign 创建 pdf

发布于 2024-09-03 04:03:33 字数 346 浏览 3 评论 0原文

对于一个项目,我需要自动创建名片。现在,他们为每个名片模板都有一个 InDesign 文件。他们将所有人员的信息插入 indesign 文件中,然后生成一个 pdf 文件。

现在,在 Web 应用程序中输入客户信息没有问题,但如何生成 pdf 以及如何在运行时更改 indesign 文件?

我认为无法以编程方式更改 indesign 文件?

我可以从 indesign 生成一个 pdf 文件,其中包含一张卡片模板吗?在运行时,我会将卡片复制到 pdf 中 x 次。然后我需要注入人员的信息(姓名、地址……)?

这里有什么可能?

最终的 pdf 由一台自动创建名片、剪切名片的机器使用......

For a project I need to automate creation of business cards. Now, they have a InDesign file for each business card template. They insert the info of alle the people in the indesign file and then generate a pdf of it.

Now, entering the information of customers in a web application is no problem, but how will I generate a pdf and how will I alter the indesign file at runtime?

I think that altering the indesign file will be not possible programmatically?

Could I generate a pdf from the indesign with one card template in it. At runtime I would copy the card in the pdf x number of times. Then I would need to inject the information of the people (name, address, ...)?

What's possible here?

The final pdf is used by a machine that automatically creates the business cards, cuts them, ...

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

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

发布评论

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

评论(1

安穩 2024-09-10 04:03:33

您可以使用 InDesign 中的内置脚本支持来自动化几乎任何事情。在 InDesign GUI 中,您可以将脚本标签分配给 InDesign 文档中的各种元素,例如文本框架。例如,如果您想替换文本框架中的某些文本,您可以在 Javascript 中应用类似的内容(CS4 及以下版本,请参阅下面的注释):

var document = app.open(File("path to your InDesign file"), false);
var textFrame = document.pageItems.item("your script label");
var story = textFrame.parentStory;
story.contents = "your new content"

要创建 PDF,您可以执行以下操作:

var pdfFile = new File("path to your pdf");
document.exportFile(ExportFormat.PDF_TYPE, pdfFile);

这只是几个示例我希望这对您有所帮助。
如果您不知道如何在 InDesign 中安装和运行脚本,这篇博文解释了这个过程。您可以在此处找到良好的在线脚本参考。
据我了解,您希望将脚本作为批处理过程运行。如果是这种情况,我建议您查看一下 InDesign Server。它基本上是 InDesign 的桌面版本,但没有 GUI,只有一个简单的 Web 服务界面。它还作为 Windows 服务(或其他平台上的同等服务)运行。

注意:从 CS5 开始,您无法再通过脚本标签来识别文本框架,如上所示。 这里有一些相关讨论。最好的替代方法是使用 itemByName(name) 而不是 item,其中 name 是图层调色板上的名称。这可以在 GUI 中通过执行 非常慢的双击来更改 在图层调板中的项目上。或者,此解决方法 将每个文本框架的名称设置为其脚本标签。然后,要更改文本框架的内容,您所需要做的就是:

document.textFrames.itemByName("shmullus").contents = "The Doctor";

You can automate pretty much anything using the built-in scripting support in InDesign. In the InDesign GUI you can assign script labels to various elements, such as text frames, in your InDesign document. If you, for instance, would like to replace some text in a text frame you can apply something like this in Javascript (CS4 and below, see note below):

var document = app.open(File("path to your InDesign file"), false);
var textFrame = document.pageItems.item("your script label");
var story = textFrame.parentStory;
story.contents = "your new content"

To create a PDF you do something like this:

var pdfFile = new File("path to your pdf");
document.exportFile(ExportFormat.PDF_TYPE, pdfFile);

This was just a few examples of what you can do, I hope that was somewhat helpful.
If you don't know how to install and run scripts in InDesign, this blog post explains the process. You can find a good online scripting reference here.
As I understand it you would like to run your scripts as a batch process. If that is the case I recommend that you take a look at InDesign Server. It is basically the desktop version of InDesign but without the GUI and with a simple Web Service interface. It is also running as a Windows service (or the equivalent on other platforms).

NOTE: Starting with CS5, you can no longer identify a text frame by its script label, as shown above. There's some discussion about it here. The best alternative is to use itemByName(name) instead of item, with name being the name on the layers palette. This can be changed in the GUI by doing a really slow double click on the item in the layers palette. Or, this workaround sets each text frame's name to be equal to its script label. Then, all you have to do to change the text frame's contents is this:

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