InDesign Server Scripts: templating with existing idml file
I have a set of idml files I am using as templates to place text/images and convert to pdf.
Most templates are set up like this:
A textframe
- title, body, inline textframes for photos
B textframe
- logo
I've sucessfully placed text/images. This is a sample js snippet of key parts. (If there is a better way to replace content please let me know.)
var user_name = "Sam";
var user_photo_1= "file location";
// Modify idml
// Clear old preferences
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
// Change text for "NAME"
app.findTextPreferences.findWhat = "NAME";
app.changeTextPreferences.changeTo =user_name;
app.changeText();
// Loop through stories then textframes
// Check contents of textframe to replace content
// Doing this for images since the above didn't work
switch (myTextFrames[j].contents) {
case "IMG_1":
if (user_photo_1 == "") { myTextFrames[j].remove(); break; }
myTextFrames[j].place(File(user_photo_1));
myTextFrames[j].fit(FitOptions.CONTENT_TO_FRAME);
myTextFrames[j].fit(FitOptions.FILL_PROPORTIONALLY);
myTextFrames[j].fit(FitOptions.CENTER_CONTENT);
break;
}The issue I am having is when I have less content to fill the document space than expected. I need to:
1. trim textframe A.
Can someone point me in the right direction for getting this done?