Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do you export a full document as plain text, or text-based markup?

Participant ,
May 02, 2025 May 02, 2025

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?

TOPICS
How to
429
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 02, 2025 May 02, 2025

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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 02, 2025 May 02, 2025

@Thomas_Calvin

 

Put cursor in this Story.

Hit Ctrl+A. 

Hit Ctrl+C. 

Switch to Notepad. 

Hit Ctrl+V.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 02, 2025 May 02, 2025

Unfortunately I've inherited very large documents where every page is a separate story (and sometimes more than one).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 02, 2025 May 02, 2025

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.

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 02, 2025 May 02, 2025

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 03, 2025 May 03, 2025

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();
}

 

 

Screen Shot 32.png

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 03, 2025 May 03, 2025

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... 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 03, 2025 May 03, 2025

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 03, 2025 May 03, 2025

@rob day

 

OP wants to compare contents of different documents... So order of the text needs to be rather precise...

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 02, 2025 May 02, 2025
quote

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. 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 02, 2025 May 02, 2025

 

quote

[...] 

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.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 02, 2025 May 02, 2025

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. 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 02, 2025 May 02, 2025

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:

 

Screen Shot 31.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 02, 2025 May 02, 2025

That is helpful, thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 03, 2025 May 03, 2025

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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
May 03, 2025 May 03, 2025

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/

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 05, 2025 May 05, 2025
LATEST

Cool, thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines