2 Replies Latest reply: Feb 26, 2013 7:59 AM by 4everJang RSS

    Script needed to generate a list of paragraph and character styles from the Book Level

    jamesm0671 Community Member

      Hello,

       

      I am using FrameMaker 11 in the Adobe Technical Communication Suite 4 and I need to find a script that will generate a list

      of paragraph and character styles from the book level.

       

      I am working with unstructured FrameMaker books, but will soon be looking at getting a conversion table developed
      that will allow me to migrate all my data over to Dita (1.1 for now).

       

      Any thoughts, ideas on this is very much appreciated.

       

      Regards,

       

      Jim

        • 1. Re: Script needed to generate a list of paragraph and character styles from the Book Level
          Russ Ward Community Member

          Hi Jim,

           

          I think the problem you are having with getting a response is that you are asking someone to write a script for you. Normally, you would have to pay someone for this, as it is something that folks do for a living.

           

          Nonetheless, I had a few minutes to spare, so I worked up the following script that I believe does the job. It is very slow, clunky, and totally non-elegant, but I think it works. It leverages the book error log mechanism which is built in and accessible by scripts, but is spendidly unattractive. I hope this gives you a starting point. It could be made much more beautiful, of course, but such would take lots more time.

           

          Russ

           

           

           

          ListAllFormatsInBook()
          
          function ListAllFormatsInBook()
          {
              var doc, path, fmt;
              
              var book = app.ActiveBook;
              if(!book.ObjectValid()) book = app.FirstOpenBook;
          
              if(!book.ObjectValid())
              {
                  alert("No book window is active. Cannot continue.");
                  return;
              }
          
              CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
              CallErrorLog(book, 0, 0, "** Book format report for:");
              CallErrorLog(book, 0, 0, book.Name);
          
              var comp = book.FirstComponentInBook;
               
              while(comp.ObjectValid())
              {
                  path = comp.Name;
                  
                  doc = SimpleOpen (path, false);
                  
                  if(doc.ObjectValid())
                  {
                      CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
                      CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
                      CallErrorLog(book, doc, 0, "");
                      CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
                     
                      CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
                      CallErrorLog(book, 0, 0, "Paragraph formats:");
                      fmt = doc.FirstPgfFmtInDoc;
                      while(fmt.ObjectValid())
                      {
                          CallErrorLog(book, 0, 0, "  - " + fmt.Name);
                          fmt = fmt.NextPgfFmtInDoc;
                      }
                      
                      CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
                      CallErrorLog(book, 0, 0, "Character formats:");
                      fmt = doc.FirstCharFmtInDoc;
                      while(fmt.ObjectValid())
                      {
                          CallErrorLog(book, 0, 0, "  - " + fmt.Name);
                          fmt = fmt.NextCharFmtInDoc;
                      }
                  }
                  
                  else
                  {
                      CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
                      CallErrorLog(book, 0, 0, "!!!  Could not open: " + comp.Name + " !!!");
                      CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
                  }
              
                  comp = comp.NextComponentInBook;
              }
          }
          
          function CallErrorLog(book, doc, object, text)
          {
              var arg;
              
              arg = "log ";
              
              if(book == null || book == 0 || !book.ObjectValid())
                  arg += "-b=0 ";
              else arg += "-b=" + book.id + " ";
              if(doc == null || doc == 0 || !doc.ObjectValid())
                  arg += "-d=0 ";
              else arg += "-d=" + doc.id + " ";
              if(object == null || object == 0 || !object.ObjectValid())
                  arg += "-O=0 ";
              else arg += "-O=" + object.id + " ";
              arg += "--" + text;
              
              CallClient("BookErrorLog", arg);
          }
              
              
          
          
          • 2. Re: Script needed to generate a list of paragraph and character styles from the Book Level
            4everJang Community Member

            Jim,

             

            If I understand it correctly, you will be using the list of paragraph and character styles to define the first level of a conversion table. Unless your books contain very large numbers of chapters, there is no need to write a script for this. You simply call the StructureTools > Generate Conversion Table command on the first chapter in the book. Save the generated conversion table. Then for each of the remaining chapters in the book, open that chapter and call the Generate Conversion Table command again, choosing the option to add the formats to the existing conversion table document. What remains is a full conversion table that contains all your paragraph, chapter and cross-reference formats, plus markers and table elements.

             

            Good luck. If you get stuck or need someone to build your conversion tables, let me know. I won't do it for free, as I do need to make a living out of this, but I have done the work before and that might help.

             

            Jang