Skip navigation
Currently Being Moderated

Way to export style description/style settings

Jan 25, 2013 12:27 AM

Does anyone know of a way to export all of the document's paragraph style description/style settings info to a text file? Is there a script that can do the trick?

 
Replies
  • Currently Being Moderated
    Jan 25, 2013 2:13 AM   in reply to Dimitra.p

    Here is a script that makes a list of all paragraph styles and character styles and their settings: font name, size and leading. It saves the information to csv-file so it can be opened in Excel. You can add more properties if needed and change the extension to ".txt".

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 25, 2013 6:55 AM   in reply to Dimitra.p

    Dimitra.p wrote:

     

    Thank you very much. I tried it and it works but doesn't give me all the info I need.

    Is there a way to tweak this script to include more properties like tracking, paragraph space before/after, alignment, indents, paragraph rules etc?

    The commercial Blatner Tools plug-in for InDesign, from DTPtools.com, adds a style report item to the paragraph and character panel menus that offers user-selectable options for which styles to report, and for every style attribute.

     

    The cost might be more than you like for this one reporting feature, but it's only one of many features you might also find useful. There's a trial.

     

     

    HTH

     

     

    Regards,

     

     

    Peter

    _______________________

    Peter Gold

    KnowHow ProServices

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 26, 2013 7:49 AM   in reply to Dimitra.p

    Yes, I can do this, but not today because I'm finishing the current issue of my magazine.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 27, 2013 7:12 AM   in reply to Dimitra.p

    I am writing a script that will export all (or maybe almost all) properties of the paragraph styles; I've already made most of them.

    I am sorry for the previous post: I referred to the wrong scripts since my head was too busy with work.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 27, 2013 8:29 AM   in reply to Dimitra.p

    Here is the first version of the script.

    I'd like to know what you and others on the forum think about it and if anybody is interested in the script to be developed further.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 28, 2013 1:57 AM   in reply to Kasyan Servetsky

    Kasyan Servetsky wrote:

     

    Here is the first version of the script.

    I'd like to know what you and others on the forum think about it and if anybody is interested in the script to be developed further.

     

    Two very minor notes:

     

    * The difference between CS4, on which I tried, and CS6 are not really earth shattering. If you wrap some code around the "Keep with Previous" and "Span Columns" sections, it will also work with CS4!

    (An issue, then, would be that CS4 does not automatically expand numerical constants into enumeration names.)

     

    * "CSV" stands for "comma separated values", and you use "SSV" -- 'semi-colon separated' and my hyper-modern, state-of-the-art, Microsoft's Flagship, The Pride of All of Redmond County (etc.) Excel Professional Plus 2010 ... does not recognize semi-colons! It also seems to ignore the fancy column headers that are visible on your own image. (OTOH, it just may be me.)

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 28, 2013 9:48 AM   in reply to [Jongware]

    Thank you for your feedback, Jongware.

     

    I made a new version which works in CS3–6. I tested it in CS3, 5, 5.0 and 6, and I will test it in CS4 when I get to work. Enumerations are not a problem because the script handles them in switch statements that convert them to human-transparent strings (the same as in the UI).

     

    In Excel (I use  2007 for Windows) this option is called "CSV (Comma delimited)", but in fact, it saves the file as semicolon-delimited. It's confusing. Once I wrote a script that used  csv-files exported from Excel 2010 for Mac, which were indeed comma separated, but every cell was enclosed in three pairs of double quotes. I guess that's because commas are also used in text.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 12, 2013 1:08 PM   in reply to peter at knowhowpro

    I made a new version.

    export_styles_description_settings_to_csv_3.jpg

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 13, 2013 8:54 AM   in reply to Kasyan Servetsky

    @Kasyan – this script is very helpful. Thank you.

     

    I just did a quick test with InDesign CS5.5 on Mac OSX 10.6.8 (German).

     

    Process: active Document

    For column delimiters use: Tab
    File extension: TXT

    [ ] Open CSV/TXT file: unchecked

     

    I then opened the text file in TextEdit app and copy/pasted the contents to a new Excel sheet.

     

    One minor glitch is that the  text document will translate characters like "ß" to "√ü" (one of the paragraph styles were named "Fußnotentext" //=Footnotetext).

     

    This Excel sheet was not prepaired in any case and my German Excel insists, that dot values like "7.5" will translate to "7.Mai" which obviously is a date format. But that glitch is related to not pre-formatting the Excel file.

     

    To work around thiese issues I expanded your

     

    WriteToFile(text){} function

     

    with a few lines of code (quickly written), so that in addition to the txt file a new InDesign file is generated with a text frame, that holds "text" as contents. Afterwards I could easily transform the contents to an InDesign table.

     

    Then: "ß" remains "ß" and (of course) "7.5" remains "7.5".

     

    Code added to your WriteToFile(text){} function:

     

    //ADDITIONAL:
    if(extension === ".txt"){
        var logDoc = app.documents.add();
        var logTF = logDoc.textFrames.add({geometricBounds:[0,0,297,210]});
        logTF.contents = text;
        };
    

     

     

    As I already said, this was just a quick test.
    If time allows, I will test on with InDesign CS3, CS4, CS5 and CS5.5.

     

    Uwe

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 14, 2013 2:39 AM   in reply to Laubender

    Hi Uwe,

     

    I encountered the same issues in Russian:

    1. Excel “helpfully” converted floating numbers to dates until I changed a parameter in regional settings (don’t remember which exactly at the moment: may be dot to comma for decimal separators)

    2. If a paragraph/group name contains non-English characters, in Excel they’re displayed as abracadabra if CSV format is used. That’s why I added “tab delimited + TXT” option: such files are opened by the wizard so you can choose encoding, cell format, etc. Though it adds a few manual steps, it gives you full control over settings.

    CSV is opened without any dialogs which is faster, but I don’t know if it’s possible to change default encoding in Excel.

    Yesterday I tested it in CS3 and CS6 both on Mac and Windows fixing numerous bugs and today posted a new version – 3.1 which seems to be working as expected.

     

    Regards,

    Kasyan

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 14, 2013 3:33 AM   in reply to Kasyan Servetsky

    Hi, Kasyan!

     

    Yesterday I discovered a few bugs and maybe one encoding/decoding problem.

     

    The last one mentioned is still present in the new 3.1 version of the script. All others are resolved.

     

    Under:

    Bullets and numbering

        Bullet character

     

    I see a number:

        8226

     

    where it should be something like "2022", the Unicode for the glyph "BULLET"?

     

    Or the following example, where I see the number "42" listed (stands for the "ASTERISK", Unicode 002A).


    Another minor glitch:

    Some result columns are left blank, where you could have inserted a N/A annotation (or maybe not? Hm. That we can debate…), if the feature is not used or not present at all. (I tested with InDesign CS5.5 v7.5.3):

     

    Nested styles

    Nested line styles

    GREP style

     

    Export tagging - EPUB and HTML

         Tag

         Class

         Split document (EPUB only)

     

     

    So far so good!
    Thanks!

     

    Uwe

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 15, 2013 3:38 AM   in reply to Laubender

    Hi Uwe,

    Under:

    Bullets and numbering

        Bullet character

     

    I see a number:

        8226

     

    where it should be something like "2022", the Unicode for the glyph "BULLET"?

     

    Or the following example, where I see the number "42" listed (stands for the "ASTERISK", Unicode 002A).

     

    I think 8226 is decimal value for 0x2022 – hexadecimal equivalent of Unicode value for Bullet character.

    1.jpg

    So, may be a simple conversion from Dec to Hex and adding “0x” is needed here. Though the situation with this property – characterValue – is not quite clear to me. The scripting reference states: “The bullet character as a Unicode ID or a glyph ID.” I made a quick test and found out that if the default font (set in the basic character formats > font family) is not changed by bulletsFont, a Unicode value is used as decimal. If it is changed, a GID value is used instead. However it’s not clear to me how this works so I may be wrong.

     

     

    Some result columns are left blank, where you could have inserted a N/A annotation (or maybe not? Hm. That we can debate…), if the feature is not used or not present at all.

    I had the same idea too, and even did this in one of intermediate versions. But I temporarily abandoned the idea because I haven’t sorted out how some properties work: some properties, if the user doesn’t change them, are “blank”, but some have default values even when user hasn’t changed them (e.g. span columns). I’d like somehow to indicate the difference. Anyway, in the next version I’ll change them to “N/A” as you suggested.

     

    Regards,

    Kasyan

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 15, 2013 3:52 AM   in reply to Kasyan Servetsky

    Kasyan Servetsky wrote:

     

    Hi Uwe,

     

    Under:

    Bullets and numbering

        Bullet character

     

    I see a number:

        8226

     

    where it should be something like "2022", the Unicode for the glyph "BULLET"?

     

    Or the following example, where I see the number "42" listed (stands for the "ASTERISK", Unicode 002A).

     

     

     

     

    I think 8226 is decimal value for 0x2022 – hexadecimal equivalent of Unicode value for Bullet character.

    1.jpg

    So, may be a simple conversion from Dec to Hex and adding “0x” is needed here. Though the situation with this property – characterValue – is not quite clear to me. The scripting reference states: “The bullet character as a Unicode ID or a glyph ID.” I made a quick test and found out that if the default font (set in the basic character formats > font family) is not changed by bulletsFont, a Unicode value is used as decimal. If it is changed, a GID value is used instead. However it’s not clear to me how this works so I may be wrong.

     

    Try this -- a property of "Bullet":

     

    #characterTypeBulletCharacterType:
    BulletCharacterType.UNICODE_ONLY
    BulletCharacterType.UNICODE_WITH_FONT
    BulletCharacterType.GLYPH_WITH_FONT

     

    By the way, I also did a quick experiment with weird characters in style names. It works in Excel with your JS file set to "latin1" encoding, but any lines with characters that are not available in Latin-1 are simply ignored. So it would work for Uwe (since his German umlauts and Ringelesses *are* available), but not for you (Cyrillic is *not* in Latin-1). But the problem lies, of course, in Excel. Since you cannot set an encoding 'in' a CSV file, it's dumb enough to assume everything the world needs is Latin-1. ... A fairly typical attitude, for Microsoft at least.

    Hmm -- while typing this: perhaps you can try to feed it UTF16, with an appropriate BOM for Little or Big endian?

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 21, 2013 5:47 AM   in reply to [Jongware]

    Thank you for your advice, Jongware. In current version 3.2 I did as you sugested: the script checks characterType and displays the bullet character like so:

    1.jpg

    After adding BOM character  – FEFF – with UTF-8, Cyrillic text is imported correctly into Excel. I wonder if it works properly for other non-English languages now. Uwe, does it work for German?

    Empty cells now filled with “N/A”

     

    Regards,

    Kasyan

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 21, 2013 8:38 AM   in reply to Kasyan Servetsky

    Hi, Kasyan!
    Good work. Congratulations!
    The encoding for "ß" is working now. Also the Bullet Characters are translated very well.
    This was just a quick test, however.

     

    I'm in a hurry so cannot test any further before Monday.

     

    Cheers,
    Uwe

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 22, 2013 2:09 AM   in reply to Laubender

    Hi Uwe,

     

    Yesterday I tested it on Mac: InDesign CS6 and Excel 20110. It turned out that the trick didn’t work there. The BOM character – FEFF – appeared as tree strange characters in A1 cell and Cyrillic names remained mangled (with/without adding FEFF).

    1.png

    So far I don’t know what to do with this. I’ll look into the issue further.

     

    Regards,

    Kasyan

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 29, 2013 4:16 AM   in reply to Kasyan Servetsky

    I made a new version -- 3.3 -- added all the properties for tabs and rules above-below.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 29, 2013 5:36 AM   in reply to Kasyan Servetsky

    @Kasyan – great!

    Just tested.

     

    Hm.

    With v3.3 the Umlaut-ß-problem is back again…

    Like it was in v3.0 and v3.1 (not in v3.2!)

     

    Name of paragraph style is:

     

    "Fußnotentext"

     

     

    TXT-report or CSV-report is changing that to:

     

    "Fußnotentext"

     

     

     

    Will test something more…


    Uwe

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 30, 2013 4:38 AM   in reply to Laubender

    Hi Uwe,

     

    In version 3.3 I tried to solve the issue described in post 18 by adding BOM character on Windows only since it didn't fix Cyrillic characters on Mac. In new version -- 3.4 -- I added it again as it was in 3.2. However in the cell A1 three weird characters appear now (on Mac). I don't know how to get rid of them.

     

    Regards,
    Kas

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 30, 2013 5:16 AM   in reply to Kasyan Servetsky

    Kasyan, I'm suspecting there are irreconcible differences between the Mac and Windows versions of Excel!

     

    Perhaps you could ask if/how Cyrillic (and UTF-8 in general) is supported in a CSV file on a Microsoft forum. Only thing is, those forums are most likely highly Windows-centred -- and on Windows, it works! :-p

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 30, 2013 5:23 AM   in reply to [Jongware]
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 31, 2013 5:39 AM   in reply to [Jongware]

    Thank you for pointing this out, Jongware.

    I'm wondering if using another encoding for Mac would solve the issue:

     

    if (File.fs == "Windows") {
        file.encoding = "UTF-8";
    }
    else {
        file.encoding = "MACINTOSH"; // or "X-MAC-ROMAN"
    }
    

    But I'll be able to test it only on Wednesday when I get to work.

     

    Regards,
    Kas

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 2, 2013 8:42 AM   in reply to Kasyan Servetsky

    Um hi guys, I'm good with InDesign but pretty new to scripts and useless in Excel - I'm trying to lay out some corperate fonts for my company for consistancy and chose one of our documents to export my paragraph syles as above using Kasyans 3.4 in InDesign 5.5 for Windows. But when it opens in Excel I'm not getting nice tidy columns, it looks like the right information but most seems stuffed into one cell, or column.

     

    When I go Format < Autofit Column Width it just expands column A to the width of the screen and there's still heaps of stuff in it and there doesn't seem to be a way to make it a nice tidy (legible) table, with a different figures or titles in each column. I also tried Laubender's trick of opening it in notepad, and it does look better but I get the same thing when I open the file in Excel, all jumbled together.

    Can anyone please offer me some simple instructions to get the info all in different cells/columns, preferably without copying and pasting each item from notepad (cos I may as well just type it up from my Paragraph Styles dialogue box)?

    thanks so much

    Philip

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 2, 2013 8:49 AM   in reply to Eavisgrebe

    ExcelscreengrabGrebesworth.jpg

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 2, 2013 10:43 AM   in reply to Eavisgrebe

    Hi Philip,

     

    From the screenshot I see that you're on Windows. What version of Excel do you have? I tested it only in 2007 on Windows and in 2011 on Mac —  it works for me. Most probably your version is newer than mine and something changed there.

    Try to use other options for delimiters: Tab with "txt" extension, and comma with "csv" extension.

     

    Kas

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 2, 2013 11:26 AM   in reply to Kasyan Servetsky

    Hi Kas...

     

    Works for me in Excel 2010 and LibreOffice. I used tab delimited. Pretty cool bit of work. Thank you.

     

    Mike

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 2, 2013 11:00 PM   in reply to Eavisgrebe

    @Philip – what I do is chosing TAB delimiter and TEXT as output format.
    (I'm on Mac OSX 10.6.8 and working with TextEdit)

    Then I copy/paste the text file to Excel where I select only one single cell before pasting.

     

    After that I set the formatting of the selection (all used cells) to Text and paste again.

     

    This is necessary because my German Excel insists to use Date formatting where floating point data is presented (eg.  point size like 9.5 will change to 9th of May etc.).

     

    Maybe today I have the chance to test that workflow on Windows with several different Excel versions…

     

    Uwe

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2013 1:08 AM   in reply to Laubender

    Hi guys and thankyou so much for your kind responses. I sat down at my desk and tried what you said and it worked fine! When I tab delimit it and copy from notepad it all just sorted itself neatly into its table in Excel! (For the record I'm using Excel 2010, Kasyan). now I need to decide what to do with all this information! Great job and thanks again for your help!

    Philip

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 5, 2013 3:33 AM   in reply to Laubender

    @Uwe

    This version works for me on Mac with "Tabs" and "CSV" selected: all the Cyrillic text is readable and no strange characters appear any more. I wonder how it works with German?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 16, 2013 7:23 AM   in reply to Kasyan Servetsky

    @Kasyan – sorry for the delay…

     

    Hi, Kasyan!

     

    Today I tested your script version 3.5.

    This time I used all 6 possible output file options.

     

    To make it short: For me, the only useful way for output is still:

    "Tab" as delimiter for columns,

    "Txt" as output format and:

    "Open CSV/TXT File" checked.

     

    Here the details:

     

    Using CSV:

     

    Every time I checked "Open CSV/TXT File" my Excel will pop up and showing date formatted instead of floating point values. I couldnot change that in Excel back to the original values (maybe I'm not versed enough!).

    So using "csv" is a dead end.

     

    After expecting all three possible csv formats, its seems, that:

    "Comma" for column delimiters writes an UTF8 file.

    "Semicolon" for column delimiters writes an UTF8 file.

     

    Only "Tab" chosen as delimiter is writing a UTF16 file.

     

    (The same goes for txt files)

     

    CSV Comma UTF8

    CSV Semicolon UTF8

    CSV Tab UTF16

     

    TXT Comma UTF8

    TXT Semicolon UTF8

    TXT Tab UTF16*

     

    Opening all UTF8 formatted csv files directly in my Excel will give me the formatting problem with Umlauts, ß etc. plus the problem with unwanted date formats.

     

    Opening the UTF16 formatted csv file directly in Excel is showing no problem with Umlauts, ß etc. (however, the problem with unwanted date formats persists).

     

     

     

    *Using TXT:

     

    Since Tab delimited txt file is the only option with UTF16 I'm using this the following way, which really is working best for me and is the only functionable workflow:

     

    1. Open the TXT file (UTF16) in TextEdit.app

    2. Copy/paste to new Excel sheet

        => values like "1.2" change to date information: "1. Februar"

    3. Format all cells with plain TEXT (all necessary cells are automatically selected)

    4. Paste again (cells are still selected and the pasted contens overrides the previous cell contents)

        => values like "1.2" stay the same

     

    (OSX 10.6.8, InDesign CS5.5 v7.5.3, TextEdit, Excel 2004 | all German)

     

     

    Uwe

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 17, 2013 1:57 AM   in reply to Laubender

    Hi Uwe,

    The problem with unwanted date formats has nothing to do to Excel, InDesign or the script. This happens because you have "Non English" settings in your System. I had the same issue with my Russian system too. If you change comma to dot in the "decimal separator" (not sure if that's correct translation) field, it should work as expected.

    On Windows, it should be changed here:

    2.jpg

    There’s an analogous setting on Mac but I don’t remember which exactly (I don’t have a Mac at hand at the moment).

     

    Try to do the following:

    1.    Change temporarily your "Language & Text" settings from German to English

    2.    Run the script and choose "Tab" for delimiters and "CSV" for file extension

    3.    Open the csv-file in Excel

    I can test it with German characters on Mac later today when I get to work.

     

    There is significant distinction between different versions of Excel on both platforms (the way they import csv/txt files). I made options for selecting a delimiter and file type to make sure that at least one combination of the settings works for every version.

     

    Regards,
    Kasyan

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 17, 2013 11:16 AM   in reply to Laubender

    Today I tested it more carefully on two Macs.

    The first is my work machine:  Excel 2011, InDesign CS6, Mac OS X 10.6.8

    With “Delimiters” set to “Tab” and “File extension” to “CSV” everything works correctly.

    No problems with German and Cyrillic characters:

    1.png

    The second Mac: Excel 2004, InDesign CS3, Mac OS X 10.4.11

    At first I encountered the both problems: numbers rendered as dates and non-English names were mangled.

    Solution 1 (almost the same as Uwe suggested):

    1. "Tab" as delimiter for columns,
    2. "Txt" as output format and:
    3. "Open CSV/TXT File" checked.
    4. Select and copy all text
    5. In Excel select all cells and choose “Text” in “Format Cells” > “Number”
    6. After that paste the text.

    Solution 2:

    1. Choose “File” > “Open” and select the TXT/CSV file
    2. In the ”wizard” that appears you can select a number of setting, in the “Advanced” section select “dot” for decimal delimiters.
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 22, 2013 7:20 AM   in reply to Kasyan Servetsky

    Hi Kasyan,

     

    I want to thank you for this script, and thank everyone in all this thread, it is very useful discussion, really many thanks for every one participate in this discussion.

     

    In the same time I have a question. I want to ask you about something further depend on your script result.

     

    Do you think that there is a way to do the reverse way for your script?

     

    I mean we export [paragraph styles and character styles and their settings: font name, size and leading. so..] from someone document.

     

    After I got  CSV file. I will make some modifies on that file, such as change paragraph styles settings indent value and character style settings size, language , and so...

     

    AFTER that change Can I re-insert the file to the same document with this modification?

     

    So the result will be same styles with modifies i did.

     

    Thanks again for you amazing efforts.

     

    Regards,

    Hima

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 22, 2013 7:27 AM   in reply to MW Design

    i agree with you

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 22, 2013 11:03 AM   in reply to Kasyan Servetsky

    @Kasyan – Thank you for further testing.

     

    "Solution 1" is still working best for me. Especially your modified version :-)


    I also tested "Solution 2" with "Excel 2004" on Mac.

    Thank you for the hint with the "Advanced" section. But to get it the way I want (the original representation of the values), I'll have to change my OS settings…

     

    So I will stick with "Solution 1":
    It's  easy to handle, I will not forget about  a possible "Advanced" setting in the open CSV/TXT "wizard" of Excel, not get fooled with the "Preview" and I need not to change my International Settings for number representation in my OS.

     

    Uwe

     

    Message was edited by: Laubender

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 23, 2013 4:09 AM   in reply to Hima.ib

    @Hima

    Yes, I am planning to add the “Import” feature in the future when time permits.

     

    @Uwe

    I’ve uploaded the version 3.5 on my site and will write some clarification regarding the “dates appearing instead of numbers” problem soon.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points