FORUMS: list search recent posts

Best way to export text from InDesign?

COW Forums : Adobe InDesign

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Jacki in Atlanta
Best way to export text from InDesign?
on May 1, 2007 at 12:54:08 pm

I can export text story by story. Any way to export all the text from InDesign? And what's this InCopy I'm reading about? This is something I may do regularly, so I might want a plug-in.


Return to posts index

Jacki in Atlanta
Re: Best way to export text from InDesign?
on May 1, 2007 at 6:39:02 pm

http://rorohiko.com/

I was given this on the Adobe forum, it has a text exporter for InDesign to .rtf or .txt.

Has anyone used these?

Also, more importantly, does InDesign CS3 have the capability to do this? I'll wait if it does. We'll get CS3 at some point.


Return to posts index

Mike Gondek
Re: Best way to export text from InDesign?
on May 2, 2007 at 2:44:32 pm

USing the text tool, to select a text box you can choose file >> export, and you will get the formats (.rtf, .txt).

I have not used the text exporter mentioned, so it may have more features such as exporting by pages rather than linked text.

I do often use somehting called puretext on the PC. It pastes the clipboard as unformatted text, so I can pick up the formatting from the target document in another application.


Return to posts index


Jacki in Atlanta
Re: Best way to export text from InDesign?
on May 2, 2007 at 11:23:55 pm

You can export story by story that way Mike, but I believe it does not export the whole document, which is what I want. You can export all the layout text from a pdf, but it is not formatting exactly how I need for some file comparisons. I did go ahead and download that tool and it's AWESOME. I think. Only had time to try it once. But it worked and the text was formated really nicely.

I also got the trial of InCopy and it seems like too much trouble to deal with for this purpose.



Return to posts index

Tim Cole
Re: Best way to export text from InDesign?
on May 3, 2007 at 3:08:29 am

There are Mac and Win versions of an ID script that exports all stories in a document as separate files. What's your platform?

- TC


Return to posts index

cowcowcowcowcow
Jacki in Atlanta
Re: Best way to export text from InDesign?
on May 3, 2007 at 3:51:00 am

Mostly mac. We have production pc's too though. I don't want separate. I want together, but formatted better that you get from a pdf. I think the rorohiko plugin is going to do the trick. InCopy does the export by story thing for both platforms. Not relevant for what I'm doing.



Return to posts index


Jacki in Atlanta
Re: Best way to export text from InDesign? REVISITED
on May 8, 2007 at 9:07:02 pm

OK, this plugin is listing some of the text more than once, can't have that. So I still have not solved the issue. How can I export text from InDesign to one Word doc, .rtf, or .txt? Anybody?...


Return to posts index

Tim Cole
Re: Best way to export text from InDesign? REVISITED
on May 9, 2007 at 8:29:52 pm

Jacki,

This script exports ALL of the text in an ID dodument into one text file. It's the CS3 version, but Ole Kvern, the author says it should run in CS2.

Copy and paste this into a text editor, save it as text only (i.e., not RTF) and name it EportAllText.jsx.

Toss it into your scripts folder and give it a try.


TC


//ExportAllText.jsx
//An InDesign CS3 JavaScript
//
//Exports all of the text in the active document as a single
//text file. To do this, the script will create a new document,
//combine the stories in the new document using export/import,
//and then export the text from the new document.
if(app.documents.length != 0){
if(app.documents.item(0).stories.length != 0){
myExportAllText(app.documents.item(0).name);
}
}
function myExportAllText(myDocumentName){
var myStory;
//File name for the exported text. Fill in a valid file path on your system.
var myFileName = "/c/test.txt";
//If you want to add a separator line between stories, set myAddSeparator to true.
var myAddSeparator = true;
var myNewDocument = app.documents.add();
var myDocument = app.documents.item(myDocumentName);
var myTextFrame = myNewDocument.pages.item(0).textFrames.add({geometricBounds:myGetBounds(myNewDocument, myNewDocument.pages.item(0))});
var myNewStory = myTextFrame.parentStory;
for(myCounter = 0; myCounter < myDocument.stories.length; myCounter++){
myStory = myDocument.stories.item(myCounter);
//Export the story as tagged text.
myStory.exportFile(ExportFormat.taggedText, File(myFileName));
//Import (place) the file at the end of the temporary story.
myNewStory.insertionPoints.item(-1).place(File(myFileName));
//If the imported text did not end with a return, enter a return
//to keep the stories from running together.
if(myCounter != myDocument.stories.length -1){
if(myNewStory.characters.item(-1).contents != "r"){
myNewStory.insertionPoints.item(-1).contents = "r";
}
if(myAddSeparator == true){
myNewStory.insertionPoints.item(-1).contents = "----------------------------------------r";
}
}
}
myNewStory.exportFile(ExportFormat.taggedText, File("/c/test.txt"));
myNewDocument.close(SaveOptions.no);
}
function myGetBounds(myDocument, myPage){
var myPageWidth = myDocument.documentPreferences.pageWidth;
var myPageHeight = myDocument.documentPreferences.pageHeight
if(myPage.side == PageSideOptions.leftHand){
var myX2 = myPage.marginPreferences.left;
var myX1 = myPage.marginPreferences.right;
}
else{
var myX1 = myPage.marginPreferences.left;
var myX2 = myPage.marginPreferences.right;
}
var myY1 = myPage.marginPreferences.top;
var myX2 = myPageWidth - myX2;
var myY2 = myPageHeight - myPage.marginPreferences.bottom;
return [myY1, myX1, myY2, myX2];
}






Return to posts index

Jacki in Atlanta
Re: Best way to export text from InDesign? REVISITED
on May 11, 2007 at 6:17:03 pm

Oh my, well how's that for service? Thank you, and thank Ole...! Will try it next week. I got around the triplicate text in the plugin with a little extra work, but this is a task I'll need to do on a whole bunch of files this year, so I will try to find the most efficient way.

You are saying to add this to the InDesign CS2 script folder, right? Just making sure...



Return to posts index


Tim Cole
Re: Best way to export text from InDesign? REVISITED
on May 11, 2007 at 6:21:29 pm

Yes. Copy and paste the script text into a text editor and save it as a .jsx file. Save it into ID's Scripts folder, which is inside the Presets folder.

If you have any problems with the script it's probably because something got scrogged in the copy and paste process. If that happens, try again, and if you still have the problem, let me know and we'll find a way for me to just email the script to you directly.


TC


Return to posts index

Sakina Lokat
Re: Best way to export text from InDesign? REVISITED
on May 22, 2008 at 10:28:22 am


Hey,

I was just wondering how this scripting thing works cause to be honest this is a life saver for me right now but I just don't know how to work it.

I pasted the entire thing into a text editor but I couldn't save it as plain text or the text format .jsx

So I saved it as EportAllText.jsx.doc and then just removed the .doc from the name. Seemed to work.

Anyway, i added the txt file into the IDs script folder but there are four sub folders so which one do I put it in?

As for now I just put it in right under the scripts folder.

Now I opened my ID file and want to export all the text into a wrod document.

How do I do it?

Sorry... Im still new in this field :)



Return to posts index

Tim Cole
Re: Best way to export text from InDesign? REVISITED
on May 9, 2007 at 8:37:29 pm

Jacki, note that this line of the script:

var myFileName = "/c/test.txt";

requires you to enter a valid path for the file export...i.e., where you want the txt file to be saved.

Ole is going to add some UI to the script to eliminate that need asap. I'll post it as soon as he sends it to me. In the meantime, this one should do what you need.


TC


Return to posts index


Tim Cole
Re: Best way to export text from InDesign? REVISITED
on May 9, 2007 at 9:17:09 pm

OK, here's a version that throws up a dialog box asking you where you'd like to save your text file rather than forcing you to enter a path.

If you have any problems running this in CS2, let me know.


TC


//ExportAllText.jsx
//An InDesign CS3 JavaScript
//
//Exports all of the text in the active document as a single
//text file. To do this, the script will create a new document,
//combine the stories in the new document using export/import,
//and then export the text from the new document.
if(app.documents.length != 0){
if(app.documents.item(0).stories.length != 0){
myGetFileName(app.documents.item(0).name);
}
}
function myGetFileName(myDocumentName){
var myFilePath = File.saveDialog("Save Exported File As:");
if(myFilePath != null){
myDisplayDialog(myDocumentName, myFilePath);
}
}
function myDisplayDialog(myDocumentName, myFilePath){
//Need to get export format, story separator.
var myExportFormats = ["Text Only", "Tagged Text", "RTF"];
var myDialog = app.dialogs.add({name:"ExportAllStories"});
with(myDialog.dialogColumns.add()){
with(dialogRows.add()){
with(dialogColumns.add()){
var myExportFormatDropdown = dropdowns.add({stringList:myExportFormats, selectedIndex:0});
}
}
with(dialogRows.add()){
var myAddSeparatorCheckbox = checkboxControls.add({staticLabel:"Add separator line", checkedState:true});
}
}
var myResult = myDialog.show();
if(myResult == true){
var myExportFormat = myExportFormats[myExportFormatDropdown.selectedIndex];
var myAddSeparator = myAddSeparatorCheckbox.checkedState;
myDialog.destroy();
myExportAllText(myDocumentName, myFilePath, myExportFormat, myAddSeparator);
}
else{
myDialog.destroy();
}
}
function myExportAllText(myDocumentName, myFilePath, myExportFormat, myAddSeparator){
var myStory;
var myTempFolder = Folder.temp;
var myTempFile = File(myTempFolder + "/tempTextFile.txt");
var myNewDocument = app.documents.add();
var myDocument = app.documents.item(myDocumentName);
var myTextFrame = myNewDocument.pages.item(0).textFrames.add({geometricBounds:myGetBounds(myNewDocument, myNewDocument.pages.item(0))});
var myNewStory = myTextFrame.parentStory;
for(myCounter = 0; myCounter < myDocument.stories.length; myCounter++){
myStory = myDocument.stories.item(myCounter);
//Export the story as tagged text.
myStory.exportFile(ExportFormat.taggedText, myTempFile);
//Import (place) the file at the end of the temporary story.
myNewStory.insertionPoints.item(-1).place(myTempFile);
//If the imported text did not end with a return, enter a return
//to keep the stories from running together.
if(myCounter != myDocument.stories.length -1){
if(myNewStory.characters.item(-1).contents != "r"){
myNewStory.insertionPoints.item(-1).contents = "r";
}
if(myAddSeparator == true){
myNewStory.insertionPoints.item(-1).contents = "----------------------------------------r";
}
}
}
switch(myExportFormat){
case "Text Only":
myFormat = ExportFormat.textType;
myExtension = ".txt"
break;
case "RTF":
myFormat = ExportFormat.RTF;
myExtension = ".rtf"
break;
case "Tagged Text":
myFormat = ExportFormat.taggedText;
myExtension = ".txt"
break;
}
myNewStory.exportFile(myFormat, File(myFilePath));
myNewDocument.close(SaveOptions.no);
myTempFile.remove();
}
function myGetBounds(myDocument, myPage){
var myPageWidth = myDocument.documentPreferences.pageWidth;
var myPageHeight = myDocument.documentPreferences.pageHeight
if(myPage.side == PageSideOptions.leftHand){
var myX2 = myPage.marginPreferences.left;
var myX1 = myPage.marginPreferences.right;
}
else{
var myX1 = myPage.marginPreferences.left;
var myX2 = myPage.marginPreferences.right;
}
var myY1 = myPage.marginPreferences.top;
var myX2 = myPageWidth - myX2;
var myY2 = myPageHeight - myPage.marginPreferences.bottom;
return [myY1, myX1, myY2, myX2];
}



Return to posts index

bit182
Re: Best way to export text from InDesign? REVISITED
on May 14, 2007 at 10:12:02 pm

I just happened to stumble upon this thread while looking for the same type of text export process. I just tried the script, and it works brilliantly.

The only enhancement I would make to the script would be to have it only recognize the current active layer. I had two brochure designs in one file, and it exported text for both into the file. That's fine because it was exactly what I needed for this situation, but I could see only wanting text for a particular layer to show up.

Thanks again. Awesome script.



Return to posts index

Tim Cole
Re: Best way to export text from InDesign? REVISITED
on May 17, 2007 at 3:05:12 pm

Yeah, being able to select a layer (or to constrain the script to visible layers) would be great. Ole thinks it's a good idea. It's a bit of work to implement, so it won't happen soon given the other things on his plate at the moment.

As it is, though, it's a pretty handy script.


TC


Return to posts index


Jacki in Atlanta
Re: Best way to export text from InDesign? REVISITED
on May 24, 2007 at 7:57:37 pm

I had that layer issue with the plugin I used so I created a new file with each layer alone and it worked. I will still use this when one of these comes up, and they will. Been to busy to test it.


Return to posts index

Sophia Zhang
Re: Best way to export text from InDesign? REVISITED
on Feb 24, 2009 at 4:51:22 am

Hi, everyone, especially greetings to TC! Thanks for your kind help. I'm sorry I still don't know how to do. Could u tell me the steps in details base on the situation I'm sitting in, pls? I'm a graphic designer which use Indesign everyday but don't know how does the program work technically. Thanks.

1) I'm using Mac OX10.5.6, when I use Text Edit to save your scripts, the limited file format for me to save is: RTF, RTFD, HTML,Web archive, odt, docx, doc and Word 2003 XMLFormat, I don't see any options I can save it as a .jsx file. How can I do?

2) I'm using Indesign CS3, the script folder is not located in the Presets folder, there's an independent folder named "Script" under the path of Indesign CS3. Also, as another responder said, there are 4 sub folders inside the IDs Script folder, I don't know which one should I put it in.

3) If I should put it into the "Scripts" folder, inside the Script folder, there's a folder named "Scripts Panel", then "Samples", then 2 folders named "AppleScript" & "JavaScript", c u tell me which one is the right one, pls?

4) How should I do after then? Restart Indesign, then open the artwork, start to export text from the artwork? The biggest problem is: The limited options I can choose from the Export menu are: PDF, EPS, Indesign Interchange, JPEG, SVG, SVG Compressed, XML, I don't think any one of them is a text file format. How can I do?

Waiting for your prompt reply as I'm doing an urgent job needs to export the final text from Indesign CS3. I'm not sure if TC still active on this forum, can anybody knows more than me could supply helps?

Thanks & Regards.

Sophia


Return to posts index

Angela Yates
Re: Best way to export text from InDesign? REVISITED
on Apr 3, 2009 at 10:43:41 am

Yes please, I need this to. Done the save scripting file bit, can't work out how to apply the script to Indesign book? I have all my text in separate spreads as a book in CS3.


Return to posts index

Celia Brissenden
Re: Best way to export text from InDesign? REVISITED
on Jun 5, 2009 at 1:35:55 am

Hi Angela and Sophia

Just found this thread! Hope it's not too late to help you out -

I saved Tim's very helpful script (thanks so much, TC!), then searched InDesign help and worked this out... FYI I'm running CS3 on Win:

With InDesign closed, save the .jsx file you've saved a few layers down inside the Scripts folder, into the JavaScript folder. Here's my filepath...

C:Program FilesAdobeAdobe InDesign CS3ScriptsScripts PanelSamplesJavaScript

Then open InDesign and open the doc you want to export.

Go to the Window folder > Automation > Scripts.

Click on the Scripts tab.

Navigate this filepath: Application > Samples > JavaScript

You'll see the list of java scripts (.jsx) and in there will be ExportAllTexdt.jsx that you saved with Tim's script.

Double click it to run it and choose your format (I chose .rtf) and where you want to save the file.

The result for me was a bit confused in its rendition of a TOC and the footer from the Master page pops up every now and then in an odd spot, but I'm happy to wrangle that, as the hugely long doc is now all there in MSWord.

I'm not a techy, just a communications officer who plays with InDesign...so go forth and good luck!

Celia




Return to posts index

Angela Yates
Re: Best way to export text from InDesign? REVISITED
on Jun 5, 2009 at 7:53:59 am

Hi, Thanks Celia, but this didn't actually answer my question.

I can get all the text from a single document spread, but when it's extracted it has lots of information I don't want eg,
r----------------------------------------rSPREAD DETAILS:
GMIN36
SUM09_US_1
r----------------------------------------r

r---------------- seems to come out on every line.

PLUS because all my pages are in a book not a single document, I need to be able to do this with a book function.

Any help anybody pleeeeease, TC, you still out there?

Thanks,
Angela


Return to posts index

Celia Brissenden
Re: Best way to export text from InDesign? REVISITED
on Jun 5, 2009 at 11:42:20 am

Hi Angela

sorry, missed that about the book.

I have been googling around this today, and will now point you to http://www.rorohiko.com/wordpress/indesign-downloads/

Their Text Exporter (towards the bottom of the list) does a terrific job without all the formatting crap (I got that too using TC's script - no offence meant, Tim).

When I had a problem (this morning) I emailed support and got a reply within an hour or so. Turns out I hadn't had a problem at all -- it hadn't asked me for a 'save as' filepath and I though it hadn't saved. In fact the .rtf file was just sitting in the same folder as my .indd files.

Going on their website's claims and the support I had today from Kris, I wouldn't be surprised if they could assist you with exporting from a book.

Post back to let us know how you go.

Cheers and good luck -

Celia


Return to posts index

Erin Benjamin
Re: Best way to export text from InDesign? REVISITED
on Sep 21, 2009 at 8:27:17 pm

Hello,
I came accross this post and it's exactly what I need but i keep getting this error.

JavaScript Error!

Error Number: 25
Error String: Expected: ;
Line: 53
Source: myStory =
myDocument.stories.item(myCounter);
Offending Text: myStory

I am running InDesign CS3 on Mac OSX 10.5.8

Any help would be greatly appreciated.


Return to posts index

Erin Benjamin
Re: Best way to export text from InDesign? REVISITED
on Nov 12, 2009 at 9:44:21 pm

Anyone?


Return to posts index

Andréa Queirolo
Re: Best way to export text from InDesign? REVISITED
on Jul 26, 2010 at 3:00:43 pm

I have difficulty with javascript and used your script. I get the best results! Thanks a
lot!

Ps. sorry for my english!


Return to posts index

Taavi Tuisk
Re: Best way to export text from InDesign? REVISITED
on Aug 16, 2013 at 1:55:13 pm

This script worked fine even with CS6. Thank you!


Return to posts index

Michael Morris
Re: Best way to export text from InDesign?
on Jun 4, 2013 at 7:28:14 pm

This solution isn't as sexy as a script, but I export my InDesign docs as PDFs, open the PDF in Acrobat Pro, and then export again as a text file. Or you can save as text through the free Acrobat Reader. You may have to tweak the final text file slightly depending on how many stories you have per page, but it works for me.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]