Exporting Paragraph Styles of an InDesign File

Posted on 2007-08-06
Last Modified: 2013-12-02
I need help exporting paragraph styles of an InDesign file to text file using javascript.

Also I need to export tags to a file as well.

function myExportStyle() {
      myDoc = app.activeDocument;
      // get current folder name
      var myFldrName = myDoc.filePath;

      // create file name to write by documentStyles.txt
      var myTextName =".indd").join("Styles.txt");

      // set current file to path of document / documentnameStyles.txt
      var myFile = File(myFldrName + "/" + myTextName);
      // open file"w");

      // write file
      myFile.write("Paragraph Styles " + myDoc.paragraphStyles.length + "\n");

      // close file
Question by:bergstrom_davin
    LVL 51

    Accepted Solution

    are you talking about server-side javascript?
    LVL 1

    Author Comment

    The file has a .jsx extension. I am not sure what you mean by server-side javascript.
    LVL 75

    Expert Comment

    by:Michel Plungjan
    LVL 1

    Author Comment

    I am attempting to write a script that will update the xml tree without losing attributes. I have received a good base code from Olav Knerv on the Adobe forums that I need to extent.

    What I need to do is get a listing of all tag styles and paragraph styles and their association. So I can force mapping on paragraphs that have not been mapped automatically on a 100+ page document.
    LVL 1

    Author Comment

    Here is the function I got working had to dig up the DOM for InDesign

    function mySaveXmlMap () {
          var myMaps, myString, myDoc;

          myDoc = app.activeDocument;
          myMaps = myDoc.xmlExportMaps;
          myString = "";
          // creates tabbed list of stylename [tab] tagname [newline]
          for (count = 0; count < myMaps.count(); count++) {
                myString +=  myMaps[count] + "\t" + myMaps[count] + "\n";

          mySaveMappings (myString.trim());

    function mySaveMappings (myString) {
          var myFilePath = myFindFile();
          var myFile = File(myFilePath);

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now