8 Replies Latest reply on Nov 13, 2008 6:09 PM by (HenryL)

    Linked Textframe Export

      Hi,

      I have tried the export function for a set of Linked Textframes, it returned me all the textframes content.

      Is there any way to export a set of Linked Textframes contents one by one into a set of files?

      Thanks.

      Henry
        • 1. Re: Linked Textframe Export
          Loic.Aigon Adobe Community Professional
          could you please be clearer ? Do you want to get a txt file for any linked textframe or a indd ? Let us see the code you already written.
          Loic
          • 2. Re: Linked Textframe Export
            Level 1
            Hi Loic,

            Thanks for your replied.

            Actually, I've a indesign file with 10 textframes which are linked together. I want to have the text inside each textframe export out one by one into a text file so that I can further process the export data.

            I found that the export function would export the whole linked textframe contents together (with 10 textframes content linked together) but not one by one.

            Any advise or suggestion? Thanks.

            Henry
            • 3. Re: Linked Textframe Export
              Loic.Aigon Adobe Community Professional
              Hi one has written a great script here that split linked text frames into separate text frames. Associated with the ExportAllStories.jsx that export all the texts to a text file (or rtf or indsign tagged text), it may lead to what you want.
              Will see that deepler asap.
              Loic
              http://indesignsecrets.com/exporting-all-stories-text-rtf.php
              • 4. Re: Linked Textframe Export
                Level 1
                Hi Loic,

                Thanks for your reply.

                I've read the ExportAllStories.jsx, it can export all the textframes content into 1 txt file, in my case when using this function, the output is all the content in the 10 textframes exported into 1 txt file since the 10 textframes are linked together.

                However, I would like to have the export function doing in the 10 textframes one by one, i.e., 10 txt files would export out instead of 1 txt file.

                I have tried the function text_story.export in a For Loop to go 10 times, all the 10 output files are the same in size and content but not contain the content in difference textframes

                Any hints/references for the issue? Please advise.

                Thank you.

                Henry
                • 5. Re: Linked Textframe Export
                  (Simon_Paterson) Level 1
                  Henry, as Loic pointed out, you must run the SplitStoryFrames script first, then run ExportAllStories.
                  • 6. Re: Linked Textframe Export
                    Loic.Aigon Adobe Community Professional
                    I just tried mixing Peter Werner's awesome script "breakcolumns.jsx" with the "ExportAllStories".jsx. But guys, that are really hot stuff !

                    Peter's script is wonderful but yet difficult (for me) to reduce to your case Henry. Your quickest solution may be as Simon precised to use both script as they are right now.
                    But I think Peter's script is definitive. I mean once columns are broken, they stay broken (That was the purpose of the script).

                    I will try to come back to it later.

                    Loic

                    PS: Henry, you may try to contact Peter (The guy who wrote "breakcolumns.jsx") directly as I don't know if he is still turning around. (Replace X by what you can imagine :-)
                    PeterWerner X gmx.ch
                    • 7. Re: Linked Textframe Export
                      Loic.Aigon Adobe Community Professional
                      Hi HenriL,
                      I hope you keep watching by here.
                      I aggregated both script we talked about. Finally I get tonight this running but quite instable version of the script.
                      As long as you select a textFrame in a thread, no matter the rank of it in the chain, the script should work fine. But I hadn't got the time to fix any situations.
                      Moreover, the name generation for the txt do not convince me but as I don't know the kind of index you want, I let it as it was in the former script.
                      I tried to let Peter's comments all along but maybe one line blew up once in a while.

                      Hope it helps.
                      Come back to me & wish me bravery, so I can find the energy to finish this stuff ;-)

                      //ExportEveryLinkedTextFrameToIndividualTxt.jsx
                      //An InDesign CS3 JavaScript
                      //
                      //Exports all stories from a thread in an InDesign document into individual files using a specified text format.
                      //
                      //This script is a mix between the ExportAllStories script from Adobe & uses smart functions from Peter Werner's script "BreakColumns.jsx.
                      //As this moment there is a few bugs to fix but it's late. Loic Aigon
                      //

                      if(isValidContext()){
                      myDisplayDialog();
                      }
                      else{
                      alert("No documents are open. Please open a document and try again.");
                      }
                      function myDisplayDialog(){
                      with(myDialog = app.dialogs.add({name:"ExportAllStories"})){
                      //Add a dialog column.
                      myDialogColumn = dialogColumns.add()
                      with(myDialogColumn){
                      with(borderPanels.add()){
                      staticTexts.add({staticLabel:"Export as:"});
                      with(myExportFormatButtons = radiobuttonGroups.add()){
                      radiobuttonControls.add({staticLabel:"Text Only", checkedState:true});
                      radiobuttonControls.add({staticLabel:"RTF"});
                      radiobuttonControls.add({staticLabel:"InDesign Tagged Text"});
                      }
                      }
                      }
                      myReturn = myDialog.show();
                      if (myReturn == true){
                      //Get the values from the dialog box.
                      myExportFormat = myExportFormatButtons.selectedButton;
                      myDialog.destroy;
                      myFolder= Folder.selectDialog ("Choose a Folder");
                      if((myFolder != null)&&(app.activeDocument.stories.length !=0)){
                      myExportAllStories(myExportFormat, myFolder);
                      }
                      }
                      else{
                      myDialog.destroy();
                      }
                      }
                      }
                      //myExportStories function takes care of exporting the stories.
                      //myExportFormat is a number from 0-2, where 0 = text only, 1 = rtf, and 3 = tagged text.
                      //myFolder is a reference to the folder in which you want to save your files.
                      function myExportAllStories(myExportFormat, myFolder){

                      var mysel = app.selection[0];
                      var firstTf = mysel.startTextFrame;
                      var lastTf = mysel.endTextFrame;
                      var nTf = firstTf.nextTextFrame;
                      var mycount = 0;
                      exportMe(firstTf);
                      while(nTf!=lastTf)
                      {
                      exportMe(nTf);
                      nTf = nTf.nextTextFrame;
                      }
                      exportMe(lastTf);
                      }

                      function isValidContext()
                      {
                      // We need an active document
                      if( app.documents.length == 0 )
                      return false;

                      // We need stories
                      if( app.activeDocument.stories.length == 0 )
                      return false;

                      // We need a selection for this to work
                      if( app.selection.length == 0 )
                      return false;

                      // We can only operate on a text frame
                      if( app.selection[0].parent.constructor.name != "Story" && app.selection[0].constructor.name != "TextFrame" )
                      return false;

                      var tf = getSelectedTextFrame();

                      // We need a valid frame selection
                      if( tf == null )
                      return false;

                      // We can't work on a locked frame. We could theoretically unlock
                      // and then relock the frame, but that would kind of defeat the purpose
                      // of letting the user lock a frame. The command being greyed out
                      // is more like what a user would expect, even though InDesign lets
                      // users change the number of columns on a locked frame.
                      if( tf.locked == true )
                      return false;

                      // Everything's fine
                      return true;
                      }

                      //-----------------------------------------------------------------------------
                      //
                      // This function returns a text frame for the current selection, or null if
                      // no text frame or text in a frame is currently selected.
                      //
                      function getSelectedTextFrame()
                      {
                      if( app.selection[0] == null )
                      return null;

                      if( app.selection[0].parent.constructor.name == "Story" )
                      return app.selection[0].parentTextFrames;

                      if( app.selection[0].constructor.name == "TextFrame" )
                      return app.selection[0];

                      return null;
                      }

                      function exportMe(Me)
                      {
                      Me.texts[0].select();
                      myStory = app.selection[0];
                      myID = Me.id;
                      switch(myExportFormat){
                      case 0:
                      myFormat = ExportFormat.textType;
                      myExtension = ".txt"
                      break;
                      case 1:
                      myFormat = ExportFormat.RTF;
                      myExtension = ".rtf"
                      break;
                      case 2:
                      myFormat = ExportFormat.taggedText;
                      myExtension = ".txt"
                      break;
                      }
                      myFileName = "StoryID" + myID + myExtension;
                      myFilePath = myFolder + "/" + myFileName;
                      myFile = new File(myFilePath);
                      myStory.exportFile(myFormat, myFile);
                      }
                      • 8. Re: Linked Textframe Export
                        Level 1
                        Hi Loic,

                        Appreciate for your work. Thank you very much for the great help. I'll try and modify it by myself if needed and let you know what I modify it.

                        Thanks.

                        Henry