Copy link to clipboard
Copied
Hi,
Is there a differnce in the find / replace routines between desktop and server version of InDesign? I know it should work the same way as in the interface, and it does work when running on the desktop version.
I'm trying to replace a character sequence (a previously "encoded" indent to here) with the real "indent to here" special character.
This works in desktop as well as server versions:
app.findTextPreferences.findWhat = "roof-i";
app.changeTextPreferences.changeTo = "roof-a";
app.changeText();
(replacing the word "roof-i" with the word "roof-a")
But this does not work, nothing happens in the Server version:
app.findTextPreferences.findWhat = "roof-i";
app.changeTextPreferences.changeTo = "^i";
app.changeText();
However, on my client tests with the script, the word roof-i becomes the real indent to here special character, just as when writing ^i in the find/change dialogue.
Is there something special to regard when replacing special characters on the server version. I've also tried using the grep version, changeTo set to ~i instead, but with the same results (nothing happens on the server).
Best regards,
Andreas Jansson
Copy link to clipboard
Copied
Hi Andreas,
Nothing should happen in either case--you need to address the document, story, or text you want to perform the find/change operation on. This line:
app.changeText();
...should be something like:
app.documents.item(0).changeText();
I do see the special character in the list of special characters for InDesign Server (SpecialCharacters.indentHereTab), so it should work.
Thanks,
Ole
Copy link to clipboard
Copied
Ole,
>Nothing should happen in either case--you need to address the document, story, or text you want to perform the find/change operation on
app.changeText() and app.changeGrep() target all open documents: they are the equivalent of picking "All documents" in the Find/Change dialog.
Peter
Copy link to clipboard
Copied
My problem is that the ^i does not result in the indent to here, on the server version.
(I do have a story object to send to my replace function, but for simplicity I used the app.change... call while testing - it made no difference to use the story object, still no replace on the InDesign server version.)
I thought about using the special character like this: app.changeTextPreferences.changeTo = SpecialCharacters.indentHereTab;
...But I read in another thread that you should use the same characters as in the user interface in InDesign (in this case ^i or ~i for grep), and that should be the way as I see it. Using SpecialCharacters.indentHereTab results in error
" Invalid value for set property 'changeTo'. Expected String or NothingEnum enumerator, but received 1397319796. "
Andreas
Copy link to clipboard
Copied
Perhaps there is a problem with special character escaping. Try with double or triple '^' (in regular text find) or '~' (in GREP find). Or insert them as hex characters: <005E> and <007E>.
Copy link to clipboard
Copied
I was trying with double and triple ^ prefix on the server script for text replace now. Here are the results:
app.changeTextPreferences.changeTo = "^^^i";
results in ^roof-i
So there is no "indent to here" character inserted, and the text to find was not removed, only prefixed with ^. Very strange.
app.changeTextPreferences.changeTo = "^^i";
results in ^i
No "indent to here" character inserted. The word to find has been replaced.
(Thanks for the input on special characters, I will have to check them one by one to determine whether they are valid to encode to XML).
More tests:
app.changeTextPreferences.changeTo = "<005E>i";
Results in ^i
The same as when prefixing with double ^, that is.
Copy link to clipboard
Copied
If you use changeGrep instead of changeText, does it work any better?
Harbs
Copy link to clipboard
Copied
I got the same result with grep, testing yesterday, but I could try all of the combinations with grep too (double~, triple~, hex). Will check that up and write back here in a while.
Copy link to clipboard
Copied
app.changeGrepPreferences.changeTo = "<007E>i";
results in <007E>i
~i
results in no change at all
~~i
results in -i
~~~i
results in -roof-i
I'm not sure why it's a - and not a ~ in the results. Anyway, the results are fairly similar to the text replaces tried above.
Perhaps I could use the find function to find the texts, and then insert the special characters on those positions. Or are there more other ideas for a work-around using changeText/changeGrep?
Best regards,
Andreas
Copy link to clipboard
Copied
Perhaps I could use the find function to find the texts, and then
insert the special characters on those positions.
Yes you can. That's the way I'd work around this problem.
for(var idx=0;idx<finds.length;idx++){
finds+.contents = SpecialCharacters.INDENT_HERE_TAB;
}
Harbs
http://www.in-tools.com
"Automated Publishing for the Rest of Us!"
Copy link to clipboard
Copied
When this did not work either, I realized that there had to be something else wrong with the server scripts. I found a logic error in my coding, reversing the replace before I got the result, and also leaving the wrong results in the document. I'm so sorry that I bothered you all with this
. The normal changeTo ^i (same as desktop) works fine on server as well.
Thank you all, you have been most helpful.
-- Andreas
[I'm not sure about the points awarded - I'd like to give you all helpful-points but I set the question as answered now, and then the points system disappeared as the question was resolved.]
Copy link to clipboard
Copied
Another related question: Do these (SpecialCharacters.reflect.properties) make up the complete list of characters that InDesign can not encode to XML?
The reason for my need to temporarily replace some characters with something else (and then replace back to the special characters again) is that I get this message from InDesign when these characters are contained in tagged text. "Content contains characters which cannot be encoded".
I've been looking for a list of characters that I have to handle, but only been able to find out that some special characters can not be encoded. The help file states: "Avoid tagging special characters, such as the Automatic Page Number character. When exporting, InDesign strips out some special characters to comply with XML standards. InDesign warns you when characters cannot be encoded in XML."
-- Andreas
Copy link to clipboard
Copied
The Special Characters appears to me as a somewhat random collection of 'spare parts' that could not be included somewhere else. For some characters there is no reason at all to be here (bullet, copyright, degree) because they have a well defined code point in Unicode. The spaces could be defined by Unicode as well, as most of them also have Unicode values (if I'm not mistaken, Adobe added some new ones).
Browsing through the list, I'd single out those that generate text, rather than display a character:
and special break types (not sure, but I don't think these have Unicode values):
Safest way to check is ... put them all in an InDesign document and export that to XML -- then open that in a Unicode aware editor and check what you got ![]()
Find more inspiration, events, and resources on the new Adobe Community
Explore Now