Copy link to clipboard
Copied
Hello folks,
Why this post?
I'm interested in knowing some of your experience about layout automation. Obviously the good ideas, but also the bad ones (like don't go this way, it's a waste of time) and some possible new areas to be explored.
Let's be honest, I'm not a pro at scripting, by far, but I'm eager to learn. That's a start I guess.
I understand that a good scripter should not only know the coding part, but also apply the best strategy to get to his goal. I believe it's rather easy to write "some" code that works (oversimplified, I know) it's another story to "know what to write" and understand what are the best tools and the structure that should be put in place.
That's why I'm asking you. For pieces of advice, respectfully.
What is my project about?
I'd like to build routines and scripts to give me a hand at making layouts of books of hundreds of pages.
The end game is not to have something 100% automated, but rather a tool box and a routine that can help speeding up the layout process, saving time, saving costs etc.
I've got in my hands :
- 1. A word file. Text is tagged and has already some styles set up. Tags encapsulate the mains sections.
- 2. A "template", being an indesign file with all the design (Masters / graphics / Styles etc.)
- 3. No urgency. Time is at my side. No stress here… but I won't sleep until it's done…
My understanding so far
- I can not hope to make magic out of Extendscripts only.
- Indesign servers are meant to achieve such things. But cheap solutions are of the essence. It's a no go then.
- Plugins and C++ coding could help me at some point. That goes deeper in ID objects management. I'm not afraid of going there if really needed (ignorance is bliss, isn't it?)
- I need better understanding of how I can handle objects in ID via scripting
- UXP scripting for ID is still lagging behind in terms of possibilities compare to Extendscript (so far, in 2025)
- IdExtenso could help me out and I need to get to know it more.
- No Data merge tools are relevant here. No variables are needed.
- Typefi free tools for textframe adjustments will be helpful (https://www.typefi.com/autofit/)
My questions
- What is the main strategy I should focus on?
- Can I aplpy Masters based on content, then cut texts, place Textframes in specific positions?
- Can I place a picture based on a tagged text with (name of picture), and create a strategy of position depending of the dimensions / ratio HxL of the pic?
- Is it possible to adjust the textframes depending of the Master applied, after the text has been deployed?
My current focus.
- Scripts for cleaning the text
- Interpreting/ changing Word styles to ID ones.
- Creating formating rules to apply ID styles to specific paragraphs
- creating side scripts that serve as tools for complex local formating that can't be done on a large scale
Thanks for you patience and to the ones that would be happy talking about that topic
Fred.L
Copy link to clipboard
Copied
In short - pretty much everything you can click in the InDesign - you can do through scripting.
There are some Dialogs that can't be accessed / controlled through scripting - but they still use the same properties and do the same operations that are available through scripting.
Copy link to clipboard
Copied
Hey Robert,
Thanks for the reminder, I certainly agree with you. Sometimes, it's even the other way around. Some properties well hidden are sometimes discovered and brought under the light by our notorious experts, like M.Autret with stylighter. (just an example from the top of my head)
I would then say that what is provided by ID can be manipulated via scripts, but some many others things too.
Copy link to clipboard
Copied
Hi @Fred.L , You can browse the ExtendScript API here:
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Document.html
Copy link to clipboard
Copied
Hey,
Thanks for your reply. I 've kind of gotten to that page everyday for the past two years ^^
Sooo useful, can't be overlooked
Copy link to clipboard
Copied
Really enjoyed reading your post. It’s refreshing to see someone diving into automation not with the goal of pushing a magic button, but building a toolbox that helps speed things up while keeping control over the design. That mindset alone will save you from a lot of the headaches that have tripped up many along the way.
You're already off to a solid start: having structured Word files with tags and a clean InDesign template is half the battle. The real wins come from having a clear workflow in mind, then building your scripts or tools to serve that workflow, rather than the other way around. The ability to step back and ask “what’s the smartest way to get from A to B?" - perhaps it's a script, perhaps it's building solid InDesign Templates, or working in a book file so you can sync all your styles.
A few thoughts from experience
Start small, script often
I have a built up a library of building blocks of scripts over the years. Some grafted from other scripts, some built with limited knowledge and a can do attitude (although many times people have helped me and shown better ways to do it which is fantastic).
When the goal seems complex, break things into small repeatable tasks. Scripts that do one job well like cleaning up Word junk, mapping styles, or tagging images are more useful (and easier to debug) than some beast of a script trying to do it all.
Build up your toolbox in layers.
Lean into tagged structure
You mentioned your text is tagged. Brilliant. That might open up a lot of automation potential from applying Parents, to placing images, to deciding where content lands on the page. If your tags follow a pattern, it could drive layout decisions.
Parent pages
You should be able to apply Parents based on tagged content and it might be worth testing. For long books, that alone can shave hours off. Just make sure your Parents are well structured, named frames, predictable guides, consistent styles etc.
Images: think in ratios, not just names
Placing an image based on a tag like “(Image:Name)” works great when paired with logic that checks the image’s dimensions. Portrait? Goes in the sidebar. Landscape? Full width maybe. Thumbnail might be top left text frame. Build rules based on image shape, not just filename. It’s smart and scalable.
I don't know much about InDesign Server or plugins
Perhaps you're right to skip InDesign Server for now. Unless you’re building a web app or a large-scale publishing system, ExtendScript should be more than enough. C++ or UXP might come later but for book layout automation, ExtendScript is still probably your best bet.
Post-layout tweaks are totally doable
Yes, you can adjust textframes and layout after the text is flowed. That’s often where the finesse comes in. You've already fond the Typefi tools can help with frame resizing and overflow fixes but you can also roll your own little frame fitters or balancing scripts.
Best advice - stay modular - as said before
It's easy to overlook, avoid making one mega-script. Instead, build little helpers. One for cleaning text, another for applying styles, one for images, one for layout tweaks. That way, you can test each step, reuse them, and mix and match.
I'd say your current focus is exactly where I’d start. Clean the input, standardise styles, build rules, and only then look at layout automation. The fewer surprises in your base content, the more confidently you can automate the rest.
If you haven’t already, look at Marc Autret’s work on Indiscripts, Peter Kahrel, Tomaxxi, not sure who else (sorry not naming dropping anyone else brain is fried) - all have a good library of scripts (I tend to find with searching the internet) and there are some of the JSX examples floating around the community they’re great for learning how to think strategically in scripts, not just code mechanically.
Happy to chat more as you go let us know how you get on.
All the best
Copy link to clipboard
Copied
Hey Eugene,
Wow thanks for the extensive reply. I kind of hoped to get something like this ^^
I do believe versatility is key. I don't believe in full automation. Control and adaptabilty is something that I have more in mind. I've relied so far on routines that have about 5-10 scripts that need to be run one at a time, as a sequence. Having them as separate files is nice, as I can check if everything is ok. And then I move on to the next.
I'm scripting about 2h/d, testing, improving and changing strategies on the 100+ scripts I've made so far. This is why I'm understanding that strategies are key. I managed to make a few scripts 20 times faster just by changing the strategy used in dealing with the datas. Learning from the community helps to get a proper benchmark on what can be done.
Having seen videos from Typefi (after being curious of P.Kahrel story) and the way they handled datas, help me understand the importance of tagging as many things as possible. There is a balanced to be found there though, in our workflow. I get these tags from authors/ writers. But I can only ask for bulk ones (Sidebars / tech parts / Comments / etc.) That + Styles applied in Word (about 10, only) are the material I've got. I cannot ask for more.
> Parent pages
> You should be able to apply Parents based on tagged content and it might be worth testing. For long books, that alone can > shave hours off. Just make sure your Parents are well structured, named frames, predictable guides, consistent styles etc.
Thanks for the tips. I need to digest that, understand the underlying possibility of all them.
> Images: think in ratios, not just names
Sure. Thanks.
That was my intent. With the name, I get the file. With the file, I get all the datas I need to build a strategy for placing it where it should be.
> Post-layout tweaks are totally doable
I was thinking of using Scrips labels, this undervalued possibility of naming frames/ objects. I could place these labeled objects on my Masters and use them as references for adjusting the frames within the layout (via scrips obviously)
Any idea about it?
> Best advice - stay modular - as said before
Absolutely.
Something I propably need to think of in depth is the use of global variables. If my scripts are meant to work with one another, I should probably store some datas in a global way so that every scripts can reach them.
Being French, I certainly know my fellow gurus, being M.Autret (can I say I'm the one who kindly asked him to update Smartsort to what it is now?), JC Tremblay, J.L Tournier (who btw wrote a very interesting book about dealing with long documents) and some others like P.Kahrel. I've had no problem talking to them and I'm very grateful they not only replied to me but even helped me with my scripts or demands. I won't stop thanking them.
> Happy to chat more as you go let us know how you get on
Thank you
I will
Copy link to clipboard
Copied
You can add hidden labels to pretty much every object - including Document and Application - so you can avoid situations when someone accidentally edits labels - and avoid configuration TXT files on your drive.
Copy link to clipboard
Copied
@Eugene Tyson I didn't see anything in the tagged text manual about page structure, including parent pages. It was all text and table formatting. Do you have information on other tags?
Personally, I found tagged text most useful when getting text from a database and exporting with the tags. I don't think I would bother for existing Word documents.
There is a add-on that lets you apply parent pages based on paragraph styles (and object styles) at:
https://www.id-extras.com/products/mastermatic/
Copy link to clipboard
Copied
Tagged Text is only about Text formatting - there is nothing there about any aaspect of page or graphic objects.
Copy link to clipboard
Copied
Tagged Text is only about Text formatting - there is nothing there about any aaspect of page or graphic objects.
By @Robert at ID-Tasker
I know--that's what I said. I was responding to this sentence:
"You should be able to apply Parents based on tagged content and it might be worth testing."
Copy link to clipboard
Copied
You're right - not directly - but as the OP was looking at scripts it might be and should be scriptable, so Section Headers might have a different Parent Page - I've requested this as a feature request before, to be able to assign a Parent Page with a Paragraph Style. So if you have Section Header and the attribute is Parent Page C then it applies that - I think I did before, maybe it was something similar.
So I had something similar had to go to my dropbox and dig it out - but found them. So you can target and paragraph style or tagged text to apply a Parent Page.
<edit - these need to be tweaked so that when Section Header doesn't appear on the page it shifts to the other Parent Page ---->>> Maybe I haven't thought this through ---<<<< needs more testing and obviouslly how it will be used ---->Maybe buid in fail safes so that if no header style and only body text it reverts to other parent page - but the proof is in the pudding>
This one changes Section Head paragraph style to B-Parent Page for example
(function () {
var doc = app.activeDocument;
var styleName = "Section Head";
var parentName = "B-Parent";
var master = doc.masterSpreads.itemByName(parentName);
if (!master.isValid) {
alert("Master spread \"" + parentName + "\" not found.");
return;
}
var pagesChanged = [];
for (var i = 0; i < doc.textFrames.length; i++) {
var tf = doc.textFrames[i];
var pg = tf.parentPage;
if (!pg || !(pg instanceof Page)) continue;
var paras = tf.paragraphs;
for (var j = 0; j < paras.length; j++) {
if (paras[j].appliedParagraphStyle.name === styleName) {
if (pg.appliedMaster !== master) {
pg.appliedMaster = master;
var pgName = String(pg.name);
if (pagesChanged.join().indexOf(pgName) === -1) {
pagesChanged.push(pgName);
}
}
break;
}
}
}
if (pagesChanged.length) {
alert("Applied \"" + parentName + "\" to pages: " + pagesChanged.join(", "));
} else {
alert("No paragraphs with style \"" + styleName + "\" were found on any page.");
}
})();
Similary if you have Tagged Text in InDesign
You can target it with a script to apply a parent page
(function () {
var doc = app.activeDocument;
var tagName = "Section-Header";
var parentName = "B-Parent";
var master = doc.masterSpreads.itemByName(parentName);
if (!master.isValid) {
alert("Master spread \"" + parentName + "\" not found.");
return;
}
var elements = doc.xmlElements[0].evaluateXPathExpression("//" + tagName);
var pagesChanged = [];
for (var i = 0; i < elements.length; i++) {
var el = elements[i];
try {
var text = el.markupTag.name === tagName ? el : null;
if (text && text.insertionPoints.length > 0) {
var ip = text.insertionPoints[0];
var pg = ip.parentTextFrames[0].parentPage;
if (pg && pg.appliedMaster !== master) {
pg.appliedMaster = master;
var pgName = String(pg.name);
if (pagesChanged.join().indexOf(pgName) === -1) {
pagesChanged.push(pgName);
}
}
}
} catch (e) {
$.writeln("Error processing element " + i + ": " + e.message);
}
}
if (pagesChanged.length) {
alert("Applied \"" + parentName + "\" to pages: " + pagesChanged.join(", "));
} else {
alert("No XML elements with tag \"" + tagName + "\" were found on any page.");
}
})();
Copy link to clipboard
Copied
Thanks Eugene for sharing these 2 pieces. I kind of feel it's Christmas now…
I'll be honest, I've never used this tag panel before. Now, I've just read a few things about it and I already understand that tags can be applied to almost everything. Texts, tables, objects, graphics, etc. This is great. Since I can even apply tags via F/C queries, they can be applied very quickly, obviously via script as well.
In short, now, I've got quite a few toys to play with and I'm ready to build a strategy for doing a proper layout.
Thank you very much. You helped me get to the next level ^^
Copy link to clipboard
Copied
Just in case, those XML tags are "all or nothing" - if you use the same tag in multiple places in the XML structure - like a "date" for a day - in body text, in a cell in table or in Anchored TextFrame - it will be tagged the same everywhere - and you can't assign different Char / ParaStyles to each location / instance.
Copy link to clipboard
Copied
Excellent - no problem at all - just a few ideas to increase the automation.
I've had several magazines/books/reports that require the additional push of parent pages, and doing it manually was a pain especially with text reflow.
Basing Parent Pages on styles used in the document is a great idea, but sadly not implemented.
So we can push the parent pages with scripts.
It could definitely do with some fine tuning to catch all. But as always, proof of concept is better than wondering.
Copy link to clipboard
Copied
Just an FYI: Adobe FrameMaker can apply master pages based on style usage. I wish InDesign would get more long document features from Frame.
Copy link to clipboard
Copied
...
My current focus.
- Scripts for cleaning the text
- Interpreting/ changing Word styles to ID ones.
- Creating formating rules to apply ID styles to specific paragraphs
- creating side scripts that serve as tools for complex local formating that can't be done on a large scale
...
Most of this can be accomplished without scripts.
-Word macros can clean up the text. While the macros are scripts, the macros can record your actions, making their creation and editing much easier.
-InDesign has the ability to save the Word paragraph and character styles to ID styles, so import is fairly easy. I do recommend you select all the Word text after importing and removing overrides.
(You mentioned tagging the text--some people use this as a term for applying styles. ID does have a tagged text feature too. Can you clarify your terminology?)
-If you apply your styles in Word, you shouldn't need to do much else. However, it is not always practicable to format everything in Word. For that you can use the free plug-in to so some find/changes:
https://www.automatication.com/product/mfc/
-With nested styles, GREP styles, next styles automation, most of the complex formating can be handled automatically. The find/change can usually deal with everything else.
Copy link to clipboard
Copied
Hey Dave,
Thanks for the reply, much appreciated.
>>> Most of this can be accomplished without scripts.
Well, I didn't provide any example to illustrate my point, but I can assure you MS Word cannot do most of what I'm implementing with ID scripts. There are just too many things belonging to ID properties. I've got many Grep queries for cleaning up the text, and Clearing overrides is indeed not an option, it's just mandatory.
However, I totally agree about macros being useful in MS Word. As a matter of fact, we use them. I provided a bunch of macros (and the procedure for installing them as buttons on the ribbon) and not enjoyed so much the fact that VBA Mac & PC are not 100% compatible, despite being the same language. For a few of the macros, I had to make a special PC compatible version (I'm on Mac, as you figured). So annoying.
We use Macros only for running check-ups and bring valuable pieces of information though. Verifying the presence and integrity of tags (open/ close properly), illustrations not appearing multiple times and using proper structure (Like not jumping from Heading 1 to Heading 3 - ID Toc and PDF Bookmarks not being very good at dealing with such things), tags for future Xrefs … and so on.
We experienced that at the end of the day, authors/ writers should focus on the content, not too much on the format. Providing tools to help them do a full check-up on their document is as far as we can go.
>>> You mentioned tagging the text--some people use this as a term for applying styles. ID does have a tagged text feature too. Can you clarify your terminology?
Good point, I may well be using the word the wrong way and confusing people.
I'm using the expression of tagged text to identify blocks of paragraphs in the document, parts that I need to be tagged in for a later use, somehow, in ID.
I'm in the boardgame industry, and books are closer to a technical user manual than a novel. Parts of text are technical-oriented (and need to be formatted a certain way), some others are sidebars, text in margins, etc. Tags are essential to identify where the texts are supposed to go. It is not as thorough as an XML file (this could be done though, sure), but it's good enough. In conjunction with paragraph styles, a MS Word file can already bring a lot of information.
I very well know about Multi/ Find Change. It's a great tool when it works. I've used it for about 2-3 years, but the plugin can be a temperamental child at times. And you can only install it a certain number of times (when you can. Sometimes, you cannot validate the license). After that, you have to purchase it again. I'm working on 3 Mac computers, and I clean install the OS at least once a year, change the hardware in between… well, the way the plugin is shared doesn't work for me anymore.
>>>nested styles, GREP styles, next styles automation
- Nested styles. I try to stay away from nested styles. They pretend to be your friend, but broad solutions on a 200+ pages document are usually not good solutions, speaking from experience there. In the end, I don't see the point of using them. Grep styles can do the same and much more. So why bother?
- Grep styles are nice if you use them carefully, more versatile.
- Next styles automation is great, especially (if not only) in conjunction with object styles. You can automate the formatting of a lot of stuff once you put on a specific pattern on the table. (thanks CreativePro https://shorturl.at/56Plg)
Fred
Copy link to clipboard
Copied
Your question and discussion brings many thoughts to mind:
AI, so far, cannot do any page layout work. I marvel at that.
More practically, since you mention you have "tagged text" then you might be interested in reading a free guide that Adobe published named "InDesign CS4 Tagged Text Guide" last updated in 2009. Since that feature hasn't changed, the info in this guide should be good to work with. I know of no other newer guide (if you do know of a newer version, let me know).
Another thing to ask yourself: Are you familiar with all the automation methods that already exist within InDesign? There are currently, by my count, 34 different preset automations that you can call upon to automate what you do. Simply understanding paragraph styles thoroughly is half the automation battle.
Scripts are fantastic. I think the one I use the most consistently is among the pre-installed scripts from within Adobe InDesign: "Find/Change by List". Over the years, I have improved that flawed script so that it can clean 3X the number of typesetting issues as the original script, all without harming any typesetting already done. Of course, anyone familiar with GREP and F/C routines can do that since the script is meant to be editable anyway. When typesetting is scrupulously clean, you gain the benefit of saving time in the editing cycles (the slowest part of what we do; yet the most important).
Copy link to clipboard
Copied
Hey Mike,
Thanks for the reply.
>>> Since you mention you have "tagged text," then you might be interested in reading a free guide that Adobe published named "InDesign CS4 Tagged Text Guide."
Thanks a lot for that. I didn't know something like this existed. I'll have a look.
As I mentioned above, I may have used tagged text in a naive way. Real text tagging is for now a bit overkill for what I want to achieve. I'm not sure it is relevant at this point to have that level of control on the text. I want to keep everything as natural as possible, and I consider MS Word documents as raw material and ID being the manufacturer that will polish the text. Still, I admit needing some more information than just raw texts without any kind of styles and tags. We'll see how it goes with that strategy soon enough ^^
>>> Adobe InDesign 2025 tour of 32 presets, styles, automations
Thanks for the tip. Didn't know about this one either ^^
I'll have a look. I don't know what I should expect from it though. Any personal insight you'd like to share?
I back up my ID profile regularly, meaning I hold on to many presets already.
Besides, Keith Gilbert did an amazing job listing all the settings that we could gather via scripting. Once adapted to your workflow, fear of setting up again the data is gone. (https://gilbertconsulting.com/scripts - See setup script)
>>> Find/Change by List
Thanks. I actually know that script very well. I've used it a few times, but it is probably one of the reasons I went to using the Query manager from P. Kahrel (https://creativepro.com/files/kahrel/indesign/grep_query_manager.html)
So much more we can do with it, faster, more versatile, edit queries on the fly, create & save groups of queries. A marvel.
Copy link to clipboard
Copied
In addition to all the other great comments here (from some real experts in the field!), you might also want to look at TypeFitter from Typefi. It's a big time-saver for books in particular - for automatically fixing all sorts of issues with your copy.
(Full disclosure - I wrote the original version of it, but I'm not involved in it now, other than as a fan.)
Copy link to clipboard
Copied
Hey Lawrence,
Thanks for your reply
Typefitter sounds quite interesting. Thanks for the tip. I'll have a look and see if that can be used as a replacement of the scripts I've got in hands ^^