Create pdf from inDesign at runtime
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, ...
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";
精彩评论