CreativePro Forum
Join our community of graphic designers, publishers, and production artists from around the world. Our members-only forum is a great place to discuss challenges and find solutions!
- You must be logged in to reply to this topic.Login
Apply color to all tracked changes in Story Editor
Tagged: color, story editor, swatch, track changes
- This topic has 30 replies, 3 voices, and was last updated 2 years ago by
Steven Grey.
-
AuthorPosts
-
-
April 20, 2017 at 5:07 am #93781
Alexandro Cuperus
MemberHello everyone!
Is there any way/script to automatically apply a certain color to all the tracked changes in an InDesign document? This is mainly to be able to somehow track the changes (at least what was added) when exporting to .pdf.
Or is there any GREP syntax that can search for all the tracked changes? If yes, this could be done automatically through the find/change option directly.
Thank you very much!
-
April 23, 2017 at 3:53 pm #93861
Peter Kahrel
ParticipantTrack changes isn’t exposed in the Find/Change window, but you can add a character style to additions with the following one-liner (first create a character style called change and set any formatting):
app.documents[0].stories.everyItem().changes.everyItem().characters.everyItem().appliedCharacterStyle = app.documents[0].characterStyles.item(‘change’);
Peter
-
April 24, 2017 at 11:01 pm #93870
Alexandro Cuperus
MemberThanks for the reply!
Setting character styles is out of the question since most of the text will already have a character style applied to it, be it italic, bold or other (nested) combinations.
Thank you again for your suggestion! Seems that only a complex script will solve the problem.
-
April 25, 2017 at 12:05 am #93872
Peter Kahrel
ParticipantDoesn’t have to be complex (or even a script). You can apply some form of highlighting as a local override, e.g. underline.
-
April 25, 2017 at 12:18 am #93873
Alexandro Cuperus
MemberThis is how I do it now. I typeset documents with lots of modifications that come from InCopy files, and I have to mark them in some way so the editor sees them in .pdfs. I make them magenta as a local override, but it takes a lot of time for 2000 pages books to go through each modification manually and set that color. (Open story mode, find next modification [Ctrl+Page Down], apply magenta. Repeat).
That’s why I thought that if I can do that, a sort of script/macro could do it faster.
Unfortunately colors can’t be assigned to a keyboard/mouse shortcut like para/char styles. I could work some macro on that.
-
April 25, 2017 at 1:03 am #93875
Kai Rübsamen
MemberAlexandro, if you do it in your way, you highlight only additional and not removed text? If this is enough for you, conditions could also work:
(function() { var curDoc = app.activeDocument; if (!curDoc.conditions.itemByName("Highlight").isValid) { var colorToHighlight = curDoc.conditions.add( {name:"Highlight",indicatorMethod:ConditionIndicatorMethod.USE_HIGHLIGHT, indicatorColor:UIColors.YELLOW} ); } else { var colorToHighlight = curDoc.conditions.itemByName("Highlight"); } curDoc.conditionalTextPreferences.showConditionIndicators = ConditionIndicatorMode.SHOW_AND_PRINT_INDICATORS; curDoc.stories.everyItem().changes.everyItem().characters.everyItem().appliedConditions = [colorToHighlight]; } () );
Edit: It seems also possible to loop through all changes and different changes have a different type, e.g. changeType = DELETED_TEXT. So a more or less complex script could set a flag, draw a frame or whatever at this location or could even display the deleted text …
Kai
-
April 25, 2017 at 1:37 am #93877
Alexandro Cuperus
MemberHello Kai,
you are indeed a master of your craft. I’ve been reading your posts for quite some time and you provide excellent scripts. Thank you for replying.
Your sample script is almost too well done, because I can’t find a way to remove the yellow highlight if I want to. This is why I usually changed the font color from black to magenta, so the manual override could be reverted at any time with ease.
In terms of what to track, the most important is the added text, since that’s what’s showing when the layout is done. If they want to check in depth I can always provide an InCopy .pdf that shows everything.
But if it’s easier to script so it adds magenta to everything (deleted and added text) it’s no problem at all.
Thank you again for your invaluable help!
-
April 25, 2017 at 1:43 am #93878
Peter Kahrel
ParticipantCondition highlights don’t show in a PDF.
If you want to apply a colour you can use this one-liner:
app.documents[0].stories.everyItem().changes.everyItem().characters.everyItem().fillColor = app.documents[0].swatches.item(‘C=0 M=100 Y=0 K=0’);
This uses the default colour ‘C=0 M=100 Y=0 K=0’ — make sure it’s there, or use any other colour.
Peter
-
April 25, 2017 at 1:49 am #93879
Kai Rübsamen
Member> Condition highlights don’t show in a PDF.
Peter, if the condition is applied to visible text and you use “ConditionIndicatorMode.SHOW_AND_PRINT_INDICATORS”, I can see here the hightlighting in a PDF.
Kai
-
April 25, 2017 at 1:54 am #93880
Alexandro Cuperus
MemberJust exported a test .pdf with Kai’s script and it does export with the yellow highlight.
Also, tried to run the one liner script, but it errors out. :(
-
-
April 25, 2017 at 1:57 am #93881
Kai Rübsamen
MemberAlexandro, Peter gave you this one line for adding local Magenta.
I think, the benefit of conditions are, that conditions are easier to control than local styling. Did you see the conditions-panel with the dropdown and those 3 options? If you want to remove the condition from special words, highlight the word and click on “unconditional”.
Kai
-
April 25, 2017 at 2:00 am #93882
Kai Rübsamen
MemberAlexandro, it seems, that for Peters version the quotation marks are messed up. This can happen during copy/paste > should be straight ones.
-
April 25, 2017 at 2:07 am #93883
Peter Kahrel
Participant> if the condition is applied to visible text and you use “ConditionIndicatorMode.SHOW_AND_PRINT_INDICATORS”, I can see here the hightlighting in a PDF.
Ok.
-
April 25, 2017 at 2:19 am #93884
Alexandro Cuperus
MemberThank you so much to both of you. I now have two lucrative scripts that work excellent.
I think I’m not the only one that needs this sort of stuff, so maybe an article on the website would make it more popular (or even come up with new ideas).
Thank you again!
-
April 25, 2017 at 2:52 am #93885
Kai Rübsamen
MemberGood to know, that both solutions are helpful :)
It seems not to be possible, to add a shortcut to “Unconditional”. But we can script this command and give the script a shortcut:
(function() { var curSel = app.selection[0]; if (!(curSel && curSel.hasOwnProperty ("baseline")) || curSel.constructor.name == "InsertionPoint") { alert("Select some text with a condition!"); return; } if (curSel.appliedConditions.length > 0) { curSel.applyConditions([], true); } } () );
-
April 25, 2017 at 3:00 am #93886
Alexandro Cuperus
MemberWorks as intended, although I think that usually after all the modifications are made they just select the whole text (Ctrl+A) and revert to normal color (which the script doesn’t seem to do). So they could just go to the Conditional text and delete the highlight from there.
Thank you for the extra morsels! I think everything could be clumped together in a single script with dropdown choices too if you want to get fancy with it :) -
April 25, 2017 at 3:17 am #93888
Kai Rübsamen
MemberAlexandro, the last script is only for single words, if you want to exlude the highlight in the PDF. If you want to delete everything at the end, simply delete the condition. I have no desire for building a dialog with a dropdown at the moment ;-)
While this seems to work for track changes, I can see another use case for conditions: marking words for an index. At the moment I’m working on a book with 250 pages and the author used a character style with magenta for highlighting words. Allthough I talked to him, only apply the style to words with black, he applied the style also to paras with gray or other color and messed up the complete document. So either use local styling or a condition.
-
April 25, 2017 at 3:33 am #93889
Alexandro Cuperus
MemberIndeed, this is why I avoid character styles altogether to highlight changes. They’re not for temporary stuff and it’s a hell to fix them, especially in books with lots of para and char styles.
Using conditional text hasn’t really crossed my mind until now, and you are totally right: it can prove very useful and nondestructive.
Although I am sad that they can’t have keyboard shortcuts. Dunno why Adobe restricted shortcuts to only a few ‘applicable’ characteristics of the text, like para, char and table styles. Would’ve loved to have some for Swatches or even conditional text (although the latter can be applied through quick apply).
-
July 20, 2017 at 9:51 am #96235
Alexandro Cuperus
MemberHello everyone,
coming back with an update regarding the scripts, which I have been using with some success for the past months.
The only problem I encountered that I have no idea how to fix is that on bigger files, with (maybe) many changes made, when running the scripts (either Kai’s or Peter’s, using the latter most), InDesign just freezes. I’ve left if even 30 minutes to ‘do its thing’, but it just remains frozen, eating about 25% of the CPU power, like its doing something.
Any ideas why this happens and if there is a workaround?
I can’t thank you enough for the help!
-
July 20, 2017 at 10:00 am #96236
Kai Rübsamen
MemberHi Alexandro,
InDesign has some problems with tracking and speed. I hear such freezing from the InCopy-corner. Peter and I use the everyItem() function. I would assume, that it could speed up things, when we use an array instead.
Can you please provide a example with e.g. 50 or 100 track changes. It would then be possible to test both methods against a timer.
Kai
-
July 20, 2017 at 10:16 am #96237
Alexandro Cuperus
MemberThank you for the fast reply. Is there an e-mail where I can send you a file? I can’t really release them in the open…
-
July 20, 2017 at 10:25 am #96238
Kai Rübsamen
MemberYou can sent it to forum@ruebiarts.de. Please provide a idml, not indd.
-
July 20, 2017 at 10:37 am #96239
Alexandro Cuperus
MemberIDML file sent.
-
July 20, 2017 at 12:34 pm #96240
Kai Rübsamen
MemberSome interesting stuff!
Alex has about 1200 conditions on 70 pages. With the line from Peter
app.documents[0].stories.everyItem().changes.everyItem().characters.everyItem().appliedCharacterStyle = app.documents[0].characterStyles.item(‘change’);
there is no result and I crashed InDesign after 15 minutes.
var curDate = new Date(); var oldStamp = curDate.getTime(); var allChanges =app.documents[0].stories.everyItem().changes.everyItem().getElements(); var nChanges = allChanges.length; for (var i = 0; i < nChanges; i++) { var curChange = allChanges[i]; var nCharacters = curChange.characters.length; if (curChange.changeType == ChangeTypes.INSERTED_TEXT) { for (var j = 0; j < nCharacters; j++) { curChange.characters[j].fillColor = "Magenta"; } } } var curDate = new Date(); var curStamp = curDate.getTime(); var difSec = (curStamp-oldStamp)/1000; alert (difSec);
122 seconds
var curDate = new Date(); var oldStamp = curDate.getTime(); var allChanges =app.documents[0].stories.everyItem().changes.everyItem().getElements(); var nChanges = allChanges.length; for (var i = 0; i < nChanges; i++) { if (allChanges[i].changeType == ChangeTypes.INSERTED_TEXT) { allChanges[i].characters.everyItem().fillColor = "C=0 M=100 Y=0 K=0"; } } var curDate = new Date(); var curStamp = curDate.getTime(); var difSec = (curStamp-oldStamp)/1000; alert (difSec);
30 seconds!
So it seems, that a combination of everyItem() AND getElements() + counting the length of something outside the for-loop is much faster.
Kai
-
July 20, 2017 at 12:55 pm #96241
Alexandro Cuperus
MemberI can only thank Kai again for his amazing help. All that he did is sorcery to me, but it works flawlessly. I hope this script will prove useful for anyone else that wants to put their time in the actual design process of the layout, rather than wasting it with boring (but sometimes necessary) tasks.
-
January 14, 2022 at 4:53 am #14356601
Sibren van der Burgt
ParticipantHelp with tables wanted: How to color/underline all text changes in tables?
Found this page and use the script. It is working very well for underlining all the tracked text changes in Indesign 2022.
This is working great for regular text, but not for text in tables. And I work with financial reports filled with tables.How to color/underline all text changes in the tables?
Would be great if this can be resolved.
Sibren
-
January 19, 2022 at 3:10 pm #14356783
Sibren van der Burgt
ParticipantThis is solved by Brian Pifer of designtimesolutions.com
I changed the first line to:
var allChanges = app.documents[0].stories.everyItem().tables.everyItem().changes.everyItem().getElements();
-
January 19, 2022 at 3:14 pm #14356784
David Blatner
KeymasterAwesome! Thanks for coming and letting us know, Sibren.
-
-
August 8, 2023 at 11:59 am #14394832
Steven Grey
ParticipantSorry. This is a very basic question. How do you actually use these? Are they saved as text files with the jsx extension and added to the scripts panel (that gave me an error)?
-
August 8, 2023 at 12:39 pm #14394833
David Blatner
KeymasterFair question… here you go:
How to Install a Script in InDesign That You Found in a Forum or Blog Post
-
August 22, 2023 at 2:27 pm #14395208
Steven Grey
ParticipantVery much appreciated! Thanks, David.
-
-
-
AuthorPosts
- You must be logged in to reply to this topic.
