Copy link to clipboard
Copied
I've seen several posts claiming that you can just go to File/Export and choose text. No; this option does not exist.
I have a file that's 20+ pages, all one story. I tried exporting to "InDesign Markup," which is utterly useless because it's not a markup; it's just another binary file format.
Then I tried exporting to XML, which is utterly broken. What I got, for a 27-page document, was one screenful of XML with only 11 elements that contain one line of text... text that doesn't appear in the original document! I have no idea where it came from.
Then I tried HTML, and got nothing but blank pages... albeit with the master pages' headers (which were graphics). The page count at least looked appropriate, unlike the tiny fragment of XML.
At this point I am utterly stumped as to how this tool can be used in any kind of quality-controlled workflow. I need a way to compare the text of two documents and detect where it changed. This is esssential to our work. How are we to accomplish this, when there is no way to get text out of this application?
Copy link to clipboard
Copied
This tool, that we use in all kinds of QCed workflows, is old and large, and the learning curve is steep. You only see raw text as an export option when you have text selected with the Text tool. If your layout is all one threaded story, then you can click into the story, whack Select All, then go to Export, and you'll find that you can export to Plain Text.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Unfortunately I've inherited very large documents where every page is a separate story (and sometimes more than one).
Copy link to clipboard
Copied
You did say in your initial post that your text was all one story, though.
Rob Day's recommendation for the Export All Stories script is a good one, but if you wind up with one of those long documents that has eight hundred stories in it, you might want to use a plug-in like TextStitch from Rorohiko to automatically thread those frames.
Copy link to clipboard
Copied
Thanks. That first post referred to a test file that I had already consolidated into one story. The reason I pointed the single story out was to head off any suggestions that the XML output only contained one story out of many.
Copy link to clipboard
Copied
Hi @Thomas_Calvin , Sounds like you want all of the text in one .txt file, so the script could be simpified—maybe something like this:
if(app.documents.length != 0){
if (app.activeDocument.stories.length != 0){
writeStories();
}else{
alert("The document does not contain any text. Please open a document containing text and try again.");
}
}
else{
alert("No documents are open. Please open a document and try again.");
}
function writeStories(){
//the document stories
var s = app.documents[0].stories.everyItem().getElements();
//doc name with no ext.
var n = app.activeDocument.name.replace(RegExp('()?\.[^\.]+$'), '');
//text fie path
var f = Folder.selectDialog ("Choose a Folder");
f = f + "/" + n + ".txt"
//text to save
var t = n + " Stories\r\r"
for (var i = 0; i < s.length; i++){
t += "Story ID " + s[i].id + "\r" + s[i].contents + "\r\r"
};
//write the text
writeText(f,t)
}
/**
* Write a text file
* @ param the file path
* @ param the text
*
*/
function writeText(p,s){
var file = new File(p);
file.encoding = 'UTF-8';
file.open('w');
file.write(s);
file.close();
}
Copy link to clipboard
Copied
There is one big problem with those solutions - there is no control over the order of the Stories...
And ID per document also, most likely, will be different...
Copy link to clipboard
Copied
Right, if that’s important the script would have to be more complex—going page by page maybe considering the parent frame positions. The simplified version I posted at least saves all the text into one file.
Copy link to clipboard
Copied
OP wants to compare contents of different documents... So order of the text needs to be rather precise...
Copy link to clipboard
Copied
Unfortunately I've inherited very large documents where every page is a separate story (and sometimes more than one).
By @Thomas_Calvin
Then, with my ID-Tasker tool, you'll have 100% control over every letter 😉
You don't even have to export anything - my tool can compare multiple documents directly in the InDesign.
It can even automatically open documents from a specified folder(s) - and prepare a report.
You can select which Stories to ignore or in what order to compare.
Or from which layers - in case you've multiple languages.
Or just Tables separately.
You will be able check differences on the list in my tool - or get a report.
It can even overlay pages if you want 😉
Etc. Etc. Etc.
If you don't mind - please click my nickname and send me a few sample files with more info on how would you like me to compare them and I'll send you a sample result.
Copy link to clipboard
Copied
[...]
At this point I am utterly stumped as to how this tool can be used in any kind of quality-controlled workflow. I need a way to compare the text of two documents and detect where it changed. This is esssential to our work. How are we to accomplish this, when there is no way to get text out of this application?
If you work on Windows - my ID-Tasker tool would most likely do everything you need - and way more - but isn't free.
Although, I can let you try full version for free for some time. I'll even help you configure it and add any extra functionality you would need - FoC.
Copy link to clipboard
Copied
I feel obliged to point out to you that IDML is actually zipped. Rename the extension from .idml to .zip and unpack it, and there you'll find what you might expect from XML export - a directory with all the stories as separate .xml files, among other elements.
Also, the XML file was empty, I'd imagine, because none of the page elements were tagged. You can see your current XML structure by going to View -> Structure -> Show Structure. The flyout menu from that panel will let you load XML, map styles to tags, et cetera.
Copy link to clipboard
Copied
Hi @Thomas_Calvin , Not sure if this helps, but there is also the ExpotAllStories script that will export the document’s stories to .txt files—see the Samples folder in the Scripts panel:
Copy link to clipboard
Copied
That is helpful, thanks!
Copy link to clipboard
Copied
in the InDesign scripts folders
Window>Utilities>Scripts
You should find an Exportallstories script.
Which will export all stories to a text file.
From here you can combine them into 1 file if you wish.
Which wouldn't take long - pretty sure you could combine them into a PDF and export it back to a single text file.
Or with the indesign file make a PDF and then export from PDF to a text file, maybe Word first, then save as plain text from there.
Where there's a will there's a way.
(not tested anything - just thinking out loud)
Copy link to clipboard
Copied
My Export to Word script will export an entire InDesign file to a single Word (well, really RTF) file. It stiches all the stories together first, so you end up with a single Word file with all text.
At that point, it should be easy to copy/paste the Word document into a text editor, or save as .txt.
https://www.id-extras.com/one-click-export-indesign-to-word/
Copy link to clipboard
Copied
Cool, thanks!